Golang Basic 1 – Install && Hello World
What is Golang
- Official website: https://golang.org/
- Go is an open source programming language that makes it easy to build simple, reliable, and efficient software.
How to install
- Download link: https://golang.org/dl/
- Build from source code: Installing Go from source
- Windows installer: https://golang.org/dl/
- Ubuntu apt:
add-apt-repository ppa:longsleep/golang-backports
apt update
apt install golang-go -y
Comments
- 3 way to write a comments in go program.
-
// this is a single line comment -
/* this is a multi line comment */
Hello World
usr@host:go/ # cat hello.go
package main // if you want to run this program
import "fmt" // import some build in packages, fmt is a packag e for print something on the screen
func main(){ // the main function, the entry of the program
fmt.Println("Hello world.!") // call fmt.Println to print something on the screen
}
usr@host:go/ # go build hello.go # build the program
usr@host:go/ # ./hello # run it
Hello world.!