Getting started
Basic types
Variables
Constants
Strings
Pointers
Arrays
Slices
Maps
Structs
Interfaces
Empty interface
if, switch, goto
for, while loops
range statement
Functions
Methods
Error handling
Defer
Panic and recover
Concurrency
Channels and select
Mutex
Packages
Files and I/O
Time and date
Command line arguments
Logging
Executing commands
Hex, base64 encoding
JSON
XML
CSV
YAML
SQL
HTTP Client
HTTP Server
Text and HTML templates
Reflection
Context
Package fmt
OS Signals
Testing
Calling C from GO with cgo
Profiling using go tool pprof
Cross compilation
Conditional compilation with build tags
Inlining functions
sync.Pool for better performance
gob
Plugin
HTTP server middleware
Protobuf in Go
Console I/O
Cryptography
Images (PNG, JPEG, BMP, TIFF, WEBP, VP8, GIF)
The Go Command
Testing code with CI services
Windows GUI programming
Contributors

Linux install and setup

suggest change

Install on Ubuntu

Using Ubuntu provided package

$ sudo apt-get update
$ sudo apt-get install golang-go

Packages provided by Ubuntu are often outdated. A new version of Go is released every 6 months but Ubuntu distribution moves at a slower pace.

Newer versions are often available via ppa:gophers/archive package repository:

$ sudo add-apt-repository ppa:gophers/archive
$ sudo apt-get update
$ sudo apt-get install golang-1.11-go

If those are still not recent enough, you can install binary parckages.

Using binary packages

These instructions work on most Linux distributions:

$ sudo apt-get update
$ sudo apt-get install -y build-essential git curl wget
$ wget https://storage.googleapis.com/golang/go<versions>.gz

You can find the version list here.

# To install go1.12.4 use
$ wget https://storage.googleapis.com/golang/go1.12.4.linux-amd64.tar.gz

# Untar the file
$ sudo tar -C /usr/local -xzf go1.12.4.linux-amd64.tar.gz
$ sudo chown -R $USER:$USER /usr/local/go
$ rm go1.12.4.linux-amd64.tar.gz

Setup on Linux

After installing the compiler you need to configure GOPATH environment variable.

Since Go 1.8, the GOPATH environment variable has the default value of $HOME/go, so you can skip setting it.

Create the go directory with mkdir $HOME/go.

Add the following two lines at the end of your ~/.bashrc file

export GOPATH=$HOME/go
export PATH=$GOPATH/bin:/usr/local/go/bin:$PATH
$ source ~/.bashrc

Test the setup by running go version.

You should understand the effect of GOPATH.

More resources:

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents