Book Image

Go Cookbook

By : Aaron Torres
Book Image

Go Cookbook

By: Aaron Torres

Overview of this book

Go (a.k.a. Golang) is a statically-typed programming language first developed at Google. It is derived from C with additional features such as garbage collection, type safety, dynamic-typing capabilities, additional built-in types, and a large standard library. This book takes off where basic tutorials on the language leave off. You can immediately put into practice some of the more advanced concepts and libraries offered by the language while avoiding some of the common mistakes for new Go developers. The book covers basic type and error handling. It explores applications that interact with users, such as websites, command-line tools, or via the file system. It demonstrates how to handle advanced topics such as parallelism, distributed systems, and performance tuning. Lastly, it finishes with reactive and serverless programming in Go.
Table of Contents (14 chapters)

Vendoring and project layout

Vendoring Go applications is still a largely unresolved issue. There are discussions and plans to produce an official vendoring solution (https://github.com/golang/dep), but it's very early days and things are far from complete. For now, there are a number of alternative solutions. By default, you can place packages into a local vendor directory to use them instead of those in your GOPATH environment variable. This allows packages to pin on the version in their vendor directory and allows for reproducible builds without having to commit your entire GOPATH into version control. Most package managers take advantage of this. For this recipe, we'll explore the layout for a web application and how to manage its vendor dependencies with godep github.com/tools/godep, a popular tool for managing dependencies.

...