Mac system go upgrade 1.4 to 1.5.1

Source: Internet
Author: User
Tags install go
This is a creation in Article, where the information may have evolved or changed. Mac native is the first brew install go 1.3.3 version, this January through brew upgrade to version 1.4.
But the official update for brew is too slow to wait to manually upgrade to version 1.5.1.


1. Download go1.5.1.darwin-amd64.tar.gz from official website https://golang.org/dl/
Cd/users/wenke/documents/tools/go
Mv/users/wenke/downloads/go1.5.1.darwin-amd64.tar.gz./
Tar zxvf go1.5.1.darwin-amd64.tar.gz
Xattr-r-C Go
MV Go 1.5.1




2. Modify the Liteide configuration file:
Goroot=/usr/local/cellar/go/1.4/libexec
Become:
goroot=/users/wenke/documents/tools/go/1.5.1


3. Modifying a hard-link file
Go version
Go version go1.4 darwin/amd64


which go
/usr/local/bin/go


Cd/usr/local/bin
ll go*
Lrwxr-xr-x 1 root admin 1 go. /cellar/go/1.4/bin/go
Lrwxr-xr-x 1 root admin 1 gofmt. /cellar/go/1.4/bin/gofmt
RM Go
sudo ln-s/users/wenke/documents/tools/go/1.5.1/bin/go go
RM gofmt
sudo ln-s/users/wenke/documents/tools/go/1.5.1/bin/gofmt gofmt
ll go*
Lrwxr-xr-x 1 root Admin $13:50 go,/users/wenke/documents/tools/go/1.5.1/bin/go
Lrwxr-xr-x 1 root admin 13:50 gofmt-/users/wenke/documents/tools/go/1.5.1/bin/gofmt


Go version
Go version go1.5.1 darwin/amd64


4. Modifying environment variables
VI ~/.ZSHRC
Export goroot=/users/wenke/documents/tools/go/1.5.1
Export gobin= $GOROOT/bin
Export path= $PATH: $GOROOT/bin
Export Gopath=~/go
Export path= $PATH: $GOPATH/bin


source. ZSHRC


5. Delete the files generated by the old version compilation
RM-RF $GOPATH/pkg


TIP:
If you have finished upgrading, compile or run the old project error:
Go Build
Package Ysz
Imports Runtime:c source files not allowed when not using CGO or swig:atomic_amd64x.c defs.c float.c heapdump.c lfstack. C malloc.c mcache.c mcentral.c mem_darwin.c mfixalloc.c mgc0.c mheap.c msize.c os_darwin.c panic.c parfor.c proc.c Runtime . C signal.c signal_amd64x.c signal_unix.c stack.c string.c sys_x86.c
This is why the environment variable is not in effect. Only source. ZSHRC or new terminal can be solved!
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.