Skip to content

Start Project

mkdir ~/Golang/projects/hello && cd ~/Golang/projects/hello

Create Module

A Go module or module path as a canonical name or identifier for your project and need to be unique.

For example initialize a module:

go mod init hello.example.com

Which creates a file go.mod:

module hello.example.com

go 1.22.4

Hello World

Create the following main.go file:

hello.go
package main

import "fmt"

func main() {
    fmt.Println("Hello world!")
}

Run the program:

go run .