No description, website, or topics provided.
Go
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
pkg/darwin_386/chapter11
src/chapter11
arrays.go
average.go
channels.go
cli.go
closure.go
crchash.go
ctof.go
doubleit.go
doublylinkedlist.go
elements.go
elementstates.go
evengen.go
factorial.go
filepath.go
files.go
fizzbuzz.go
goroutine.go
helloworld.go
httpserver.go
panicexample.go
pointers.go
readme.md
selectexample.go
shapes.go
smallestnumber.go
sorting.go
strings.go
swap.go
tcpserver.go
test.txt
test1.txt
test2.txt
testscores.go

readme.md

http://www.golang-book.com/

Notes

  • go run helloworld.go
  • short variable declaration (:=) serves as a declaration and initialization, staticly typed, short for var name string; name = "John"
  • panic and recover for exception handling
  • * pointer, followed by type, also used to dereference a pointer
  • new can be used to create a pointer
  • & find the address of a variable, &x returns a pointer to a type, e.g. *int
  • "anonymous fields"/"embedded types" can be used to achieve subclassing
  • compose functionality with Interfaces, Interface defines a method set (list of methods)
  • concurrency with goroutines and channels
  • channels c <- "ping" means send string "ping" to channel c
  • msg := <- c means receive message on channel c and assign it to msg
  • channels can be bi-directional, or only send, or only receive
  • select keyboard can be used like case statement with channels
  • normal channels are sychronous
  • buffered channel is asynchronous, sending or receiving does not wait unless the channel is already full
  • packages information, src and pkg directories are required, set GOPATH
  • importing a package, can create an alias
  • container/list package implements a doubly-linked list