Skip to content

Latest commit

 

History

History

go

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 

GO

Install Go

If you are upgrading from an older version of Go you must first remove the existing version. To remove an existing Go installation from your system delete the go directory.

# Linux & Mac
$ sudo rm -rf /usr/local/go

# Windows
Delete c:\Go

To install Go, run the following command:

$ go_version=1.24.1
$ cd ~/Downloads
$ sudo apt-get update
$ sudo apt-get install -y build-essential git curl wget
$ wget https://go.dev/dl/go${go_version}.linux-amd64.tar.gz
$ sudo tar -C /usr/local -xzf go${go_version}.linux-amd64.tar.gz
$ sudo chown -R $(id -u):$(id -g) /usr/local/go
$ rm go${go_version}.linux-amd64.tar.gz

Add go to your $PATH variable

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

Troubleshoot Go

Install Intellij GoLand IDE

Learn Go

Learn Go Nuances

Read these books / articles / web pages in order:

If you just want a quick refresh of the syntax, the following link is very handy: A Tour of Go

Flag Library

Cli Library

Dependency management

$ export GO111MODULE=on

Error handling & Reporting

OOP Concepts in Go

Interfaces in GO

Reflection

Mixin

Mutexes

Concurrency

Go Style guide

$ go get -u github.com/golang/lint/golint
$ golint <file>.go
  • go vet examines Go source code and reports suspicious constructs. See how to use it here.
  • Command goimports updates your Go import lines, adding missing ones and removing unreferenced ones.

https://godoc.org/golang.org/x/tools/cmd/goimports

Documenting Go Code

HTTP Basic

GO net/http

Tracing HTTP Connections

// By default, Transport caches connections for future re-use.
// This may leave many open connections when accessing many hosts.
// This behavior can be managed using Transport's CloseIdleConnections method
// and the MaxIdleConnsPerHost and DisableKeepAlives fields.
//
// Transports should be reused instead of created as needed.
// Transports are safe for concurrent use by multiple goroutines.

JSON

YAML

GO Template Engine

GO INI Lib

https://github.com/go-ini/ini

JSON Query Lib

https://github.com/jmespath/go-jmespath

GO Debugger

https://github.com/davecgh/go-spew

Testing time-sensitive code

https://github.com/jmhodges/clock

Where you'd use time.Now, instead use clk.Now where clk is an instance of Clock. When running your code in production, pass it a Clock given by Default() and when you're running it in your tests, pass it an instance of Clock from NewFake().

Clock Utility Methods: https://github.com/jinzhu/now

Unit Testing Library

Mocks

HTTP Testing

BDD Testing

HTTP Load testing tool

GO Profiling and Application Performance

It will show how pprof can be used to analyze both CPU and heap profile as well as demonstrate how to use go-torch to build Flamegraphs. This process makes it easier to identify hotspots in your service and gives you a better understanding of where time is spent.

Get Password from Terminal Without showing Password

Plugins in Go

Best Practices