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


$ gofmt 2.1.go 
package main

import (
	"fmt"
	"os"
	"strconv"
)

// the srtconv package for converting them into integers"

func main() {
	arguments := os.Args
	sum := 0
	for i := 1; i < len(arguments); i++ {
		temp, _ := strconv.Atoi(arguments[i])
		sum = sum + temp
	}
	fmt.Println("Sum:", sum)
}


$ go run 2.1.go 1 2 3 
Sum: 6