Install Go Language

Source: Internet
Author: User
Tags install go

Directory:

  • Preface
  • First Installation Method: Download the Binary Package
  • 1. Download [Go Binary Package] [2].
  • 2. Configuration:
  • 3. Detection:
  • Method 2: Use the gvm plug-in
  • 1. Install the [gvm] [3] plug-in:
  • 2. Install [go] [1] through [gvm] [3]:
  • 3. Detection:
  • Classic example:
  • 1. Code
  • 2. Run
Preface

I recently learned the Go language and recorded some processes. The first step is to install the Go environment.

First Installation Method: Download the Binary Package 1. Download the [Go Binary Package] [2].
# Pay Attention to the corresponding operating system and CPU architecture when downloading. aria2c 'https: // go.googlecode.com/files/go1.1.linux-386.tar.gz'unzip decompress tar zxvf go1.1.linux-386.tar.gz go
2. Configuration:
# Echo "export GOROOT = $ HOME/GO">. zshrc # GO third-party package installation path or project path echo "export GOPATH = $ HOME/workspace/go">. zshrc # Add PATHecho "export PATH = $ GOROOT/bin: $ GOPATH/bin: $ PATH" >>>. zshrc
3. Detection:
# Check whether go is available which go # view go version # view go environment variable go env
Method 2: Use the gvm plug-in. 1. Install the [gvm] [3] plug-in:
# Install bash <(curl-s https://raw.github.com/moovweb/gvm/master/binscripts/gvm-installer) # configure echo '[[-s "$ HOME /. gvm/scripts/gvm "] & source" $ HOME /. gvm/scripts/gvm "] '>. zshrc source. zshrc # gvm version Detection
2. Install [go] [1] through [gvm] [3]:
# List all supported versions of gvm listall # download the source code, compile and install go1.1gvm install go1.1 # list the installed gvm list # Use go1.1, which can be set as the default value (add the -- default parameter) gvm use go1.1 [-- default]
3. Detection:

See detection in the first method.

For more information, visit the official gvm website.

Classic example: 1. Code
# Hello. gopackage mainimport ("fmt") func main () {fmt. Printlf ("Hello, world! ")}
2. Run
# Run go run hello. go # compile and run go build hello. go./hello

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.