3 June 2011
While the Go authors have been working hard at improving Go's standard library, the greater community has created a growing ecosystem of external libraries. In this post we look at some popular Go libraries and how they can be used.
Mgo (pronounced "mango") is a MongoDB database driver. MongoDB is a document-oriented database with a long list of features suitable for a broad range of uses. The mgo package provides a rich, idiomatic Go API for working with MongoDB, from basic operations such as inserting and updating records to the more advanced MapReduce and GridFS features. Mgo has a bunch of cool features including automated cluster discovery and result pre-fetching - see the mgo homepage for details and example code. For working with large data sets Go, MongoDB, and mgo are a powerful combination.
Authcookie is a web library for generating and verifying user authentication cookies. It allows web servers to hand out cryptographically secure tokens tied to a specific user that will expire after a specified time period. It has a simple API that makes it straightforward to add authentication to existing web applications. See the README file for details and example code.
Go-charset provides support for converting between Go's standard UTF-8 encoding and a variety of character sets. The go-charset package implements a translating io.Reader and io.Writer so you can wrap existing Readers and Writers (such as network connections or file descriptors), making it easy to communicate with systems that use other character encodings.
goinstall launchpad.net/mgo \ github.com/dchest/authcookie \ go-charset.googlecode.com/hg/charset \ github.com/madari/go-socket.io
Once goinstalled, the packages can be imported using those same paths:
import ( "launchpad.net/mgo" "github.com/dchest/authcookie" "go-charset.googlecode.com/hg/charset" "github.com/madari/go-socket.io" )
Also, as they are now a part of the local Go system, we can inspect their documentation with godoc:
godoc launchpad.net/mgo Database # see docs for Database type
Of course, this is just the tip of the iceberg; there are more great Go libraries listed on the package dashboard and many more to come.
- Go 2017 Survey Results
- Hello, 中国!
- Participate in the 2017 Go User Survey
- Eight years of Go
- Community Outreach Working Group
- Contribution Workshop
- Contributors Summit
- Toward Go 2
- Go 2016 Survey Results
- Participate in the 2016 Go User Survey and Company Questionnaire
- Go, Open Source, Community
- GopherChina Trip Report
- Four years of Go
- Get thee to a Go meetup
- Go turns three
- Organizing Go code
- Getting to know the Go community
- The Go Programming Language turns two
- The Go image/draw package
- The Go image package
- Third-party libraries: goprotobuf and beyond