This is an old revision of go from 14.10.2017 21:22 edited by EvaggelosBalaskas.
go in archlinux
$ sudo pacman -S go go-tools $ go version go version go1.9.1 linux/amd64 $ cat > helloworld.go << EOF package main import "fmt" // This is a demonstrative comment! func main() { fmt.Println("Hello World!") } EOF
$ go run helloworld.go fork/exec /tmp/go-build127438955/command-line-arguments/_obj/exe/helloworld: permission denied $ mkdir -pv TMPDIR mkdir: created directory 'TMPDIR' $ export -p TMPDIR=TMPDIR/ $ go run helloworld.go Hello World!
$ cat helloworld.go package main import "fmt" // This is a demonstrative comment! func main() { fmt.Println("Hello World!") }
$ gofmt helloworld.go package main import "fmt" // This is a demonstrative comment! func main() { fmt.Println("Hello World!") }
$ godoc fmt | head use 'godoc cmd/fmt' for documentation on the fmt command PACKAGE DOCUMENTATION package fmt import "fmt"
## The Go Programming Language - documentation in web server ! $ godoc -http=:8181
## Go uses static linking by default $ go build helloworld.go $ ls -l total 752 -rwxr-x--- 1 ebal ebal 1855827 Oct 14 23:07 helloworld -rw-r----- 1 ebal ebal 109 Oct 14 23:05 helloworld.go $ ./helloworld Hello World! $ file helloworld helloworld: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), statically linked, with debug_info, not stripped $ ldd helloworld not a dynamic executable $ strip helloworld $ ldd helloworld not a dynamic executable $ ls -l helloworld -rwxr-x--- 1 ebal ebal 1226248 Oct 14 23:14 helloworld ## From 1855827 ~~> 1226248 $ file helloworld helloworld: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), statically linked, stripped
## Variables GOROOT GOHOME GOBIN GOPATH
$ go help environment | head -5 The go command, and the tools it invokes, examine a few different environment variables. For many of these, you can see the default value of on your system by running 'go env NAME', where NAME is the name of the variable.
$ gofmt test.go package main import ( "fmt" "os" ) func main() { arguments := os.Args for i := 0; i < len(arguments); i++ { fmt.Println(arguments[i]) } } $ go run test.go 1 2 TMPDIR/go-build729121647/command-line-arguments/_obj/exe/test 1 2