1. 程式人生 > >CentOS 32 bit安裝golang 1.7

CentOS 32 bit安裝golang 1.7

原文:http://studygolang.com/wr?u=http%3a%2f%2fblog.csdn.net%2fzgljl2012%2farticle%2fdetails%2f53183931

這裡下載相應的包

下載命令:

wget https://storage.googleapis.com/golang/go1.7.3.linux-386.tar.gz
  • 1
  • 1

下載後解壓縮:

tar -zxvf go1.7.3.linux-386.tar.gz
  • 1
  • 1

然後將golang放到指定的資料夾,我是放在/opt/go

mv go /opt/go
  • 1
  • 1

設定環境變數GOROOT

export GOROOT=/opt/go
  • 1
  • 1

在系統bin目錄下新增go程式的連結:

ln -s /opt/go/bin/go /bin/go
  • 1
  • 1

到此,就可以執行go了

go version
  • 1
  • 1

出現版本資訊即安裝成功。

centos7 64位安裝方法

原文:http://studygolang.com/articles/8560

環境(個人阿里雲主機):

# hostnamectl
   Static hostname: iZ23nwzgx3sZ
         Icon name: computer-vm
           Chassis: vm
        Machine ID: 45461f76679f48ee96e95da6cc798cc8
           Boot ID: 4022018209e04363871ed0279a30c225
    Virtualization: xen
  Operating System: CentOS Linux 7 (Core)
       CPE OS Name: cpe:/o:centos:centos:7
            Kernel: Linux 3.10.0-229.11.1.el7.x86_64
      Architecture: x86-64
# lsb_release -a
LSB Version:    :core-4.1-amd64:core-4.1-noarch
Distributor ID: CentOS
Description:    CentOS Linux release 7.2.1511 (Core) 
Release:        7.2.1511
Codename:       Core

到官方https://golang.org/dl/下載安裝包
</pre><pre name="code" class="plain">#wget https://storage.googleapis.com/golang/go1.7.1.linux-amd64.tar.gz

# tar zxvf go1.7.1.linux-amd64.tar.gz -C /usr/local

新建GOPATH目錄
# mkdir -p /mnt/wwwroot/gofile
# vim /etc/profile

export GOROOT=/usr/local/go
export GOBIN=$GOROOT/bin
export PATH=$PATH:$GOBIN
export GOPATH=/mnt/wwwroot/gofile
:wq儲存

使其生效
#source /etc/profile

檢視是否配置成功
# go version
go version go1.7.1 linux/amd64

簡單測試:
# cd /mnt/wwwroot/gofile
# vim hello.go
package main
import "fmt"
func main() {
    fmt.Println("Hello, 世界")
}
# go run hello.go
Hello, 世界