《Go程序设计语言(英文版)》的原文摘录

  • 这个规则有一个例外:两个变量的类型不携带任何信息且是零值,例如 struct{} 或 [0]int,在当前的实现里面,它们有相同的地址。 (查看原文)
    天天不勇敢 2回复 2赞 2020-02-22 15:29:18
    —— 引自章节:2.3.3 new函数 25
  • 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. (查看原文)
    天天不勇敢 2回复 2赞 2020-02-22 15:29:18
    —— 引自章节:2.3.3 new函数 25
  • It is not a problem if the map doesn't yet contain that key (查看原文)
    jeff 2016-09-26 20:29:20
    —— 引自第9页
  • if the expression is omitted, the initial value is the zero value for this type (查看原文)
    jeff 2016-09-26 20:54:17
    —— 引自第30页
  • It perfectly safe for a function to return the address of a local variable (查看原文)
    jeff 2016-09-28 07:19:52
    —— 引自第32页
  • Any file may contain any number of functions whose declaration is just func init() {} (查看原文)
    jeff 2016-09-29 20:47:19
    —— 引自第44页
  • The type rune is an synonym for int32 (查看原文)
    jeff 2016-09-30 07:50:20
    —— 引自第52页
  • 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. (查看原文)
    jeff 2016-10-02 10:01:40
    —— 引自第78页
  • 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. (查看原文)
    jeff 2016-10-03 09:58:44
    —— 引自第107页
  • 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. (查看原文)
    jeff 2016-10-03 17:34:25
    —— 引自第146页
  • 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. (查看原文)
    jeff 2016-10-06 09:46:32
    —— 引自第219页
  • Where possible, use defer and let critical section s extend to the end of a function. (查看原文)
    jeff 2016-10-06 18:13:58
    —— 引自第264页
  • 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. (查看原文)
    jeff 2016-10-06 18:17:48
    —— 引自第265页
  • 其实在任何时候,你并不需为了编写正确的代码而要考虑变量的逃逸行为,要记住的是,逃逸的变量需要额外分配内存,同时对性能的优化可能会产生细微的影响。 (查看原文)
    随候鸟南飞 2019-02-26 06:36:34
    —— 引自章节:2.3 变量
  • Channel & Goroutines(The essence of Golang) (查看原文)
    Liagc 2019-04-20 21:47:54
    —— 引自第999页