These are notes from a youtube video of the same name
By default its ~/go
You can determine via
$ go env GOPATH
/Users/davis/go
Note, you can put code in that same dir, but you can also use the src dir as done here.
$ cd src
$ mkdir go12m
$ cd go12m
$ vi go12m.go
Add the following code
package main
import "fmt"
func main() {
fmt.Println("yo")
}
Run the code in one step. Note, this will not create an exe file like would happen if you did a separate compile (go mod; go build) step.
$ go run go12m.go
Building the code to make an exe is like this:
$ go mod init go12m
$ go mod tidy
$ go build
You can also do an install. This will put the executable in
the ~go/bin
directory.
$ go install
// var name type
var value int
// init a value
var my_pi int = 3.14
// Shorthand for initialized value (type is inferred)
my_pi2 := 3.14
let x int = 6
if x > 6 {
fmt.Println("More than 6")
} else if x < 2 {
fmt.Println("Less than 2")
} else {
fmt.Println("<= 6 and >= 2")
}