One day transfer Go The engineer
Go Official website
Go Official China mirror website
Go Chinese lovers website
The road to conquest
1、Go Development environment construction 2、HelloWorld
Go Development environment construction
# download go-archive
$ wget https://golang.google.cn/dl/go1.17.7.linux-amd64.tar.gz
# Extract the archive you downloaded into /usr/local, creating a Go tree in /usr/local/go
$ sudo rm -rf /usr/local/go && sudo tar -C /usr/local -xzf go1.17.7.linux-amd64.tar.gz
# To configure GO Related environment variables
$ export GOROOT=/usr/local/go # Source package path
$ export GOPATH=$HOME/go # Developer's Go Project path
$ export PATH=$PATH:$GOROOT/bin:$GOPATH/bin # Add the above path to PATH environment variable
# Verify that the installation was successful
$ go version
go version go1.17.7 linux/amd64
HelloWorld
$ mkdir -p $GOPATH/src/helloworld && cd $GOPATH/src/helloworld
$ vim helloworld.go
// helloworld
package main
import (
"fmt"
)
func main() {
fmt.Println("Hello World!")
}
$ go run helloworld.go
Hello World!
...