当前位置:网站首页>Fire! One day transferred to go engineer, not fire handstand sing Conquest (in serial)

Fire! One day transferred to go engineer, not fire handstand sing Conquest (in serial)

2022-07-06 14:23:00 BewaterMyfriends

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

Official website reference

# 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!

...

原网站

版权声明
本文为[BewaterMyfriends]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/02/202202131401145466.html