...
go build
Install it
go install
FunctionsÂ
Example showing error returnFunctions
Code Block |
---|
package main import ( "fmt" "error" "math" ) func main() { result, err := sqrt(16) if err != sum(2,3 nil { fmt.Println(err) } else { fmt.Println(result) } } func sqrt(x float64) (float64, error ) { if x < 0 { return 0, errors.New("Undefined for negative numbers") } return math.Sqrt(x), nil } |
Commands
Command | Description |
---|---|
go run <src.go> | Run some code |
go build | Compile the code. Outputs to local folder. Executable has folder as name. |
go install | Compiles and places the output in workspace/bin |
go env GOPATH | Outputs the default workspace folder |
...