Skip to content

Latest commit

 

History

History
49 lines (39 loc) · 1.05 KB

go.md

File metadata and controls

49 lines (39 loc) · 1.05 KB

Go

  • C style with garbage collector
  • In case of sending in a function
    • If intention to modify then pass by reference - Mutation Function
    • if not pass by value
# install go
mkdir ~/go
export GOPATH = "$HOME/go"
echo $GOPATH

mkdir -p $GOPATH/src/github.com/repo_name
cd GOPATH/src/github.com/repo_name
git clone repo_name

go test folder_name/*.go

Code snippet

// Go code will not run with redundant import
// Remove imports and sort
goimports -w *.go

type Person struct {
name string
}

func (p *Person) Info() string {
   if p==nil { return "" }
}

var test *Person
// Here receiver treated as the first parameter
test.Info()
Info(test)

go test foo_test.go foo.go
go test server *.go
go run --race test.go 
go vet

References