Letter “g” – is generally often used as a shorthand to a phrase “(current) goroutine” – see: http://groups.google.com/group/golang-nuts/browse_thread/thread/3bdf4b609417939e/8ddea965ec294ad6#8ddea965ec294ad6.
Strictly related:
G
(struct G
) – is an internal C struct containing some data related to a goroutine – see: pkg/runtime/runtime.hg
(G g
) – is a thread-local variable of type struct G
; “g is usually the current goroutine, but it's real purpose is to be the definitive place to find the current stack bounds during the stack growth check at the beginning of most functions. (ref.)extern register
, and thus it must be declared in the same way in every C unit of compilation "in all modules and libraries". This is guaranteed if you #include “runtime.h”
.