One.Go installation

Time:2020-3-26

1、 Go language features

  1. Concurrent, fast compiled language with garbage collection.
  2. Static type language, type system has no hierarchy, which is more lightweight than object-oriented language.
  3. Go for multi-core machines.

2、 Go installation mode

  1. Go source installation

    • Source installation requires gcc compiler.
***Xcode in MAC already contains;
   In Ubuntu system, sudo apt get install gcclibc6 dev is used to install and compile;
   You can install MinGW or cygwin to install GCC in Windows

*Go to the official website https://golang.google.cn/ to download the source code version.src.tar.gz and extract it to the $home directory
1. (linux)  cd go/src
   ./all.bash
   All test passed after running all.bash indicates that the installation is successful
2. (MAC) write the command to. Bashrc or. Zshrc
    export GOPATH=$HOME/gopath
    export PATH=$PATH:$HOME/go/bin:$GOPATH/bin
    Bash. Bashrc or bash. Zshrc
3. (Windows) set E: / go / bin; E: / gopath
  1. Go standard package installation

    • Window installation

​ export GOROOT=$HOME/go

​ export GOPATH=$HOME/gopath

​ export PATH=$PATH:$GOROOT/bin:$GOPATH/bin

View system information (Windows) systeminfo (Linux) uname – m or arch

    • Mac installation direct next step
    • linux tar zxvf go1.8.3.linux-amd64.tar.gz -C $GO_INSTALL_DIR

      Set path export path = $path: $go? Install? Dir / go / bin

    1. Third party tool installation

      GVM version management tool

        bash < <(curl -s -S -L https://raw.githubusercontent.com/moovweb/gvm/master/binscripts/gvm-installer)
    gvm install go1.8.3
    go use go1.8.3 --default

    Apt get installation go

    sudo apt-get install python-software-properties
    sudo add-apt-repository ppa:gophers/go
    sudo apt-get update
    sudo apt-get install golang-stable git-core mercurial

    ​ wget

    wget https://storage.googleapis.com/golang/go1.8.3.linux-amd64.tar.gz
    sudo tar -zxf go1.8.3.linux-amd64.tar.gz -C /usr/local
    export GOROOT=/usr/local/go
    export GOBIN=$GOROOT/bin
    export PATH=$PATH:$GOBIN
    export GOPATH=$HOME/gopath

    perhaps

    sudo vim /etc/profile

    export GOROOT=/usr/local/go
    export GOBIN=$GOROOT/bin
    export PATH=$PATH:$GOBIN
    export GOPATH=$HOME/gopath

    source /etc/profile

    Mac homeberw installation

    /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
    brew update && brew upgrade
    brew install go 
    brew install git
    brew install mercurial