Linux (Ubuntu) Install go locale

Source: Internet
Author: User

The impulse to replace the notebook with the Linux Mint system, so share the experience of installing Golang under Linux

Installation

First, you can install the latest version of Go directly from the command line:

Apt Install Golang

Here the main introduction of manual installation process, first to download the latest installation package: Go download

Select the Linux version and after downloading, unzip to/usr/local:

Tar-c/usr/local-xzf go1.10.3.linux-amd64.tar.gz

Configuring Environment variables

Edit the/etc/profile file and add to the end:

 export PATH=$PATH:/usr/local/go/bin

After saving, use the command source Etc/profile to take effect.

After you install go, the default is to use $home/go as the working directory, or you can manually specify the directory, set Gopath to define the directory. To configure environment variables for the current user, edit. BASHRC or. Profile, add:

export GOPATH=$HOME/goexport PATH=$PATH:$GOPATH/bin

After the configuration is complete, enter go-version to view the installed version.

$ go  

Test

After the configuration, the test can compile the go file normally, first create the HelloWorld package and the corresponding go source file:

$ mkdir -p go/src/helloworld$ cd go/src/helloworld$ touch helloworld.go

Write code to the source file:

package mainimport "fmt"func main() {    fmt.Printf("hello, world\n")}

Then start compiling:

$ cd $HOME/go/src/helloworld$ go build

Permissions may appear at this time can ' t load Package:...permission denied
You need to add permissions to the directory:

chmod 755-r $HOME/go

The corresponding executable file is generated after the compilation is passed

$ cd $HOME/go/src/helloworld$ go build$ lshelloworld  helloworld.go$ ./helloworldhello, world

Compile through to be able to print normally.

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.