Difference between revisions for go
|
← Previous edit |
Next edit → |
Additions:
$ godoc fmt | head
use 'godoc cmd/fmt' for documentation on the fmt command
PACKAGE DOCUMENTATION
package 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
$ file helloworld
helloworld: ELF 64-bit LSB executable, x86–64, version 1 (SYSV), statically linked, with debug_info, not stripped
$ ldd helloworld
$ ldd 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
import (
TMPDIR/go-build729121647/command-line-arguments/_obj/exe/test
1
2
use 'godoc cmd/fmt' for documentation on the fmt command
PACKAGE DOCUMENTATION
package fmt
import “fmt”
$ 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
$ 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
import (
“fmt”
“os”
)“os”
arguments := os.Args
for i := 0; i < len(arguments); i++ {
$ go run test.go 1 2 for i := 0; i < len(arguments); i++ {
- Println(arguments[i])
TMPDIR/go-build729121647/command-line-arguments/_obj/exe/test
1
2