Last Updated: 8/13/2024
The traditional “Hello World” example.
package main
import "fmt"
func main() {
fmt.Println("hello world")
}
Ran as:
go run hello-world.go
Compiled as:
go build hello-world.go
Both will produce the executable “hello-world”.
root@nodeb-01:~/test# ls -al
total 12980
drwxr-xr-x 2 root root 4096 Jul 27 14:36 .
drwx------ 12 root root 4096 Jul 27 14:36 ..
-rwxr-xr-x 1 root root 1758409 Jul 27 14:44 hello-world
-rw-r--r-- 1 root root 73 Jul 27 14:36 hello-world.go