1. 安装GO

sudo apt-get install golang-go

2. 设置Go环境变量

打开终端,输入命令:

export GOROOT=$HOME/go
export PATH=$GOROOT/bin:$PATHU

3. 设置go代码目录

sudo mkdir Applications/go

4.  测试安装

完成安装后,新建一个文档来测试环境是否搭建成功:

Example helloWorld.go

package main
 
    import (
        "fmt"
         "runtime"
    )

    func main() {
        fmt.Println("Hellow World!", runtime.Version())
    }    

执行go run helloWorld.go, 应该会打印出:

或者go build helloWorld.go,将生成helloWorld.sh,./helloWorld也可以运行。

Hellow World! %!(EXTRA string=go1.6.2)

相关文章:

  • 2021-11-12
  • 2022-01-19
  • 2021-06-08
  • 2021-04-18
猜你喜欢
  • 2021-06-20
  • 2022-12-23
  • 2021-05-20
  • 2022-01-14
  • 2021-12-02
  • 2021-10-13
相关资源
相似解决方案