Go

The latest language

Sunday, Feb 16, 2020

Getting Started

# macOS
brew install go
# Debian
apt install golang-go

Your First Program

Packages

Programs in go are made up of multiple packages, and will run starting from the code defined in the main package.

Vim Plugin

If you want to edit your Go projects in Vim, there’s a very healthy ecosystem to support you.

" Install the libraries needed for `vim-go`
:GoInstallBinaries
" Getting help
:help vim-go

I’ve included some useful commands below:

" Run the code in the current buffer
:GoRun

" Compile the code
:GoBuild

" Install the coe
:GoInstall

" Test the code
:GoTest

" Test a single function
:GoTestFunc

" See dependencies of the current package
:GoDeps

" See all source files in cwd
:GoFiles

" Rename an identifier
:GoRename

" Format the document according to the go style guide
:GoFmt

" Resolve all needed package imports & remove all unused packages
:GoImports

" Import the package `math` #study #rise&grind
:GoImport math

" Drop the package `math` #jk2cool4school
:GoDrop math

" Pull up documentation for the function `Printf` package `fmt`
:GoDoc fmt Printf