The Go Programming Language

The Go Programming Language

 The Go Programming Language|200

  • 作者: Brian W. Kernighan
  • 简介:
  • 出版时间:
  • ISBN:
  • 分类:
  • 出版社: Addison-Wesley Professional
  • 字数: 0
  • 在线阅读: 微信读书
  • 划线数量: 62
  • 想法数量: 39

笔记

The Origins of Go


📌 beget
💭 beget | BrE bɪˈɡɛt, AmE bəˈɡɛt |
① archaic (father) 成为…之父
▸ they hoped that the king might beget an heir by his new queen
他们希望国王新娶的王后可以为他生一位继承人
② literary (bring about) 引起
▸ violence begets more violence
暴力招致暴力

  • ⏱ 2024-01-29 14:26:35 ^19836794-7OA3CsHdq


📌 offspring
💭 offspring | BrE ˈɒfsprɪŋ, AmE ˈɔfˌsprɪŋ,ˈɑfˌsprɪŋ |
noun plural offspring
(of animal) 幼仔; (of human) 子女

  • ⏱ 2024-01-29 14:26:57 ^19836794-7OA3DYGgK


📌 incorporate
💭 incorporate | BrE ɪnˈkɔːpəreɪt, AmE ɪnˈkɔrpəˌreɪt |
transitive verb
① (include) 纳入 ‹thoughts, suggestions›; 收录 ‹revision, feature›
② Business, Law 合并 ‹business, company›

  • ⏱ 2024-01-29 14:27:34 ^19836794-7OA3GuUmN

📌 communicating sequential processes (CSP)

  • ⏱ 2024-01-17 01:00:58 ^3-3339-3386

📌 In CSP, a program is a parallel composition of processes that have no shared state; the processes communicate and synchronize using channels.

  • ⏱ 2024-01-17 13:10:41 ^3-3505-3646


📌 reminiscent
💭 reminiscent | BrE ˌrɛmɪˈnɪsnt, AmE ˌrɛməˈnɪs(ə)nt |
adjective
① (absorbed in memories) 怀旧的 ‹mood, smile›
② predicative (suggestive) 引人联想的
▸ to be reminiscent of sth/sb;
让人联想到某事物/某人
▸ his style is vaguely reminiscent of Matisse
他的风格隐约使人联想起马蒂斯

  • ⏱ 2024-01-15 12:17:05 ^19836794-7OeCO0jkq

The Go Project


📌 frustration
💭 frustration | BrE frʌˈstreɪʃn, AmE frəˈstreɪʃ(ə)n |
noun
① uncountable (irritated feeling) 失望
▸ to suffer from frustration
感到失望
▸ frustration at or with sth;
对某事感到的失望
▸ to vent one’s frustration (on sb/sth);
(在某人/某物身上)出气
② countable (irritating thing) 令人沮丧的事物
▸ the frustrations of doing sth;
做某事的不如意
③ (of attempt, effort) 沮丧
④ uncountable (in job, role) 不满意
⑤ uncountable (of plans, ambition) 受挫
▸ the frustration of sb’s hopes
某人希望的落空
⑥ (sexual) 性方面的不满足

  • ⏱ 2024-01-15 15:35:02 ^19836794-7OePLP3T2

📌 As Rob Pike put it, “complexity is multiplicative”: fixing a problem by making one part of the system more complex slowly but surely adds complexity to other parts. With constant pressure to add features and options and configurations, and to ship code quickly, it’s easy to neglect simplicity, even though in the long run simplicity is the key to good software.

  • ⏱ 2024-01-15 15:42:14 ^4-1393-1778


📌 pernicious
💭 pernicious | BrE pəˈnɪʃəs, AmE pərˈnɪʃəs |
adjective
有害的
▸ a pernicious lie
恶毒的谎言
▸ a pernicious disease
恶疾
▸ to be pernicious to sth;
对某事物有害

  • ⏱ 2024-01-15 15:43:11 ^19836794-7OeQiWm10


📌 accommodated
💭 accommodate | BrE əˈkɒmədeɪt, AmE əˈkɑməˌdeɪt |
A.transitive verb
① (provide space for) 为…提供住宿 ‹guests›; 容纳 ‹passengers›
▸ how many cars will the car park accommodate?
这个停车场能停多少辆车?
▸ the site can accommodate 10 factories
这个地方能建10座工厂
② (adapt to) 适应
③ formal (meet request of) 为…提供便利 ‹client›; 关照 ‹interests›
▸ I think I can accommodate you
我想我可以为你提供方便
B.to accommodate oneself reflexive verb
▸ to accommodate oneself to sb/sth;
使自己适应某人/某事物
▸ it took a long time for me to accommodate myself to the notion
我花了很长时间才接受了这个观念

  • ⏱ 2024-01-15 15:44:35 ^19836794-7OeQoAVnc


📌 compromising
💭 compromise | BrE ˈkɒmprəmʌɪz, AmE ˈkɑmprəˌmaɪz |
A.noun
① countable (settlement) 妥协
▸ to make or reach or come to a compromise
达成妥协
▸ to agree to a compromise
同意达成妥协
▸ he was the compromise candidate, not anybody’s first choice
他是个折中的候选人,并不是任何人的首选
▸ a compromise plan/proposal
折中计划/提议
② uncountable (willingness to settle) 妥协态度
B.intransitive verb
妥协
▸ to compromise on sth;
在某事上作出让步
C.transitive verb
① (threaten) 危及
▸ she was much compromised by the gossip surrounding her divorce
关于她离婚的闲言碎语令她声誉受到很大损害
② (weaken) «person» 减少 ‹chances, hope›; «person» 在…上让步 ‹principles›; «event» 损害 ‹reputation›
▸ to compromise success
减少成功的机会
D.to compromise oneself reflexive verb
使自己受到损害

  • ⏱ 2024-01-15 15:46:20 ^19836794-7OeQvHDq4

📌 and a pernicious change trades simplicity for its shallow cousin, convenience

  • ⏱ 2025-01-20 19:08:38 ^4-2380-2457


📌 agenda
💭 agenda | BrE əˈdʒɛndə, AmE əˈdʒɛndə |
noun
① Administration 议事日程
▸ to be on the agenda
列入日程表
② figurative (list of priorities) 工作事项
▸ a hidden or secret agenda
秘密事项
▸ unemployment is high on the political agenda
失业是重要的政治议题

  • ⏱ 2024-01-15 18:27:23 ^19836794-7Of13Dvx4


📌 hindsight
💭 hindsight | BrE ˈhʌɪn(d)sʌɪt, AmE ˈhaɪn(d)ˌsaɪt |
noun uncountable
事后聪明
▸ with (the benefit of) hindsight
事后一想

  • ⏱ 2024-01-15 18:27:50 ^19836794-7Of15v74a


📌 first-class functions
💭 In computer science, a programming language is said to have first-class functions if it treats functions as first-class citizens.

This means the language supports passing functions as arguments to other functions, returning them as the values from other functions, and assigning them to variables or storing them in data structures. Some programming language theorists require support for anonymous functions (function literals) as well.

In languages with first-class functions, the names of functions do not have any special status; they are treated like ordinary variables with a function type. The term was coined by Christopher Strachey in the context of “functions as first-class citizens” in the mid-1960s.

  • ⏱ 2024-01-15 18:30:22 ^19836794-7Of1fLzxO


📌 lexical
💭 lexical | BrE ˈlɛksɪkl, AmE ˈlɛksək(ə)l |
adjective
词汇的

  • ⏱ 2024-01-15 18:43:36 ^19836794-7Of27xPzo


📌 immutable
💭 immutable | BrE ɪˈmjuːtəbl, AmE ɪ(m)ˈmjudəb(ə)l,əˈmjudəb(ə)l |
adjective
formal 不可改变的 ‹fact, decision›

  • ⏱ 2024-01-15 18:44:16 ^19836794-7Of2aeD99

📌 text is generally encoded in UTF-8

  • ⏱ 2024-01-15 18:44:29 ^4-3181-3215


📌 no generics
💭 Go 1.18版本增加了对泛型的支持。

  • ⏱ 2024-01-15 20:15:14 ^19836794-7Of87zgQM


📌 macros
💭 宏(Macro),通常指一种通过预定义规则自动生成或替换代码的机制。宏的主要作用是简化重复性代码的编写,提升开发效率。

  • ⏱ 2025-01-21 21:26:03 ^19836794-7Xn3SFoUJ


📌 plague
💭 plague | BrE pleɪɡ, AmE pleɪɡ |
A.noun
① uncountable Medicine (epidemic) 瘟疫; (bubonic plague) 鼠疫
▸ a plague of typhoid/cholera
伤寒/霍乱瘟疫
▸ a plague epidemic/bacterium/vaccine
瘟疫流行/病菌/疫苗
▸ the Great Plague
大瘟疫 [1665-1666年主要在英国伦敦流行的黑死病]
▸ to avoid sb/sth like the plague
informal 极力回避某人/某事物
② countable (large number) 灾祸
▸ a plague of locusts/rats/muggers
蝗灾/鼠害/抢劫祸患
③ countable informal (annoying person) 讨厌的人; (annoying thing) 令人烦恼的事物
▸ the noise is a constant plague to the residents
噪音一直烦扰着居民
▸ that dog is a real plague!
那只狗实在讨厌!
B.transitive verb
① (beset) 困扰
▸ to be plagued with or by sth
为某事物所困扰
▸ the computer is plagued with or by technical faults
这台计算机频频出现技术故障
▸ we were plagued with or by wasps
我们为黄蜂所困扰
② (harass) 纠缠
▸ to plague sb with questions/complaints;
不断提问题/发牢骚烦扰某人
▸ to plague sb for sth;
缠着某人要求某事物
▸ to plague sb to do sth;
缠着某人做某事
▸ to plague the life out of sb
informal 把某人烦得要死

  • ⏱ 2024-01-15 20:18:07 ^19836794-7Of8jiQwy


📌 go to the lengths
💭 B.lengths plural noun
(extent, measures) 程度
▸ to go to great/any/such lengths (to do sth)
(为做某事)不遗余力
▸ they went to absurd lengths to keep the affair secret
他们为了对这件事保密无所不用其极
▸ to go to the lengths of doing sth
到做某事的程度
▸ he even went to the lengths of writing to the Queen
他甚至给女王写了信

  • ⏱ 2024-01-15 20:31:36 ^19836794-7Of9c4iQk


📌 contemporary
💭 /kənˈtempərərɪ/
a.当代的;现代的

  • ⏱ 2025-01-21 21:30:38 ^19836794-7Xn4bhTtM

📌 Go’s aggregate types (structs and arrays) hold their elements directly, requiring less storage and fewer allocations and pointer indirections than languages that use indirect fields.

  • ⏱ 2025-01-22 12:49:12 ^4-5266-5449

📌 goroutines

  • ⏱ 2025-01-22 12:49:26 ^4-5643-5660

📌 batteries included

  • ⏱ 2024-01-16 00:22:03 ^4-6158-6176

📌 Projects built using the go tool use only file and identifier names and an occasional special comment to determine all the libraries, executables, tests, benchmarks, examples, platform-specific variants, and documentation for a project; the Go source itself contains the build specification.

  • ⏱ 2025-01-22 21:06:51 ^4-6596-6913

Organization of the Book

📌 slices, Go’s approach to dynamic lists

  • ⏱ 2024-01-16 00:26:38 ^5-2456-2501


📌 imperative
💭 imperative /ɪmˈperətɪv/
a. 必要的;紧急的;极重要的
a. 命令(式)的;必须服从的,强制的;专横的
a. 具抑制(或控制、支配)力的
a. 【语】命令的,祈使的
n. 必要的事;紧急的事;必须履行的责任;需要,必要性
n. 命令;规则
n. 【语】祈使语气;祈使语气动词

  • ⏱ 2024-01-16 00:28:03 ^19836794-7OfoGb5Uo

📌 complex object behaviors are created from simpler ones by composition, not inheritance.

  • ⏱ 2025-01-22 21:09:42 ^5-3625-3712

📌 the relationship between concrete types and abstract types (interfaces) is implicit

  • ⏱ 2025-01-22 21:10:07 ^5-3815-3926

📌 Chapter 11 deals with testing, where Go takes a notably lightweight approach, avoiding abstraction-laden frameworks in favor of simple libraries and tools.

  • ⏱ 2025-01-22 21:11:54 ^5-5430-5589


📌 laden
💭 laden /ˈleɪdən/
• lade的过去分词
a. 装满的;充满了的
a. 负担沉重的;苦恼的
/ˈleɪdən/

  • ⏱ 2024-01-16 10:12:26 ^19836794-7Og0X575I


📌 atop
💭 atop /əˈtɒp/
prep. 在…顶上
ad. 在顶上

  • ⏱ 2024-01-16 10:12:58 ^19836794-7Og0Zhv7X


📌 gory details
💭 “Gory details” 是一个英语短语,指令人毛骨悚然或细节非常血腥的描述。这个短语经常用来形容与暴力、血腥或令人不适的细节相关的内容。比如,讲述某个事故、谋杀或其他惨烈事件时,提及了让人感到恐惧或厌恶的具体细节。
不过,在非正式语境中,“gory details” 有时也可以用来幽默地描述琐碎但具体的细节,比如一些尴尬、丢脸或者夸张的小故事。
例句:
1. The detective refused to share the gory details of the crime with the public.
(侦探拒绝向公众透露犯罪的血腥细节。)
2. She gave me all the gory details of her awkward date last night.
(她把昨晚尴尬约会的所有细节都告诉了我。)
根据上下文判断,它可能是严肃的,也可能带有戏谑的语气。

  • ⏱ 2025-01-23 12:13:05 ^19836794-7XpwhIKQ0

📌 gopl.io

  • ⏱ 2025-01-23 13:35:30 ^5-7008-7020

Where to Find More Information

📌 https://golang.org

  • ⏱ 2024-01-16 19:21:59 ^6-983-1006

📌 blog.golang.org

  • ⏱ 2024-01-16 19:22:11 ^6-1374-1394

📌 play.golang.org

  • ⏱ 2024-01-16 19:22:47 ^6-2142-2162

📌 read-eval-print loop (REPL)

  • ⏱ 2024-01-16 19:23:24 ^6-2803-2837


📌 snippets
💭 snippet
n. (切下的)小片;碎片;小部分;snippets片断,摘录
n. ⟨口⟩不足道的人;不知天高地厚的年轻人

  • ⏱ 2025-01-23 17:35:59 ^19836794-7XpRqR5MR

📌 tour.golang.org

  • ⏱ 2024-01-16 19:24:21 ^6-3211-3231


📌 elaborate
💭 /ɪˈlæbərət/
a. 精心计划(或制作)的;精巧的;详尽的
a. 复杂的
a. (煞费)苦心的,刻苦的,辛勤的
vt. 精心制作;详细搞出;详尽阐述;发挥;发展
vt. 使(食物或简单成分)变成复杂有机物;由简单成分合成为(复杂有机物)
vi. 详述;详尽计划(on,upon)
vi. 变得复杂

  • ⏱ 2024-01-16 19:25:02 ^19836794-7OgB8WcPf

Acknowledgments


📌 invaluable
💭 /ɪnˈvæljʊəbl/
a. 非常宝贵的;极为贵重的,无价的;无法估价的
a. ⟨古⟩没有价值的,无用的

  • ⏱ 2024-01-16 19:26:13 ^19836794-7OgBdKqG8

📌 went far beyond the call of duty

  • ⏱ 2024-01-16 19:26:38 ^7-1134-1166


📌 meticulous
💭 /mɪˈtɪkjʊləs, mə-/
a. 过分注意细节的;谨小慎微的
a. ⟨口⟩非常仔细的,非常注意细节的;一丝不苟的,严谨的

  • ⏱ 2024-01-16 19:27:05 ^19836794-7OgBhgX4m


📌 indebted
💭 /ɪnˈdetɪd/
a. 受惠的,蒙恩的;感激的(to)
a. 负债的(to)

  • ⏱ 2024-01-16 19:27:30 ^19836794-7OgBiXj9m

1.1 Hello, World

📌 Go is a compiled language. The Go toolchain converts a source program and the things it depends on into instructions in the native machine language of a computer.

  • ⏱ 2024-01-17 13:33:37 ^9-2239-2401

📌 The simplest of these subcommands is run, which compiles the source code from  one or more source files whose names end in .go, links it with libraries, then runs the resulting executable file.

  • ⏱ 2025-01-25 09:53:49 ^9-2545-2813

📌 Go natively handles Unicode, so it can process text in all the world’s languages.

  • ⏱ 2024-01-17 16:10:12 ^9-3628-3832

📌 A package consists of one or more .go source files in a single directory that define what the package does.

  • ⏱ 2025-01-25 23:40:02 ^9-5943-6077

📌 Package main is special. It defines a standalone executable program, not a library.

  • ⏱ 2025-01-25 23:40:02 ^9-7324-7434

📌 function main

  • ⏱ 2025-01-25 23:40:03 ^9-7505-7551


📌 You must import exactly the packages you need.
💭 但是Go有时候也需要隐式引入一些包,因为不引入的话,无法触发这些包的init方法。

  • ⏱ 2025-01-25 23:40:04 ^19836794-7XthTBK1z

📌 Go does not require semicolons at the ends of statements or declarations, except where two or more appear on the same line.

  • ⏱ 2025-01-25 23:40:05 ^9-10544-10668

📌 gofmt tool

  • ⏱ 2025-01-25 23:40:05 ^9-11483-11498


📌 fiat
💭 /ˈfaɪæt/
n. 命令;法令
n. 批准,许可;授权
n. (思想上的)决断,裁决
vt. 批准
vt. 以命令宣布,颁布

  • ⏱ 2024-01-17 17:11:22 ^19836794-7OhYHnl8P


📌 trivia
💭 [英][ˈtrɪviə][美][ˈtrɪviə]
n. 琐事,不足道的细枝末节

  • ⏱ 2025-01-25 23:40:05 ^19836794-7XthTIIEm


📌 infeasible
💭 /ɪnˈfiːzəbl/
a. 不能实行的,行不通的,办不到的

  • ⏱ 2024-01-17 17:11:58 ^19836794-7OhYJN7iV


📌 arbitrary
💭 [英][ˈɑ:bitrəri][美][ˈɑrbɪˌtrɛri]
adj. 随意的,任性的,随心所欲的;主观的,武断的;霸道的,专制的,专横的,独断独行的;乱

  • ⏱ 2025-01-25 23:40:07 ^19836794-7XthTMbMT

1.2 Command-Line Arguments

📌 The os package provides functions and other values for dealing with  the operating system in a platform-independent fashion.

  • ⏱ 2025-01-25 23:40:07 ^10-1588-1760

📌 os.Args

  • ⏱ 2025-01-25 23:40:08 ^10-2016-2028


📌 contiguous
💭 /kənˈtɪɡjʊəs/
a. 共边的;互相接触着的
a. 毗邻的;【数】相邻的
a. (时间或顺序上)紧接的;邻近的
a. 包含在同一边界之内的,连续不断的,连成一片的

  • ⏱ 2024-01-17 17:13:54 ^19836794-7OhYREjBf


📌 s[m:n]
💭 类Python风格,实际包含的下标为左闭右开,长度为m-n。

  • ⏱ 2025-01-25 23:40:08 ^19836794-7XthTVnLB

📌 half-open intervals

  • ⏱ 2024-01-17 17:14:30 ^10-2822-2848

📌 include the first index but exclude the last

  • ⏱ 2024-01-17 17:14:45 ^10-2877-2921

📌 contains n-m elements

  • ⏱ 2025-01-25 23:40:09 ^10-3136-3183

📌 If m or n is omitted, it defaults to 0 or len(s) respectively

  • ⏱ 2024-01-17 17:17:17 ^10-4008-4147

📌 Comments begin with //.

  • ⏱ 2025-01-25 23:40:09 ^10-6931-6980

📌 zero value

  • ⏱ 2024-01-17 17:53:04 ^10-7886-7903

📌 When applied to strings, however, the + operator concatenates the values

  • ⏱ 2025-01-25 23:40:09 ^10-8636-8762

📌 assignment statement

  • ⏱ 2025-01-25 23:40:09 ^10-9543-9570

📌 +=

  • ⏱ 2025-02-01 10:44:34 ^10-10119-10126

📌 assignment operator

  • ⏱ 2024-01-17 17:55:11 ^10-10154-10180


📌 quadratic
💭 /kwɒˈdrætɪk/
a. 【数】二次的,平方的
a. (似)正方形的
n. 【数】二次方程;二次式

  • ⏱ 2024-01-17 18:01:06 ^19836794-7Oi1XiKjD

📌 :=

  • ⏱ 2024-01-17 18:02:21 ^10-11669-11677

📌 short variable declaration

  • ⏱ 2024-01-17 18:02:11 ^10-11718-11751

📌 These are statements, not expressions as they are in most languages in the C family, so  j = i++ is illegal, and they are postfix only, so –i is not legal either.

  • ⏱ 2024-01-17 18:07:57 ^10-12462-12907


📌 postfix
💭 /ˈpəʊstfɪks/
n. 【语】后缀
vt. 【语】加…作后缀
vt. 【生】对(组织等)作后固定处理,再次用固定剂处理

  • ⏱ 2024-01-17 18:07:46 ^19836794-7Oi2olTVy

📌 initialization statement

  • ⏱ 2024-01-18 18:49:39 ^10-14367-14403

📌 condition is a boolean expression

  • ⏱ 2024-01-18 18:49:55 ^10-14683-14728

📌 post statement

  • ⏱ 2024-01-18 18:50:29 ^10-14944-14970

📌 blank identifier

  • ⏱ 2024-01-18 18:51:49 ^10-19718-19734

📌 The blank identifier may be used whenever syntax requires a variable name but program logic does not, for instance to discard an unwanted loop index when we require only the element value.

  • ⏱ 2024-01-19 00:33:48 ^10-19834-20022

📌 In practice, you should generally use one of the first two forms, with explicit initialization to say that the initial value is important and implicit initialization to say that the initial value doesn’t matter.

  • ⏱ 2024-01-19 00:35:16 ^10-21935-22424

📌 The old contents of s are no longer in use, so they will be garbage-collected in due course.

  • ⏱ 2024-01-19 09:58:21 ^10-22756-22876

📌 the Join function

  • ⏱ 2024-01-19 09:58:39 ^10-23229-23272

1.3 Finding Duplicate Lines


📌 on the fly
💭 In a hurry, on the run.

e.g. I picked up some groceries on the fly.

The transfer of this expression, which literally means “in midair or in flight,” dates from the mid-1800s.

  • ⏱ 2024-01-22 16:36:23 ^19836794-7OpxXfszr

📌 counts[input.Text()]++

  • ⏱ 2024-01-19 15:45:40 ^11-2634-2656

📌 A map holds a set of key/value pairs and provides constant-time operations to store, retrieve, or test for an item in the set.  The key may be of any type whose values can be compared with ==, strings being the most common example; the value may be of any type at all.

  • ⏱ 2024-01-19 15:44:56 ^11-3710-4054

📌 It’s not a problem if the map doesn’t yet contain that key. The first time a new line is seen, the expression counts[line] on the right-hand side evaluates to the zero value for its type, which is 0 for int.

  • ⏱ 2024-01-19 15:45:32 ^11-4959-5271

📌 The order of map iteration is not specified, but in practice it is random, varying from one run to another. This design is intentional, since it prevents programs from relying on any particular ordering where none is guaranteed.

  • ⏱ 2024-01-22 17:19:24 ^11-5563-5791

📌 verbs

  • ⏱ 2024-02-13 18:46:24 ^11-7784-7796


📌 escape sequences
💭 转义序列

  • ⏱ 2024-01-22 17:36:43 ^19836794-7OpBUdCPo


📌 cavalier
💭 cavalier | BrE ˌkavəˈlɪə, AmE ˌkævəˈlɪr |
A.Cavalier proper noun
British History 保王党成员
B.adjective
(offhand) 漫不经心的; (haughty) 傲慢的
▸ to treat sb in a cavalier manner
慢待某人

  • ⏱ 2024-01-23 15:52:18 ^19836794-7Or1nqSsa

📌 Functions and other package-level entities may be declared in any order.

  • ⏱ 2024-01-23 15:52:41 ^11-16028-16100

📌 A map is a reference to the data structure created by make. When a map is passed to a function, the function receives a copy of the reference, so any changes the called function makes to the underlying data structure will be visible through the caller’s map reference too.

  • ⏱ 2024-01-23 15:21:01 ^11-16150-16476

4.5 JSON

📌 JavaScript Object Notation (JSON) is a standard notation for sending and receiving structured information.

  • ⏱ 2024-01-21 17:38:11 ^37-678-784