We now have all the information we need to write most Go programs. But it would be dangerous to conclude that therefore we are competent programmers. Programming is as much a craft as it is just having knowledge. This chapter will provide you with some suggestions about how best to master the craft of programming.
Part of becoming a good artist or writer is studying the works of the masters. It's no different with programming. One of the best ways to become a skilled programmer is to study the source code produced by others. Go is well suited to this task since the source code for the entire project is freely available.
For example we might take a look at the source code to the
io/ioutil library available at:
Read the code slowly and deliberately. Try to understand every line and read
the supplied comments. For example in the
there's a comment that says this:
// It's a good but not certain bet that FileInfo // will tell us exactly how much to read, so // let's try it but be prepared for the answer // to be wrong.
This method probably started out simpler than what it became so this is a great example of how programs can evolve after testing and why it's important to supply comments with those changes. All of the source code for all of the packages is available at:
One of the best ways to hone your skills is to practice coding. There are a lot of ways to do this: You could work on challenging programming problems from sites like Project Euler (http://projecteuler.net/) or try your hand at a larger project. Perhaps try to implement a web server or write a simple game.
Most real-world software projects are done in teams, therefore learning how to work in a team is crucial. If you can, find a friend – maybe a classmate – and team up on a project. Learn how to divide a project into pieces you can both work on simultaneously.
Another option is to work on an open source project. Find a 3rd party library, write some code (perhaps fix a bug), and submit it to the maintainer. Go has a growing community which can be reached via the mailing list (http://groups.google.com/group/golang-nuts).