游戏网站模板源码,wordpress维基,北京商场购物中心,做外围网站代理违法吗Go 语言诞生5周年#xff01;友情提示#xff1a;本文使用Markdown编写#xff0c;黑色背景文字可能需要横向拖动才能看清全文最近为了做Hyperledger Fabric国密改造#xff0c;涉及到了golang源码的改动。特将操作过程整理如下#xff0c;以供参考#xff1a;golang的源…Go 语言诞生5周年友情提示本文使用Markdown编写黑色背景文字可能需要横向拖动才能看清全文最近为了做Hyperledger Fabric国密改造涉及到了golang源码的改动。特将操作过程整理如下以供参考golang的源码安装其实比较简单只需运行源码包中的脚本src/all.bash等到出现类似以下字样就安装好了Installed Go for linux/amd64 in xxx(目录地址)Installed commands in xxx(目录地址)但是在源码安装1.5版本以上的go时会报以下的错误 :##### Building Go bootstrap tool.cmd/distERROR: Cannot find /home/fabric/go1.4/bin/go.Set $GOROOT_BOOTSTRAP to a working Go tree Go 1.4.这是由于go 1.5版以后的编译安装需要1.4版本go所以如果想要通过源码方式安装高版本go必须先安装好1.4版本的go。让我们开始操作吧为了方便修改调试可以fork官方的仓库(https://github.com/golang/go.git)然后拉取自己仓库中的代码例如我的用户名是MangoDowner第一步、安装golang 1.4主要操作如下为了方便操作我们切换到root用户fabricfabric-VirtualBox:~$ su root为了方便统一管理将golang源码放入GOPATH中rootfabric:~# export GOPATH/opt/gopathrootfabric:~# cd $GOPATH/src/github.com/MangoDowner/rootfabric:/opt/gopath/src/github.com/MangoDowner# git clone https://github.com/MangoDowner/go.gitCloning into go...remote: Counting objects: 322777, done.remote: Compressing objects: 100% (73/73), done.remote: Total 322777 (delta 32), reused 54 (delta 28), pack-reused 322675Receiving objects: 100% (322777/322777), 147.71 MiB | 3.49 MiB/s, done.Resolving deltas: 100% (255582/255582), done.友情提醒下虽然可能有点啰嗦但是MangoDowner/go这个仓库其实是不存在的我自己改的源码放在了MangoDowner/go-gm下这里只是为了方便举例子...切换为go 1.4分支rootfabric:/opt/gopath/src/github.com/MangoDowner# cd gorootfabric:/opt/gopath/src/github.com/MangoDowner/go# git checkout release-branch.go1.4Branch release-branch.go1.4 set up to track remote branch release-branch.go1.4 from origin.Switched to a new branch release-branch.go1.4进入src目录并运行all.bash 安装脚本稍等片刻即可安装成功rootfabric:/opt/gopath/src/github.com/MangoDowner/go# cd srcrootfabric:/opt/gopath/src/github.com/MangoDowner/go/src# ./make.bash# Building C bootstrap tool.cmd/dist# Building compilers and Go bootstrap tool for host, linux/amd64.lib9libbioliblinkcmd/cccmd/gccmd/6l....# Checking API compatibility.Skipping cmd/api checksreal 0m0.538suser 0m0.310ssys 0m0.191sALL TESTS PASSED---Installed Go for linux/amd64 in /root/software/goInstalled commands in /root/software/go/bin*** You need to add /root/software/go/bin to your PATH.如果遇到报错cannot load DWARF output from $WORK/os/user/_obj//_cgo_.o: decoding dwarf section info at offset 0x4: unsupported version 0需要关闭cgo支持重新编译rootfabric:/opt/gopath/src/github.com/MangoDowner/go/src# export CGO_ENABLED0rootfabric:/opt/gopath/src/github.com/MangoDowner/go/src# ./make.bash最后我们将编译好的go 1.4复制到/usr/local下方便以后使用rootfabric:/opt/gopath/src/github.com/MangoDowner/go/src# cp -rp ../../go /usr/local/go1.4这样你就能得到1.4版本的go了。第二步、安装golang 1.9主要操作如下我们需要编译好的golang环境支持c语言的文件所以需要开启cgorootfabric:/opt/gopath/src/github.com/MangoDowner/go/src# export CGO_ENABLED1我们需要指定由go 1.4进行编译所以得设置以下环境变量rootfabric:/opt/gopath/src/github.com/MangoDowner/go/src# export GOROOT_BOOTSTRAP/usr/local/go1.4这里就用到了前面复制得到的go 1.4目录回到go源码根目录,并切换分支至1.9rootfabric:/opt/gopath/src/github.com/MangoDowner/go/src# cd ../rootfabric:/opt/gopath/src/github.com/MangoDowner/go# git checkout release-branch.go1.9Branch release-branch.go1.9 set up to track remote branch release-branch.go1.9 from origin.Switched to a new branch release-branch.go1.9下面的过程就和编译go1.4很类似不再赘述rootfabric:/opt/gopath/src/github.com/MangoDowner/go# cd srcrootfabric:/opt/gopath/src/github.com/MangoDowner/go# ./make.bash...最后将编译好的go 1.9复制到/usr/local下作为默认的golang标准库目录rootfabric:/opt/gopath/src/github.com/MangoDowner/go/src# cp -rp ../../go /usr/local/go结语上述操作结束之后当然还是要设置GOROOT之类的环境变量才可以这样的文章很多不再赘述。而且相信都能改golang源码的你这些已经不在话下了。