Skip to content

Commit 43adc6e

Browse files
committed
fix gitignore
1 parent 59ac2be commit 43adc6e

11 files changed

+3100
-8
lines changed

.gitignore

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22
.gcloudignore
33
/generated
44
app.yaml
5-
*.epub
6-
*.mobi
7-
*.html
8-
*.azw*
9-
*.pdf
10-
*.epub
11-
*.docx
12-
*.doc
5+
/*.epub
6+
/*.mobi
7+
/*.html
8+
/*.azw*
9+
/*.pdf
10+
/*.epub
11+
/*.docx
12+
/*.doc

pages/blog/101.html

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
2+
<h1>Go 101 Blog</h1>
3+
4+
<!-- index starts (don't remove) -->
5+
6+
<ul>
7+
<li>
8+
<a class="index" href="2022-04-01-update.html" data-tag="update" data-date="2022-03-05">Go 101 update (2022-Apr-01)</a>
9+
</li>
10+
<li>
11+
<a class="index" href="2022-02-22-history.html" data-tag="update" data-date="2022-02-22">Go 101 update history (before v1.18)</a>
12+
</li>
13+
</ul>
14+
15+
<!-- index ends (don't remove) -->

pages/blog/2022-02-22-history.html

Lines changed: 256 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,256 @@
1+
<p id="f-2022-02-22-history-md"></p>
2+
<h1>Go 101 Update History (Before v1.18)</h1>
3+
4+
<h3>v1.17.b (2021/Sep/10)</h3>
5+
6+
<ul>
7+
<li>improve implicit method value evaluation explanations</li>
8+
</ul>
9+
10+
<h3>1.16.b (2021/May/18)</h3>
11+
12+
<ul>
13+
<li>add Go 1.17 contents</li>
14+
</ul>
15+
16+
<h3>1.16.a (2021/Feb/18)</h3>
17+
18+
<ul>
19+
<li>support Go 1.16 embedding feature.</li>
20+
</ul>
21+
22+
<h3>1.15.b (2020/Oct/09)</h3>
23+
24+
<ul>
25+
<li>describe more about <a href="https://go101.org/article/details.html#reflect-deep-equal">reflect.DeepEqual</a> related details.</li>
26+
<li>add <a href="https://go101.org/article/exceptions.html#code-block-following-else">a new syntax execution</a>.</li>
27+
</ul>
28+
29+
<h3>1.15.a (2020/Aug/07)</h3>
30+
31+
<ul>
32+
<li>point out that, since Go Toolchain 1.15, using make+copy to clone slices is always more efficient than using append to clone.</li>
33+
</ul>
34+
35+
<h3>1.14.g (2020/Jun/12)</h3>
36+
37+
<ul>
38+
<li>remove the new detail added in 1.14.e: The behavior of comparing struct values with both comparable and incomparable fields or array values with both comparable and incomparable elements is unspecified. The reason is <a href="https://github.com/golang/go/issues/8606">the behavior will be specified</a>.</li>
39+
<li>add <a href="https://go101.org/article/details.html#impossible-to-interface-assertion">a new detail</a>: About the impossible to-interface assertions which can be detected at compile time.</li>
40+
</ul>
41+
42+
<h3>1.14.f (2020/Jun/02)</h3>
43+
44+
<ul>
45+
<li>All &quot;Go SDK&quot; uses are changed to &quot;Go Toolchain&quot;.</li>
46+
</ul>
47+
48+
<h3>1.14.e (2020/May/06)</h3>
49+
50+
<ul>
51+
<li>add <a href="https://go101.org/article/details.html#compare-values-with-both-comparable-and-incomparable-parts">a new detail</a>: The behavior of comparing struct values with both comparable and incomparable fields or array values with both comparable and incomparable elements is unspecified.</li>
52+
<li>add <a href="https://go101.org/article/details.html#blank-fields-are-ignored-in-comparisons">a new detail</a>: In struct value comparisons, blank fields will be ignored.</li>
53+
</ul>
54+
55+
<h3>1.14.d (2020/Apr/25)</h3>
56+
57+
<ul>
58+
<li><code>runtime.KeepAlive</code> related concents are removed from <a href="https://go101.org/article/unsafe.html">Unsafe Pointers</a> article.
59+
I'm sorry for spreading some wrong information in this article before.</li>
60+
</ul>
61+
62+
<h3>1.13.i (2019/Oct/31)</h3>
63+
64+
<ul>
65+
<li>fix a bug in the example code in the <a href="https://go101.org/article/container.html#delete-slice-elements">Delete a segment of slice elements</a> section
66+
of the &quot;Arrays, Slices and Maps in Go&quot; article.</li>
67+
<li>correct explainations in <a href="https://go101.org/article/function.html#function-evaluation-time">The Evaluation Moment of Deferred Function Values</a>.</li>
68+
<li>the article &quot;The Right Places to Call the Built-in <code>recover</code> Function&quot; is <a href="https://go101.org/article/panic-and-recover-more.html">renamed to</a> &quot;Explain Panic/Recover Mechanism in Detail&quot;. It was almost wholly re-written.</li>
69+
</ul>
70+
71+
<h3>1.13.h (2019/Oct/18)</h3>
72+
73+
<ul>
74+
<li>correct the explanations for the <a href="https://go101.org/article/evaluation-orders.html#value-assignment">Evaluation and Assignment Orders in Assignment Statements</a> section
75+
in the &quot;Expression Evaluation Orders&quot; article.</li>
76+
<li>add <a href="https://go101.org/article/101.html#compiler-optimizations">two new summaries</a>.</li>
77+
</ul>
78+
79+
<h3>1.13.e (2019/Oct/07)</h3>
80+
81+
<ul>
82+
<li>I decided to withdraw the last erratum in 1.13.d. (Re-added in 1.14.d)</li>
83+
</ul>
84+
85+
<h3>1.13.d (2019/Sep/30)</h3>
86+
87+
<ul>
88+
<li>add <a href="https://go101.org/article/unsafe.html#fact-value-address-might-change">a new fact</a> to the &quot;type-unsafe pointers&quot; article
89+
and pointed out <a href="https://go101.org/article/unsafe.html#pattern-convert-to-uintptr-and-back">a serious mistake</a> was made in this article.</li>
90+
</ul>
91+
92+
<h3>1.13.c (2019/Sep/25)</h3>
93+
94+
<ul>
95+
<li>remove the section containing a stupid code mistake from the &quot;The Right Places to Call the recover Function&quot; article.</li>
96+
</ul>
97+
98+
<h3>1.13.b (2019/Sep/19)</h3>
99+
100+
<ul>
101+
<li>remove the inaccurate description &quot;the address of a variable will never change&quot;</li>
102+
</ul>
103+
104+
<h3>1.13.a (2019/Sep/05)</h3>
105+
106+
<ul>
107+
<li>Go 1.13 ready.</li>
108+
<li>add two situations in the article <a href="https://go101.org/article/channel-closing.html">How to Gracefully Close Channels</a>.</li>
109+
<li><a href="https://go101.org/article/type-system-overview.html#unnamed-type">the &quot;named type&quot; and &quot;unnamed type&quot; terminologies</a> are added back,
110+
but they are eqivalent to &quot;defined type&quot; and &quot;non-defined type&quot; now.</li>
111+
</ul>
112+
113+
<h3>1.12.d (2019/May/18)</h3>
114+
115+
<ul>
116+
<li>enrich the <a href="https://go101.org/article/evaluation-orders.html#package-level-variables">Package-level Variables Initialization Order</a> section.</li>
117+
</ul>
118+
119+
<h3>1.12.c (2019/April/09)</h3>
120+
121+
<ul>
122+
<li>remove the &quot;named type&quot; and &quot;unnamed type&quot; terminology.</li>
123+
<li>adjust some discriptions in <a href="https://go101.org/article/type-embedding.html">Type Embdding</a>.</li>
124+
</ul>
125+
126+
<h3>1.12.b (2019/April/06)</h3>
127+
128+
<ul>
129+
<li>add a <a href="https://go101.org/article/evaluation-orders.html#package-level-variables">Package-level Variables Initialization Order</a> section.</li>
130+
</ul>
131+
132+
<h3>1.12.a (2019/March/02)</h3>
133+
134+
<ul>
135+
<li>Go 1.12 ready.</li>
136+
</ul>
137+
138+
<h3>1.11.f (2019/Jan/02)</h3>
139+
140+
<ul>
141+
<li>remove &quot;Unused Variables&quot; from <a href="https://go101.org/article/exceptions.html">Syntax/Semantics Exceptions In Go</a>.</li>
142+
</ul>
143+
144+
<h3>1.11.g (2018/Dec/27)</h3>
145+
146+
<ul>
147+
<li>a serious mistake was just fixed in this book.
148+
Before, the book said the starting index in a subslice syntax
149+
can't be larger than the length of the base slice. This is wrong.
150+
Please read <a href="container.html#subslice">the corrected section</a> again for details.</li>
151+
</ul>
152+
153+
<h3>1.11.f (2018/Nov/09)</h3>
154+
155+
<ul>
156+
<li>rearrange <a href="https://go101.org/article/details.html">Go Details 101</a>, more details are added.</li>
157+
</ul>
158+
159+
<h3>1.11.e (2018/Oct/26)</h3>
160+
161+
<ul>
162+
<li>published <a href="https://go101.org/article/evaluation-orders.html">Evaluation Orders</a>.</li>
163+
<li>modify some descriptions for
164+
165+
<ul>
166+
<li><a href="https://go101.org/article/packages-and-imports.html#initialization-order">program resource initialization order</a></li>
167+
</ul></li>
168+
</ul>
169+
170+
<h3>1.11.d (2018/Oct/18)</h3>
171+
172+
<ul>
173+
<li>remove &quot;Comparing Interface Values&quot; from <a href="https://go101.org/article/exceptions.html">Syntax/Semantics Exceptions In Go</a>.</li>
174+
<li>add &quot;Comparisons 2&quot; to <a href="https://go101.org/article/exceptions.html">Syntax/Semantics Exceptions In Go</a>.</li>
175+
<li>modify some descriptions for
176+
177+
<ul>
178+
<li><a href="https://go101.org/article/value-conversions-assignments-and-comparisons.html#comparison-rules">comparison rules</a></li>
179+
<li><a href="https://go101.org/article/packages-and-imports.html#package">package hierarchy</a></li>
180+
</ul></li>
181+
</ul>
182+
183+
<h3>1.11.c (2018/Sep/22)</h3>
184+
185+
<ul>
186+
<li>add a new tip <a href="https://go101.org/article/tips.html#make-struct-type-uncomparable">How to make a struct type incomparable?</a>.</li>
187+
<li>add a new tip <a href="https://go101.org/article/tips.html#reset-pointers-for-dead-elements">Try to reset pointers in freed-up slice elements</a>.</li>
188+
<li>add a new tip <a href="https://go101.org/article/tips.html#make-using-of-bce">Make optimizations by using BCE</a>.</li>
189+
<li>remove &quot;Precedences Of Unary Operators&quot; from <a href="https://go101.org/article/exceptions.html">Syntax/Semantics Exceptions In Go</a>.</li>
190+
</ul>
191+
192+
<h3>1.11.b (2018/Sep/09)</h3>
193+
194+
<ul>
195+
<li>published <a href="https://go101.org/article/tips.html">Go Tips 101</a>.</li>
196+
</ul>
197+
198+
<h3>1.11.a (2018/Sep/01)</h3>
199+
200+
<ul>
201+
<li>mention 1.11 new <code>wasm</code> GOARCH in <a href="https://go101.org/article/more.html#cross-platform-compiling">More Go Related Knowledges</a>.</li>
202+
<li>mention 1.11 new <code>go mod</code> command in <a href="https://go101.org/article/go-toolchain.html">The Go Toolchain</a>.</li>
203+
</ul>
204+
205+
<h3>1.10.g (2018/Jun/02)</h3>
206+
207+
<ul>
208+
<li>published <a href="https://go101.org/article/101-about.html">About Go 101</a>.</li>
209+
<li>published <a href="https://go101.org/article/acknowledgements.html">Acknowledgments</a>.</li>
210+
</ul>
211+
212+
<h3>1.10.f (2018/May/15)</h3>
213+
214+
<ul>
215+
<li>published <a href="https://go101.org/article/reflection.html">Relections in Go</a>.</li>
216+
<li>added a channel use case: <a href="https://go101.org/article/channel-use-cases.html#rate-limiting">rate limiting</a>.</li>
217+
</ul>
218+
219+
<h3>1.10.e (2018/Apr/28)</h3>
220+
221+
<ul>
222+
<li>added a new detail: <a href="https://go101.org/article/details.html#os-exit-runtime-goexit">Exit a program with a <code>os.Exit</code> function call and exit a goroutine with a <code>runtime.Goexit</code> function call.</a>.</li>
223+
</ul>
224+
225+
<h3>1.10.d (2018/Apr/18)</h3>
226+
227+
<ul>
228+
<li>added a new detail: <a href="https://go101.org/article/details.html#non-exported-names-from-different-packages">Non-exported method names and struct field names from different packages are viewed as diffferent names.</a>.</li>
229+
<li>added a FAQ question: [What does the compiler error message <code>declared and not used</code> mean?](<a href="https://go101.org/article/unofficial-faq.html#error-declared-not-used&quot;">https://go101.org/article/unofficial-faq.html#error-declared-not-used&quot;</a>)</li>
230+
<li>added a FAQ question: <a href="https://go101.org/article/unofficial-faq.html#time-sleep-after">What is the difference between the function call <code>time.Sleep(d)</code> and the channel receive operation <code>&lt;-time.After(d)</code>?</a></li>
231+
<li>added a FAQ question: <a href="https://go101.org/article/unofficial-faq.html#math-crypto-rand">What is the difference between the random numbers produced by the <code>math/rand</code> standard package and the <code>crypto/rand</code> standard package?</a></li>
232+
<li>added a FAQ question: <a href="https://go101.org/article/unofficial-faq.html#fmt-print-println">What are the differences between the <code>fmt.Print</code> and <code>fmt.Println</code> functions?</a></li>
233+
<li>added a FAQ question: <a href="https://go101.org/article/unofficial-faq.html#print-builtin-fmt-log">What are the differences between the built-in <code>print</code>/<code>println</code> functions and the corresponding print functions in the <code>fmt</code> and <code>log</code> standard packages?</a></li>
234+
<li>added a FAQ question: <a href="https://go101.org/article/unofficial-faq.html#math-round">Why isn't there a <code>math.Round</code> function?</a></li>
235+
<li>added a FAQ question: <a href="https://go101.org/article/unofficial-faq.html#gopher">What does the word <b><i>gopher</i></b> mean in Go community?</a></li>
236+
</ul>
237+
238+
<h3>1.10.c (2018/Apr/14)</h3>
239+
240+
<ul>
241+
<li>finished the article <a href="https://go101.org/article/concurrent-common-mistakes.html">some common concurrent programming mistakes</a>.</li>
242+
<li>published <a href="https://go101.org/article/details.html">Go details 101</a>.</li>
243+
<li>unhid <a href="https://go101.org/article/unofficial-faq.html">Go FAQ 101</a>.</li>
244+
</ul>
245+
246+
<h3>1.10.b (2018/Apr/06)</h3>
247+
248+
<ul>
249+
<li>added <a href="https://go101.org/article/type-embedding.html#dead-loop-example">an interesting type embedding example</a></li>
250+
<li>mentioned <a href="https://go101.org/article/channel.html#assign-and-compare">receive-only channels can't be closed</a></li>
251+
<li>mentioned <a href="https://go101.org/article/container.html#value-literals">indexes in array and slice composite literals must be constants</a></li>
252+
</ul>
253+
254+
<h3>1.10.a (2018/Mar/31)</h3>
255+
256+
<p>First release, though some articles are still not finished.</p>
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<p id="f-111-acknowledgements-md"></p>
2+
<h1>Acknowledgments</h1>
3+
4+
<p>Firstly, thanks to the whole Go community. An active and responsive community guarantees the completion this book.</p>
5+
6+
<p>Specially, I want to give thanks to the following people who helped me understand some implementation details in the official standard compiler and runtime: Robert Griesemer, Ian Lance Taylor, Axel Wagner, Keith Randall, findleyr, Bob Glickstein, Jan Mercl, Brian Candler, Awad Diar, etc. I'm sorry if I forgot mentioning somebody in above lists. There are so many kind and creative gophers in the Go community that I must have missed out on someone.</p>
7+
8+
<p>I also would like to thank all gophers who ever made influences on the Go 101 book, be it directly or indirectly, intentionally or unintentionally.</p>
9+
10+
<p>Thanks to Olexandr Shalakhin for the permission to use one of <a href="https://github.com/shalakhin/gophericons">the wonderful gopher icon designs</a> as the cover image. And thanks to Renee French for designing <a href="https://reneefrench.blogspot.com/">the lovely gopher cartoon character</a>.</p>
11+
12+
<p>Thanks to the authors of the following open source software and libraries used in building this book:</p>
13+
14+
<ul>
15+
<li>golang, <a href="https://go.dev/">https://go.dev/</a></li>
16+
<li>gomarkdown, <a href="https://github.com/gomarkdown/markdown">https://github.com/gomarkdown/markdown</a></li>
17+
<li>goini, <a href="https://github.com/zieckey/goini">https://github.com/zieckey/goini</a></li>
18+
<li>go-epub, <a href="https://github.com/bmaupin/go-epub">https://github.com/bmaupin/go-epub</a></li>
19+
<li>pandoc, <a href="https://pandoc.org">https://pandoc.org</a></li>
20+
<li>calibre, <a href="https://calibre-ebook.com/">https://calibre-ebook.com/</a></li>
21+
<li>GIMP, <a href="https://www.gimp.org">https://www.gimp.org</a></li>
22+
</ul>
23+
24+
<p>Thanks the gophers who ever reported mistakes in this book or made corrections for this book:
25+
ivanburak,
26+
etc.</p>
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<p id="f-222-about-this-book-md"></p>
2+
<h1>About Go Generics 101</h1>
3+
4+
<p>Starting from version 1.18 (the current latest version), Go supports custom generics.</p>
5+
6+
<p>This book talks about the custom generics feature of Go programming language.
7+
The content in this book includes:</p>
8+
9+
<ul>
10+
<li>custom generic syntax</li>
11+
<li>type constraints and type parameters</li>
12+
<li>type arguments and type inference</li>
13+
<li>how to write valid custom generic code</li>
14+
<li>current implementation/design restrictions</li>
15+
</ul>
16+
17+
<p>A reader needs to be familiar with Go general programming to read this book.
18+
In particular, readers of this book should be familiar with
19+
<a href="https://go101.org/article/type-system-overview.html">Go type system</a>,
20+
including Go built-in generics, which and Go custom generics are two different systems.</p>
21+
22+
<p>Currently, the book mainly focuses on the syntax of, and concepts in, custom generics.
23+
More practical examples will be provided when I get more experiences of using custom generics.</p>
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
<p id="f-333-about-go-generics-md"></p>
2+
<h1>About Go Custom Generics</h1>
3+
4+
<p>The main purpose of custom generics is to avoid code repetitions,
5+
or in other words, to increase code reusability.</p>
6+
7+
<p>For some situations, generics could also lead to cleaner code and simpler APIs
8+
(not always).</p>
9+
10+
<p>For some situations, generics could also improve code execution performance
11+
(again not always).</p>
12+
13+
<p>Before version 1.18, for many Go programmers, the lack of custom generics caused pains in Go programming under some situations.</p>
14+
15+
<p>Indeed, the pains caused by the lack of custom generics were alleviated to a certain extend by the following facts.</p>
16+
17+
<ul>
18+
<li>Since version 1.0, Go has been supported built-in generics, which include some built-in generic type kinds (such as map and channel) and generic functions (<code>new</code>, <code>make</code>, <code>len</code>, <code>close</code>, etc).</li>
19+
<li>Go supports reflection well (through interfaces and the <code>reflect</code> standard package).</li>
20+
<li>Repetitive code could be generated automatically by using some tools (such as the <code>//go:generate</code> comment directive supported by the official Go toolchain).</li>
21+
</ul>
22+
23+
<p>However, the pains are still there for many use cases.
24+
The demand for custom generics became stronger and stronger.
25+
In the end, the Go core team decided to support custom generics in Go.</p>
26+
27+
<p>For all sorts of reasons, including considerations of syntax/semantics backward compatibility and implementation difficulties, the Go core team settled down on <a href="https://go.googlesource.com/proposal/+/refs/heads/master/design/43651-type-parameters.md">the type parameters proposal</a> to implement custom generics.</p>
28+
29+
<p>The first Go version supporting custom generics is 1.18 (the current latest version).</p>
30+
31+
<p>The type parameters proposal tries to solve many code reuse problems, but not all.
32+
And please note that, not all the features mentioned in the parameters proposal have been implemented yet currently (Go toolchain version 1.18). The custom generics design and implementation will continue to evolve and get improved in future Go versions. And please note that the proposal is not the sky of Go custom generics.</p>
33+
34+
<p>Despite the restrictions (temporary or permanent ones) in the current Go custom generics design and implementation,
35+
I also have found there are some details which are handled gracefully and beautifully in the implementation.</p>
36+
37+
<p>Although Go custom generics couldn't solve all code reuse problems,
38+
personally, I believe Go custom generics will be used widely in future Go programming.</p>

0 commit comments

Comments
 (0)