Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.Sign up
The WaitGroup struct uses a field, state1, a byte array which length is 12 to assure WaitGroup.state() returns a 64-bit aligned pointer. There are 4 bytes wasted by using this trick.
the saving memory version:
Maybe, merging the two functions as one two-returns function is better.
btw, the trick used in WaitGroup here does indicate that compilers should guarantee the alignment of 64-bit words must be 4N. But I can't find the guarantee in Go specification. Other compilers may not enforce the 4N alignment guarantee. So this trick may make Go programs not portable.