Go Quickstart

By pjain      Published July 29, 2019, 2:18 a.m. in blog Programming   

Quick Setup

  • install git, brew, vscode or atom
  • Install go from golang.org/dl.
  • Choose the latest version available for your OS eg go1.4.2.darwin-amd64-osx10.8.pkg) and run it and follow prompts
    • it typically installs go in /usr/local/go/
  • Create Workspace ~/Develop/go - default directory for home - contains the packages, environment, etc
    • I don't like the default ~/go location md ~/Develop/go
    • So you need to set GOPATH variable in your ~/.bash_profile to eg export GOPATH=/Users/xyz/Develop/go export PATH="/usr/local/go/bin:$PATH"

Build Go, Install or Remove from workstation

  • or build it then run it like an executable file $ cd ~/Develop/go/src/hello/ $ go build # creates a hello file -on OSX was for me - 2,120,520 bytes $ ./hello # outputs .. hello, world

  • To install a go command in workspace bin $ go install # to install the binary into your workspace's bin directory $ go clean -i #to remove it.

Go Try it on https://golang.org/


  • GREAT! https://play.golang.org/
  • https://repl.it/site/languages/go


$ go version
$ go help # lists commands
$ go run hello.go
$ godoc fmt Println

Get packages

go get golang.org/x/tour   # installs the tour go package binary in /go/bin

Go Examples Quickstart


  • Create following hello.go in your go workspace folder eg ~/Develop/go/src/hello/hello.go

    package main import {"fmt"} // this is a comment func main() { fmt.Println("Hello World") fmt.Println("1 + 1 =", 1 + 1) }

  • You can run it as a go file using go runtime $ go run hello.go # outputs .. hello, world


TODO Quickstart next

https://github.com/golang/go/wiki/Screencasts https://gobyexample.com/ https://golang.org/doc/effective_go.html http://go-book.appspot.com/


Quick start Resources


Writing Microservices in Go Part II - When Not to Use Go | Nordic APIs | Calling Go functions from LUA - Tit Petric Lua: Good, bad, and ugly parts - ZeroBrane go quickstart - Google Search Getting Started - The Go Programming Language Programming in Lua An Introduction to Programming in Go | Go Resources Arrays, Slices and Maps — An Introduction to Programming in Go | Go Resources go on mobile - Google Search golang/mobile: [mirror] Go on Mobile Mobile · golang/go Wiki iOS and Android Programming with Go — SitePoint gomobile - GoDoc gomobile reviews - Google Search shared object library in go - Google Search


There are no comments yet

Add new comment

Similar posts

Go Sample Full Apps

Go Reference, Cheatsheet

Go Setup Smarts

Go Concurrency 101