Ubuntu 14.04 on Golang development environment configuration

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

Ubuntu 14.04 on Golang development environment configuration

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

This document records Ubuntu 14.04.1 64bit on Golang language development environment building.

Installing Golang

Download the latest stable version from the official download address:

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

To configure environment variables, use sudo vim /etc/profile and add the following:

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

Gopath is the development directory of Golang, which, according to the official documentation, requires a definite directory structure:

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 for Golang, and then adds the subdirectories under that directory to the bin PATH environment variable.

Installing Sublime

Installing Sublime Text 3

Sublime Text is a very beautiful editor, with a powerful plugin community support that can be configured as a lightweight IDE for various languages. Refer to the Askubuntu.com article by apt-get Installing the SUBLIME-TEXT3:

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

After installation, you can subl start Sublime Text 3 by running in the terminal

Install the package Control

Official Installation Documentation

Installing Gosublime

After you open Sublime Text, Ctrl + Shift + P enter it by opening the package Control plug-in, install and then search for Gosublime and install it.

Set font

Start Sublime, click Preferences -> Settings-User , add the following two sentences inside the curly braces and save the modified font to Courier New equal width font:

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

Sublime Text 3 font settings There is a need to pay attention to the place, refer to StackOverflow answer is good.

Installing Liteide

If the ide,liteide is a Golang integrated development environment for easy debugging or getting used to, it requires a dependent library of Qt 4.8. You can choose to compile the source code, or download the compiled version directly from SourceForge.net.

Environmental testing

Confirm the deployment of the development environment with a simple example, src build the project directory according to effective go recommended in the Gopath directory, and create a new source file Hello_world.go, and enter the following:

packagemainimport"fmt"funcmain(){    fmt.Println("hello world!")}

For a brief explanation, package management and JAVA are a bit like:

    • Use package keywords to define package names.
    • Use the import ingest fmt package.
    • Use func keywords to define functions.
    • The entry function of the program is a main function.
    • fmtthe function in the call Println prints the output.

Open the file in Sublime Text, start the Ctrl + B Console, type a go help look at the parameter description of the go compiler, and then enter the following command to run the example in an interpreted manner:

go run hello_world.go

OK, the environment configuration is complete.

Learning Resources

    • The Go programming Language
    • Go Language Introduction
    • Go by Example
    • Go Learning Notes
    • Organizing Go Code
    • Testing techniques
    • Go language Sharing
    • Go in Action Chinese version
    • The To Go
    • Tony Bai's Blog

--EOF--

    • Manage Flask and Nginx's development environment using Fig →
    • ←golang one of the language foundations: type, variable, constant

Disclaimer: This article uses the BY-NC-SA protocol to authorize. Reprint please specify transfer from: Ubuntu 14.04 on Golang development environment configuration

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.