Skip to content

Instantly share code, notes, and snippets.

@vjeffrey
Last active August 28, 2017 17:07
Show Gist options
  • Save vjeffrey/bf59a966fce25f5036ee16ceea8d845b to your computer and use it in GitHub Desktop.
Save vjeffrey/bf59a966fce25f5036ee16ceea8d845b to your computer and use it in GitHub Desktop.
learning go

VJ Learns Go

Install Go: https://golang.org/doc/install?download=go1.8.3.darwin-amd64.pkg

Where does Go go? "The package installs the Go distribution to /usr/local/go."

$ which go
/usr/local/bin/go
$ go
[list of commands]
$ go version
go version go1.8.3 darwin/amd64

Test that Go was installed: https://golang.org/doc/install?download=go1.8.3.darwin-amd64.pkg#testing

$ mkdir go
$ echo $GOPATH
/Users/vjeffrey/go
$ echo $GOBIN
/Users/vjeffrey/go/bin
$ cd go
$ mkdir -p src/hello
$ cd src/hello
$ vi hello.go
package main

import "fmt"

func main() {
    fmt.Printf("hello, world\n")
}
$ go build
$ ./hello
hello, world

go install = install the binary in go/bin, go clean = remove the binary

Learn more about Go: https://golang.org/doc/code.html#Organization

$ go env GOPATH
/Users/vjeffrey/go

Add the workspace's bin subdirectory to your PATH:
$ export PATH=$PATH:$(go env GOPATH)/bin

Make sure the GOPATH var is set.
$ export GOPATH=$(go env GOPATH)

$ mkdir -p $GOPATH/src/github.com/vjeffrey

https://golang.org/doc/code.html#Library https://golang.org/doc/code.html#PackageNames https://golang.org/doc/code.html#Testing https://golang.org/doc/code.html#remote

A longer read: https://golang.org/doc/effective_go.html

$ go get golang.org/x/tour/gotour
$ cd go/bin
$ ./gotour

Tour will open in browser. Go through all of that.

Next Step: Text Adventure game with Go: https://gocodecloud.com/blog/2016/03/19/writing-a-text-adventure-game-in-go---part-1/

https://github.com/vjeffrey/playtime-with-golang

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment