1
Prepare your environment before you actually Write Code in Go. Consider the official documentation How to Write Go Code.
Go provides excellent tools to ensure the style and quality of your code, such as Gofmt, GoDoc, and Goimports. Learn to use them.
For starters, don’t rush to get a complete Go app. You should familiarize yourself with the basic semantics and features of Go and read the official Effictive Go
2
Don’t be afraid to make mistakes. Everyone is equal when it comes to a new language, and even people who have written programs in Go for a year or two will make some silly mistakes.
Learn to take advantage of the situation. Learn to write Go programs in Go conventions. For example, follow Go Conventions and don’t always use Pointers in Go as C does.
Beginners should take a look at this article http://talks.golang.org/2012/splash.article, it will help you to understand how to Go is born, what is the philosophy of it.
3
Newbies should not start out too focused on goroutines, channels, and other concepts that involve concurrency. You may abuse channels without knowing moderation, because Go is very restrictive in many ways.
Understanding interfaces, understanding their potential, and learning to create robust Go code with combinations and interfaces is one of Go’s most gifted capabilities.
If you have used other object-oriented languages, forget about OO features and thinking for a moment. Although Go supports OO, it is not a class-based language and does not support class inheritance.
4
Go is strongly typed, which means that implementing very complex system apis can use a lot of predefined types like Java or C++, making code brittle and ugly, which is not really Go. Go’s interface and closure features allow us to write more elegant and generic implementations.
To learn how to use closures effectively, you can learn some theories about functional programming languages, or learn Ruby. Check out The well-Grounded Rubyist and give it a try in Go programming.
Learn to test the Go program, learn to use the Go related testing tools unit testing, beachmarking testing, use the test to constantly correct and improve the quality of the Go program, Can take a look at this http://github.com/feyeleanor/GoSpeed.
5
Don’t force yourself to bring your past experience with other languages into Go, every language is different, and if you’re new to Go, give yourself a new perspective on it. Try to understand it from the perspective of the language’s creators and community.
Start with Go and avoid using the Third Party Library. They may simplify what you’re doing, but in the long run they hinder your understanding of the language.
Learn how to write better Go code from the standard library. For example, you can learn how to use Concurrency from the NET/HTTP package, or check out Rob Pike’s video on Concurrency.
6
Try composition instead of Inheritance. An OO based inheritance way of thinking can get in the way of writing elegant Go code.
Embrace interface.
Not all objects are objects.
A language that doesn’t affect the way you think about programming, If a language doesn’t affect how you think about programming, it’s not worth learning.
7
Keep the function short, keep the variable names short and don’t write Go like you would in any other language, Go is not Java, it’s not Python, it’s not Ruby. Take time to understand named and unnamed types. Learn to build complete Go projects and release them. Interfaces are very important, you should learn to use them, you can solve a lot of problems you have with interfaces. Learning to read source code is an excellent way to learn Go. Keep it simple. Simplicity is one of the key features of Go. Avoid over-engineering. Implement your code functionality in smaller units, and then combine them. summary
In this world there are many simple truth, a lot of people know, but the truth is not to know what brings change, such as diligence can not succeed, still a lot of people very hard, have a good luck also not necessarily can succeed, still a lot of people look forward to the henchman excrement luck everyday, the former is too hard, have no time to think, who don’t know the diligence, always disillusioned.
Language learning is the same, don’t worry about practice, to think about it, take a look, after reading can not be too lazy, but also to practice.