Difference between revisions for go





Next edit →

Version1 Version2 Differences
1   %%(html)
  1 **go** in **archlinux**
  2
  3 %%(html5)
  4
  5 $ sudo pacman -S go go-tools
  6
2 7
3 8 $ go version
4 9 go version go1.9.1 linux/amd64
… … …
10 15 import "fmt"
11 16 // This is a demonstrative comment!
12 17 func main() {
13      fmt.Println("Hello World!")
  18 fmt.Println("Hello World!")
14 19 }
15 20 EOF
16 21
  22 %%  
  23  
  24 %%  
17 25 $ go run helloworld.go
18 26 fork/exec /tmp/go-build127438955/command-line-arguments/_obj/exe/helloworld: permission denied
19 27
… … …
24 32
25 33 $ go run helloworld.go
26 34 Hello World!
27  
  35 %%
28 36
29 37 %%
  38  
  39 $ cat helloworld.go  
  40 package main  
  41 import "fmt"  
  42 // This is a demonstrative comment!  
  43 func main() {  
  44 fmt.Println("Hello World!")  
  45 }  
  46 %%  
  47  
  48 %%  
  49 $ gofmt helloworld.go  
  50 package main  
  51  
  52 import "fmt"  
  53  
  54 // This is a demonstrative comment!  
  55 func main() {  
  56     fmt.Println("Hello World!")  
  57 }  
  58  
  59 %%  
  60  
  61 %%  
  62  
  63 $ godoc fmt | head  
  64 use 'godoc cmd/fmt' for documentation on the fmt command  
  65  
  66 PACKAGE DOCUMENTATION  
  67  
  68 package fmt  
  69     import "fmt"  
  70  
  71 %%  
  72  
  73 %%  
  74 ## The Go Programming Language - documentation in web server !  
  75  
  76 $ godoc -http=:8181  
  77 %%  
  78  
  79 %%  
  80  
  81 ## Go uses static linking by default  
  82 $ go build helloworld.go  
  83  
  84 $ ls -l  
  85 total 752  
  86 -rwxr-x--- 1 ebal ebal 1855827 Oct 14 23:07 helloworld  
  87 -rw-r----- 1 ebal ebal 109 Oct 14 23:05 helloworld.go  
  88  
  89 $ ./helloworld  
  90 Hello World!  
  91  
  92 %%