Configure Golang Development Environment on Ubuntu 14.04

Source: Internet
Author: User
Tags install go gocode

Configure Golang Development Environment on Ubuntu 14.04

Golang is a programming language launched by Google 10 years ago. Currently, the latest version 1.4 has officially started to support Android development, and Golang is also a Docker development language.

This document describes how to set up the Golang Language Development Environment on Ubuntu 14.04.1 64bit.

Install Golang

Download the latest stable version from the official website:

wget https://storage.googleapis.com/golang/go1.4.linux-amd64.tar.gzsudo tar -xzf go1.4.linux-amd64.tar.gz -C /usr/local

Configure environment variables and usesudo vim /etc/profileAnd add the following content:

GOPATH="/YOUR/USER/HOME/go"GOROOT="/usr/local/go"PATH=$GOROOT/bin:$PATH

GOPATH is the Development Directory of Golang. According to the instructions in the official documentation, a fixed directory structure is required:

GOPATH=/home/user/gocode/home/user/gocode/    src/        foo/            bar/               (go code in package bar)                x.go            quux/              (go code in package main)                y.go    bin/        quux                   (installed command)    pkg/        linux_amd64/            foo/                bar.a          (installed package object)

GOROOT is the installation directory of Golang, andbinAdd the PATH environment variable to the subdirectory.

Install Sublime

Install Sublime Text 3

Sublime Text is a beautiful editor with powerful plug-in community support and can be configured as a lightweight IDE in various languages. Refer to askUbuntu.com's article throughapt-getInstall sublime-text3:

sudo add-apt-repository ppa:webupd8team/sublime-text-3sudo apt-get updatesudo apt-get install sublime-text-installer

After installation, you can runsublStart Sublime Text 3

Install Package Control

Official installation documentation

Install GoSublime

After opening Sublime TextCtrl + Shift + POpen the Package Control plug-in and enterinstallAnd then searchGosublimeAnd install.

Set Font

Start Sublime and clickPreferences -> Settings-User, Add the following two sentences in curly braces and save the modified fontCourier NewSame Width Font:

"font_face": "Courier New","font_size": 10,

Note the font setting of Sublime Text 3. refer to the answer provided by StackOverflow.

Install LiteIDE

To facilitate debugging or get used to IDE, LiteIDE is Golang's integrated development environment, but requires the dependent libraries of Qt 4.8. You can select Source code compilation or directly download the compiled version from sourceforge.net.

Environment Test

Confirm the deployment of the development environment by using a simple example.srcCreate a project directory in the Directory recommended by objective go and create a new source file hello_world.go. Enter the following content:

package mainimport "fmt"func main(){    fmt.Println("hello world!")}

The package management is a bit like JAVA:

  • UsepackageKeyword defines the package name.
  • UseimportIntroductionfmtPackage.
  • UsefuncKeyword-defined functions.
  • The entry function of the program ismainFunction.
  • CallfmtInPrintlnFunction print output.

Open the file in Sublime Text and useCtrl + BStart the Console and entergo helpLet's take a look at the parameter description of the go compiler, and then enter the following command to run this example in interpreted mode:

go run hello_world.go

Now, Environment configuration is complete.

Getting started with Linux-installing Go in Linux

Install Go Language Pack in Ubuntu

Go language programming (HD) full-version ebook

Go language and beauty-surpassing "Hello World"

Why do I like the Go language?

Implementation of the Go language memory distributor

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.