Lightning Go
Lightning Go
Ben Jones
12/06/2023 #golang 2
Language invented by:
12/06/2023 #golang 3
Rob Pike wrote books like…
12/06/2023 #golang 4
Ken Thompson wrote operating
systems like…
12/06/2023 #golang 5
All the cool new stuff is go...
12/06/2023 #golang 6
golang features
• Keep most of expressiveness of dynamic
languages, gain speed
• C-like, statically linked, garbage collected
• Fast compilation
• Nice build / compile tools
• A reaction to C++ but won converts from
python/ruby devs
12/06/2023 #golang 7
Nice dev environment
• go get libraries
$ go get github.com/mefellows/muxy
$ ls $GOPATH/src/github.com/mefellows/muxy
LICENSE README.md examples main.go
muxy scripts version.go Makefile
command log middleware protocol
symptom wercker.yml
12/06/2023 #golang 8
No unused stuff
http://tour.golang.org
http://play.golang.org
12/06/2023 #golang 9
Run everywhere
• X-Compile is trivial
$ GOOS=windows GOARCH=386 go build -o egroupexpand.exe
egroupexpand.go
$ ls -l
total 19344
-rwxr-xr-x 1 ben staff 5445348 Aug 27 10:33 egroupexpand
-rwxr-xr-x 1 ben staff 4449792 Sep 29 10:44
egroupexpand.exe
-rw-r--r-- 1 ben staff 3075 Aug 27 10:33 egroupexpand.go
12/06/2023 #golang 10
OO without loads of cruft
• types and values instead of classes and
objects
• methods on any user-defined type
• polymorphism with interfaces
• namespacing with exports
• no inheritance
• can extend types by embedding
12/06/2023 #golang 11
Concurrency
• concurrency not parallelism (though
GOMAXPROCS can help with latter)
• “Do not communicate by sharing memory;
instead share memory by communicating”
• Goroutines: function executing concurrently
with other goroutines in same address
space
• created by prefixing func or method call with “go”
• Channels - pipes that connect goroutines
12/06/2023 #golang 12
learning resources
• http://tour.golang.org
• https://golang.org/doc/effective_go.html
• https://golang-for-python-programmers.readt
hedocs.org/en/latest
/
• http://blog.golang.org/concurrency-is-not-
parallelism
• http://www.youtube.com/watch?v=
jgVhBThJdXc
• https://www.golang-book.com
12/06/2023 #golang 13