博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
安装golang linux centos
阅读量:4203 次
发布时间:2019-05-26

本文共 1309 字,大约阅读时间需要 4 分钟。

Go的官方仓库地址:https://go.googlesource.com/go 
Go的github的仓库地址:https://github.com/golang/go 

Go的官网地址: https://golang.org 

参考文章:  

https://github.com/northbright/Notes/blob/master/Golang/china/install-go1.6-from-source-on-centos7-in-china.md 
https://golang.org/doc/install/source

高版本的编译过程需要Go1.4的二进制来实现引导(bootstrap),简单来说就是:  

Go需要Go自身来编译 

1.获取Go源码  

2.首先编译Go1.4(Go 1.4是C编写的Go工具链的最后一个分发版-官方文档写的。所以它的编译不需要Go编译器,用gcc和glibc-devel。)  
3.编译好的Go1.4二进制,来编译Go高版本

1.之前已经安装过老版本Go,清除相关环境变量:$GOPATH,$GOROOT  

2.安装git                     // 一般都有  
3.安装gcc和glibc-devel         // 一般都有  
4.下载go源码  

cd ~  git clone git@github.com:golang/go.git  cd go  git checkout -b 1.4.3 go1.4.3       // -b 1.4.3 不用也可以,它会创建一个新分支  cd src  ./all.bash      // 也可简单运行 './make.bash'
编译好的go 1.4.3 版本,默认存储在 ~/go      // 在我们执行完 './make.bash' 也有安装目录提示  
5.复制 ~/go 到 $GOROOT_BOOTSTRAP 指定的目录(高版本的Go的构建脚本,该变量值默认是:~/go1.4)  
cp -rf ~/go ~/go1.4
6.构建好 go 1.4低版本,我们现在可以开始安装高版本,它借助1.4.3版本的go  
cd ~/go  git clean -dfx      // 应该是恢复到最初开始,删除掉刚才构建生成的改变  git checkout -b 1.8 go1.8   // 我当前1.8是go的稳定版  cd src  ./all.bash
 
7.高版本安装成功,将Go相关目录,添加到环境变量中  
vim ~/.bashrc       // 我在mac上用的 zsh,vim ~/.zshrc  export PATH=$PATH:{$HOME}/go/bin  export GOPATH={$HOME}/go-projects  source ~/.bashrc    // source ~/.zshrc
简介:  
大多数用户,不需要从源码安装go,直接下载二进制包安装即可,非常简单。  
官方有两个Go编译器工具链。本文档重点介绍 gc Go编译器及其工具。gccgo编译器是一个更传统的的编译器,使用GCC作为后端。  
Go编译器支持8个指令集。 

转载地址:http://zpcli.baihongyu.com/

你可能感兴趣的文章
【一天一道LeetCode】#81. Search in Rotated Sorted Array II
查看>>
【数据结构与算法】深入浅出递归和迭代的通用转换思想
查看>>
【一天一道LeetCode】#83. Remove Duplicates from Sorted List
查看>>
【一天一道LeetCode】#91. Decode Ways
查看>>
【一天一道LeetCode】#92. Reverse Linked List II
查看>>
【一天一道LeetCode】#93. Restore IP Addresses
查看>>
【一天一道LeetCode】#94. Binary Tree Inorder Traversal
查看>>
【一天一道LeetCode】#113. Path Sum II
查看>>
【一天一道LeetCode】#114. Flatten Binary Tree to Linked List
查看>>
【unix网络编程第三版】阅读笔记(二):套接字编程简介
查看>>
【一天一道LeetCode】#115. Distinct Subsequences
查看>>
【一天一道LeetCode】#116. Populating Next Right Pointers in Each Node
查看>>
【一天一道LeetCode】#117. Populating Next Right Pointers in Each Node II
查看>>
【一天一道LeetCode】#118. Pascal's Triangle
查看>>
【一天一道LeetCode】#119. Pascal's Triangle II
查看>>
【unix网络编程第三版】ubuntu端口占用问题
查看>>
【一天一道LeetCode】#120. Triangle
查看>>
【unix网络编程第三版】阅读笔记(三):基本套接字编程
查看>>
【一天一道LeetCode】#121. Best Time to Buy and Sell Stock
查看>>
【一天一道LeetCode】#125. Valid Palindrome
查看>>