Intro To GoLang
Who am I?
Software development lead at Smashwords
Geek, nerd, etc.
Book afficianado
Writing Go for about a year, but I have no special knowledge. I’m just a programmer who likes Go.
Starting a Go meetup in Davis!
Go History
Created by Robert Griesemer, Rob Pike, and Ken Thompson
Development began at Google in 2007.
Officially announced and become a public open source project in 2009.
Version 1.0 of Go was released March 28, 2012.
The most recent version, 1.3, was released June 18, 2014.
- Go 1.4 code freeze is September 1, 2014; release is December 1, 2014.
- Lately, there's a new minor version every 6 months.
Go in the Wild
It’s a real thing!
Google of course, with YouTube
Soundcloud, with over a dozen services and repositories in Go
Heroku with a distributed data store
Bitly, with queue consumers and other things
- At Smashwords, we use it for queue consumers, reporting, and will be using it for more things in the future.
Build Something With Go
Go is statically typed like C or C++.
Though it sometimes doesn’t look like it, that’s just syntactic sugar.
It is compiled, not a scripting language like Ruby or Python.
UTF-8 support is the default
The output of a go build is a statically linked binary.
Go can compile to binaries for Windows, OSX, and Linux, and this is built into the build system by default.
Method and field exportation is defined by capitalization.
Go Has a Built-In Toolchain
Run go {command} for...
build
compile packages and dependencies
install
compile and install packages and dependencies. "Installing" means to dump the outputs in the bin directory.
get
download and install packages and dependencies to your workspace as defined by your imports.
fmt
format your files sanely and without fuss.
test
test packages. This runs with the package in the source directory of the package, and puts the package under test in scope as if you were local to the package. By convention then, test data belongs in a testdata directory in the package directory.
vet
run go tool vet on packages to validate that you aren't doing stupid things that the compiler will let you do, but are probably dumb.
- and other things...
Oh, workspaces?!
Yes, go basically enforces a particular directory structure for any projects more than trivial.
project1/project2/
somedependency/
Go is Object-Oriented, Jim
No operator overloading
No method overloading
No subclassing
No constructors
No exceptions
Well, mostly...
No classes!
Which means it also has no generics :(
Instead We Get
Do we really need to learn another language?
If you:
Like cross platform languages
Like C, Java or Ruby or Python
Like languages that don’t run on a virtual machine
Like C, Ruby or Python
Like static typing
Like C
Like modern languages where you don’t have to manage your memory or deal with 25 years of language design crumped into one unholy core of terror (*cough C++ 11*)
...
Like fast languages
Well, then. Yeah.
Favorite Features
struct field annotations for trivial marshalling/unmarshalling
crazy magic with interfaces, e.g. structural typing which helps enable composition instead of inheritance.
- alright, yeah, super simple concurrency, though I won’t be talking about it today
Favorite Packages
net/http
Gorrilla Toolkit
io/ioutil
- bufio
Gotchas
Demo
A server that listens for requests to generate epubs for a given rss url.
Where to Go Next?
Take the interactive tour.
Read the Go FAQs.
Read Effective Go.
Fall in love with godoc.
- Make stuff!
Intro To GoLang
By Case Talbot
Intro To GoLang
- 4,402