Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Run it

go run helloworld.go

Compile it

go build

Install it

go install

Commands

CommandDescription
go run <src.go>Run some code
go buildCompile the code. Outputs to local folder. Executable has folder as name.
go installCompiles and places the output in workspace/bin
go env GOPATHOutputs the default workspace folder

Variables

Variables are defined using the following syntax:

var <variablename> <type>

example:

var x int

All variables have a zero value and are pre-initialized to their zero value. For example, an int would have a zero value of 0 and a string would have a zero value of empty string "".


Code Block
package main
  
import (
  "fmt"
)

func main(){
  var x int
  fmt.Println(x)
}


References

ReferenceURL
Learn Go in 12 Minuteshttps://www.youtube.com/watch?v=C8LgvuEBraI
Go Packageshttps://golang.org/pkg/