It was in 2012 when I got in touch with GO, and it was in 2014 that I really began to systematically study and develop the system. The study of GO language was also one of my important work in 2014. The summary of go language learning was also one of the year-end summaries

1. Reasons and motivation for learning GO: 1> 2 years of Unix C development experience, I have special feelings for THE C language, GO is particularly suitable for my appetite, after using it, I can’t put it down; 2> The Go language team is too bright and powerful: Thompson Turing Award winner, co-inventor of Unix and C; Pike PLAN9 operating system principal developer and UTF-8 inventor; Robert Griesemer worked on HotSpot, JS V8 engine for Java; 3> Strongly recommended by domestic preachers: brother Xu Shiwei, Brother Xie Mengjun and other strong recommendation and related books published;

2. Learning materials: Books are: Go Programming by Lao Xu, Go Web Programming by Lao Xie, Go Learning Notes by Yuchen, Effective Go by Golang.org, The Go Programming Language Specification, the Go standard library, and numerous open source libraries on Github

3. Go learning experience: Go language basic knowledge is very simple, simple to a few days can be learned, and can get started development; But to achieve mastery, without a certain amount of code and several years of experience is difficult to achieve, this is learning any programming language must experience, the only thing you can do is: keep writing code, keep thinking, keep summarizing, keep reading other people’s code, ask the master;

4. Go learning difficulties, the difficulties I encountered in learning, and related resources index, a bit difficult for beginner learners to these knowledge, but for developers to fully grasp the go skills, I think is valuable, the knowledge is a personal learning step by step through the hole to discover after:

  • Go Map Slice String Array interface underlying data model, where array and slice are the source of confusion; See also: Very classic article by Russ Cox

Go Data Structures

Arrays, slices (and strings): The mechanics of ‘append’

  • Go defer Panic Recover is unique to GO. The errors of GO are errors and anomalies are anomalies. There is no confusion. Try catch is clear on the surface, but it hides too many problems. (Two error handling mechanisms: exception throwing mechanism – error code handling mechanism)

Use several scenarios from Defer

  • The underlying implementation mechanism of go Interface (can be in-depth into the source code) (in-depth to understand: interface assignment, interface conversion, interface assertion and GO dynamic); Go is an interface oriented, combinatorial programming language, for go interface is the soul of the language is not overstated;

See also: Lao Xu, Go Language programming, chapter 9, section 9.5 interface mechanism

How to Use interfaces in Go

See also: interfaces_and_types

See also: Learning go-interfaces & Reflections

  • Go type system: This is very important for mastering a language: static type(the language level is statically typed language), dynamic Type (dynamic type for interfaces),underly type(undertype for casts and assignments); Go’s type system is concise and clean. It is all value types. Even slice, Map,channel,func, etc., which look like reference types, are actually value types, but their internal data structures encapsulate Pointers. Unlike JAVA, there are two sets of types: the basic is the value type, the object is the reference type, and the middle has boxing, unboxing action, more strange string;

See also: The Go Programming Language Specification-type

See also: Learning go-types

  • Go function: return multiple values; Named return parameter usage; Closure; The function is first-class citizen; Higher order function; Function is also a basic type. You can define a new type for a function by type XXX func. Concurrent GO takes H function as the carrier. Objects are data with behavior attached, while closures are behavior with data attached

Function Types in Go (golang)

The Go language (Golang) – Closures

Go Functional programming: Go functional programming practices

  • Pass the go parameter: all function parameters are passed values: even if a pointer is passed, it is passed a copy of the pointer; Closure references external variables are references


Pointer: *a is passed inside the function as an argument. Inside the function, the value of *a is changed.

See also: References and references to the Go language This article is rarely a good one because it is very well analyzed

  • Go error handling mechanism,error and nil, see

Nil values and nil of type error in Go

How to customize an error to return a more specific error.

Error Handling In Go, Part I

Error Handling In Go, Part II

  • Go Nil has also been a stumbling block for GO learners

There’s an error Nil article up there

Golang: My brother Chen’s articles on go are very down-to-earth. I suggest you read them all

  • Go Package, global const(constant), var (variable) loading order, and package reference mechanism:


  • Go Reflect: Reflection is a powerful weapon, something a novice must dabble in to become an expert, and a way of metaprogramming that is relatively low in performance (flexibility also brings performance issues)

See also: official laws-of-Reflection

I think this is The best article translated, which integrates The author’s thinking and comprehension

There is also my abbreviated version, which is more of an API guide: The Laws of Reflection

Reflection tips: Refer to this translation of calling function Mikespook by name in GOLANG, which is also great

Martini framework uses the classic DI library: Inject textbook do implement injection

Inject library code is very obscure, you can refer to Brother Chen’s classic article Golang: Martini inject source code analysis this article is simple in depth, write very well

Reflection is very closely related to interfaces, go type systems, Refelct.TypeOf returns the dynamic type of the interface, func (v Value) type () type returns the type of the Value, and reflect.Type specifies the underlying type

  • Use of Go Channel and Gorutone; Concurrent programming mode; If describe go language is a crown, Goroutine and channel are the pearl on the crown, GO is CSB concurrent programming theory practitioners and reformists; Go reduces the complexity of concurrent programming by an order of magnitude, so that concurrent programming is no longer the preserve of some self-proclaimed “technology geek”; The world should be so simple that you don’t have to mess around with programmers when languages and compilers can do it well.

Related references:

See Go Concurrent Programming (to be honest, it’s not as good as I’d hoped, it’s basic, it’s a little wordy, it digs deep enough, but it doesn’t go far enough, it doesn’t systematically introduce concurrent design patterns)

See the systems behind Goroutine

The English version and Chinese version of GO memory model need to climb over the wall, which is a little difficult to understand. The Chinese one is very well written and integrated into the translator’s own thinking, which is recommended to read.

The beauty of Concurrency in THE GO language is well written and provides an in-depth look at common concurrency patterns, which is disappointing and somewhat empty in a very thick book called Concurrent Programming in Go

Some of the top posts at Google IO (with walls)

Concurrency is not Parallelism

Go Concurrency Patterns

Advanced Go Concurrency Patterns

Go Concurrency Patterns: Pipelines and explicit Cancellation

  • Go scheduler model, GO memory management, GC, GO debugging and performance analysis, cross-platform; These are advanced propositions. When a program encounters performance problems, you may need to understand the implementation mechanism of GO concurrency, find the problem, avoid or improve, or find an alternative; Unless you have a strong curiosity, the average programmer will not read the entire runtime implementation.

See Rain Marks study Notes

The Go Scheduler scheduler

Ali Skoo wrote several articles about the scheduler process very vividly

“Go Concurrent Programming” also discusses GO scheduling

The PPT written abroad is also good, there is another

Github has a very in-depth electronic writing, in-depth analysis of several key implementation of GO, very good article

5. Frame learning:

Learned xie Da beego framework, Beego is very easy to start, modular design, and module is very complete; Xie is more enthusiastic, and the QQ group is more active. My two small systems are developed based on Beego. Xiao Hei’s guide for those who want to see the framework source code is a Gospel;

Martini just looked at the Inject part and hopes to have a closer look at Martini and Revel in 2015.

6. Looking forward to

I hope someone will write a book on how to design large systems with GO. The GO language design pattern is very different from the object-oriented design pattern. Lao Xu has a PPT that introduces the connection-oriented and combination-oriented language of GO. With the scale of Qiniu system, it should be able to abstract a set of patterns. Has anyone done it? Concurrent related design patterns, many articles on the web, but not very systematic; Hopefully, 2015 will see someone step up and do this so that we can stand on the shoulders of giants and move forward.

It’s not really learning for learning’s sake: I spend most of my time developing and learning as I go through the library; If you encounter a large generic module, go to Github to find whether it has been implemented, if there is a reference, if you think your rewrite is better than the original author, you can pull request. Of course, in the development of their own knowledge of the blind spot, you need to share the spirit of research, understand it, technology will naturally improve, personal thinness, careful reference.


http://www.laktek.com/2012/01/27/learning-go-types/