I’ve been using Python for a quite a few years as my main go-to language for building web apps, RESTful API’s, utilities, and much more. It’s the driving power for most of our backends at our startup: Blimp, Blimp Boards, and FilePreviews. I have very few bad things I could argue about Python, but I won’t.
I’ve recently felt the need to dig into newer programming languages and technologies. One of the languages I’ve been wanting to try out for a while now is Go. So I did, and here’s why and a couple of resources that helped me out. The first thing I did was read up about Go for a few days.
The Go programming language is an open source project to make programmers more productive.
Go is expressive, concise, clean, and efficient. Its concurrency mechanisms make it easy to write programs that get the most out of multicore and networked machines, while its novel type system enables flexible and modular program construction. Go compiles quickly to machine code yet has the convenience of garbage collection and the power of run-time reflection. It’s a fast, statically typed, compiled language that feels like a dynamically typed, interpreted language.
This perfectly describes Go.
- It’s pretty easy to understand for new developers, fast and with a good toolset for debugging and performance tuning.
- Statically typed and compiled you end up with fewer bugs
- Easy to profile for speed and memory leaks
- Built-in code formatting
- Small memory footprint
- Simple language design
- Natively multithreaded
- Built for and actively developed by Google
- And more…
A Tour of Go
A great resource to get started with Go is A Tour of Go. The interactive tour is divided into three sections: basic concepts, methods and interfaces, and concurrency, that can be compiled and ran right from the browser.
Go by Example
Go is a tool for managing Go source code. Available go commands are:
- build – compiles packages and dependencies
- clean – removes object files
- env – prints Go environment information
- fix – runs go tool fix on packages
- fmt – runs gofmt on package sources
- get – downloads and installs packages and dependencies
- install – compiles and installs packages and dependencies
- list – lists packages
- run – compiles and runs Go program
- test – tests packages
- tool – runs specified go tool
- version – prints Go version
- vet – runs go tool vet on packages
Godoc extracts and generates documentation for Go programs, it parses Go source code and produces documentation as HTML or plain text. After generating your docs you can use GoDoc to host it. You can read more in the Godoc: documenting Go code blog post.
With the go get command you can install remote packages directly from version control. One of the things you’ll notice when starting out with Go is that there isn’t a builtin package manager tool like we’d see with package managers like Bundler, Pip and NPM. There are third party tools for for managing Go packages and their dependencies. The Go project recommends vendoring, taking the 3rd party source code that is referenced in your project and making a copy of that code inside a new folder within the project.
Check out godep, a well-maintained tool for managing vendored dependencies. Some additional resources:
- List of Package Management Tools
- Go Package Management
- Go and Package Versioning
- Manage Dependencies with GODEP
There quite a couple of startups and organizations using Go that blog about or open source packages and tools. A couple of my favorites are:
- Official docs
- How to Write Go Code
- Effective Go
- Get Your Development Team Started With Go
- Go After 2 Years in Production at Iron.io
- Google Go: The Good, the Bad, and the Meh
- How to Convince Your Company to Go With Golang
Discovering projects and packages
Package discovery has been a pain for me. Since there’s no main index, packages can be hosted many different places. You’ll quickly notice that you won’t really need that many external packages, but when you do you’ll be searching around.
- Awesome Go – A curated list of awesome Go frameworks, libraries and software
- Projects – A list of Go projects
- Go Search – A search engine specifically designed for Go
- Go Walker – Displays API documentation for Go projects
- Sourcegraph – Shows you real examples of how functions and classes are used by other open-source projects.
I’m still learning the best way I know. I’ve already started a new project that I’ll be launching in a few weeks, developed a few packages in the way that I’ll be open sourcing soon.
What resources have you found useful while working with Go? Please share them in the comments below.
Mentioned resources by others.