Ubuntu under Golang Environment configuration

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

Install Go

    1. Can go to Golang China to download the go installation package
    2. Unpacking the installation packagetar -C /usr/local -xzf <安装包>
    3. Add environment variables ' export path= $PATH:/usr/local/go/bin to/etc/profile (full system installation) or. BASHRC (bash) or. ZSHRC (in zsh)
    4. Perform source .zshrc update changes

If you want to install to a specified location

    1. Change the second step to /usr/local what you want, for example$HOME/go
    2. Add environment Variables export GOROOT=$HOME/go andexport PATH=$PATH:$GOROOT/bin

Setting up the Go workspace

The go code must be placed in the working space. It is actually a directory that contains three subdirectories:

    1. The SRC directory contains the go source files, which are organized into packages (each directory corresponds to a package)
    2. Pkg Directory contains Package objects
    3. The bin directory contains executable commands

Add a workspace to an environment variableexport GOPATH=$HOME/gowork
Add the Bin directory to the environment variableexport PATH=$PATH:$GOPATH/bin

End of Go installation

Use

You write the source file of go to the SRC directory in the workspace

If you have a GitHub account, it should be github.com/user_name used as your source path, so it will be convenient to upload to GitHub, even if not upload, anyway, the source can be placed in the SRC directory anywhere

Configure sublime text as a development tool for go

Just install gosublime , then Preferences > package setting > gosublime > user setting add the following in:

{    "env": {        "GOPATH": "$HOME/go_work",        "GOROOT": "/usr/local/go"    }}
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.