Golang based on the current 1.9 version of the source code compilation upgrade to 1.10

Source: Internet
Author: User
This is a creation in Article, where the information may have evolved or changed.

First, causes

Golang out the latest version of 1.10, and just out of the vgo is also needed based on the latest version. In order to test the vgo, I need to upgrade my v1.9 to the v1.10 version.

The students who have installed Golang know that there are 2 kinds of installation methods used in Golang.

    • Install the official compiled package directly. For example, download go1.7.4.darwin-amd64.tar.gz
    • Compile and install based on the source code.

The following is a source-based compilation installation. Many of the online tutorials in the description of the source installation, are explained to be based on the 1.4.3 version, that is, a master version of Go, and then used to compile the latest version to install.

But, I'm going to say, but. When I first started using Golang, I was downloading the compilation package directly. The problem of the earlier version and the master version was directly bypassed. Want to upgrade this time, also do not want to download based on C written version. Therefore try to upgrade the installation directly using the current 1.9 version.

Second, upgrade operation

Current Environment Description:

    • System: Mac
    • Binary installation directory: ~/go1.9/

2.1 Download the source code

There is no download from Gitlhub. Because the download volume will be relatively large. This is directly downloaded from the official website.

#下载 go1.10 放在当前家目录cd # 因为一些国内的网站还没有最新的1.10的安装包,因此才考虑使用源码,# 但源码下载也需要FQ,如果你用代理,可以直接在命令行加上代理export https_proxy=YOUR_IP:YOUR_PORTwget wget https://dl.google.com/go/go1.10.src.tar.gz# 解压tar -zxvf go1.10.src.tar.gz

2.2 Installation

An environment variable goroot_bootstrap needs to be set before installation. That is, the binary directory that is used to specify the current Golang.

go env | egrep 'PATH|ROOT'GOPATH="/Users/song/jungleCode"GOROOT="/Users/song/go1.9"# set 环境变量GOROOT_BOOTSTRAP=/Users/song/go1.9/cd go1.10/src/time bash -x ./all.bash

When you start execution, you will primarily do the following:

    • Build-related toolchain toolchain.
    • Test the built-in package.
    • Run Runtime,sync, etc.
    • Check for competition (testing race detector)
    • Conducting API checks

Finally, complete the installation, after installing the binary in the current directory of the bin directory. Installation takes 1240 seconds. Later, the last 4 lines of log at the end of the installation.

# Installed Go for darwin/amd64 in /Users/song/go1.10# Installed commands in /Users/song/go1.10/bin# *** You need to add /Users/song/go1.10/bin to your PATH.# bash -x ./all.bash  1240.55s user 456.11s system 294% cpu 9:35.17 total

2.3 Setting up a new environment

As above, a new binary has been generated. You need to modify the Golang environment variable goroot.

vim ~/.zshrc# 将GOROOT的值由/Users/song/go1.9改变/Users/song/go1.10source ~/.zshrcgo version# go version go1.10 darwin/amd64

Done.

Finally, I can play vgo. 2 links are recommended.

https://zhuanlan.zhihu.com/p/33926171

https://zhuanlan.zhihu.com/p/33935373

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.