There is one exception to this rule: two variables whose type carries no information and is therefore of size zero, such as struct{} or [0]int, may, depending on the implementation, have the same address. (查看原文)
The compiler represents these uncommitted constants
with much greater numeric precision than values of basic types, and arithmetic on them is more precise than machine arithmetic; you may assume at least 256 bits of precision. (查看原文)
The answer has to do with methods. The shorthand notation used for selecting the fields of an embedded type woks for selecting its methods as well. In effect, the outer struct type gains not just the fields of the embedded type but its methods too. (查看原文)
Deferred functions run after return statements have updated the function’s result variables.
Because an anonymous function can access its enclosing function’s variables, including named results, a defer red anonymous function can observe the function’s results. (查看原文)
Other than by returning from main or exiting the program, there is no
programmatic way for one goroutine to stop another, but as we will see later, there are ways to communicate with a goroutine to request that it stop itself. (查看原文)
Deposit tries to acquire the mutex lock a second time by cal ling mu.Lock(), but because mutex locks are not re-entrant—it’s not possible to lock a mutex that’s already locked—this leads to a deadlock where nothing can proceed, and Withdraw blocks forever. (查看原文)