手动安装

下载golang安装包

https://studygolang.com/dl

从上面的网站上下载适合自己机器的go版本,我这里选择的是go1.10.linux-386.tar.gz

解压安装包到指定目录

sudo tar -zxvf go1.10.linux-386.tar.gz -C /opt

检查是否安装成功

./opt/go/bin/go version

环境变量的设置

vi /etc/profile

export GOPATH=/home/go
export GOROOT=/opt/go
export GOARCH=386
export GOOS=linux
export GOTOOLS=$GOROOT/pkg/tool
export PATH=$PATH:$GOROOT/bin:$GOPATH/bin

source /etc/profile

编写hello.go文件,测试安装是否成功

package main
import "fmt"
func main(){
	fmt.Println("hello,world!")
}

用go run命令直接运行hello.go

go run hello.go

用go build命令生成hello可执行文件

go build hello.go 

相关文章:

  • 2021-06-19
  • 2021-12-13
  • 2022-12-23
  • 2022-12-23
  • 2021-12-15
  • 2022-01-20
  • 2021-07-18
  • 2021-12-21
猜你喜欢
  • 2021-10-24
  • 2021-12-19
  • 2021-08-19
  • 2021-12-13
相关资源
相似解决方案