Quick start Go

  1. Make a empty folder on desktop

  2. Open it with VScode

  3. Make a file named main.go leave it blank for now

  4. Run

go mod init <name of project> 
  1. This will make a go.mod file, simple answer it where dependencies live

  2. To add a dependency

go get <package name>

*NOTE*

Sometime the dependency do not want to play well so you may need to run this command and save a few times to make all the errors and warnings go away

go mod tidy

Basic hello world

  1. This to the main.go file

package main
import (
    "fmt"
)
func main(){      
      fmt.println("Hello world")
}
  1. Run

go run main.go

Last updated