- Go 94.5%
- Makefile 5.5%
| Filename | Latest commit message | Latest commit date |
|---|---|---|
| ch1 | ||
| ch2 | ||
| ch3 | ||
| ch4 | ||
| README.org | ||
Chapter Notes
Chapter 1
- Go Compatibility Promise is pretty rad.
- A "modern" community that adopted
Makefile? Awesome? goplsis cute.
Chapter 2
- Leading 0 with no prefix being octal is strange. I'm glad the book suggests not using it to reduce confusion.
- Underscores allowed in numbers for place separation makes me happy.
- rune literal :: single character, denoted with single quotes. Common
escapes are runes; e.g.,
\n,\t,\',\\ - interpreted string literal :: double quoted strings. Called interpreted because they interpret runes into single characters
- raw string literal :: backquoted string, runes are not interpreted automatically
- The result of integer division is also an integer, not a float.
+=etc are valid for modifying; e.g.,somevar *= 3-
declaration lists :: Allows assigning multiple variables at once, as a part of a single visual block
var ( a rune b int = 10 c = 30 ) -
:=:: declaration and assignment shorthand. Likevarbut also does assignment to existing variables. only valid inside of functionsa, b := 20, 40 a := 60 - Immutability in go is pretty limiting…
-
Similar to zig, unread variables cause a compile time error
- I still think that while this makes sense at the end of a feature development, it's needlessly frustrating during development. I wish this could be turned off for dev builds and enforced for production builds.
- Unicode allowed in var names is neat, but feel like they'd be a pain to actually use… glad the book calls this out.
- Camel case over snake case.
-
wat?
This is because Go uses the case of the first letter in the name of a package-level declaration to determine if the item is accessible outside the package.
Chapter 3
- Weird restrictions on array typing. Hope that I hear more about why.
- ok, so slices are the real arrays, I guess? That nomenclature is a bit obnoxious.
- ok, so we finally found
nil nilisn't comparable, but a length ofnilis0?-
Despite the kinda weird nomenclature around slices, I do like the split between length and capacity.
make(int[], 0, 10)is a neat way to start with nothing, knowing you probably won't go above 10
- Slicing slices sharing a memory address seems like a really cool feature but a sharp knife. I already know that at some point I am going to accidentally change a value I don't expect with this.
map[string][]stringis so difficult to visually parse.- The comma ok idiom makes me want to just have an
:oksigil again.
Chapter 4
-
Scoping a variable to an
ifblock is neat. Gotta think on if it's actually useful though. I guess it kind of formalizes something I do fairly frequently: declaring a var right above a scope for use in it.if n := rand.Intn(10); n == 0 { fmt.Println("That's too low") } else if n > 5 { fmt.Println("That's too big:", n) } else { fmt.Println("That's a good number:", n) } -
I have… feelings… about Go only having a
forloop.- no
do...whileI have less strong feelings about, I guess. - I feel like fewer keywords here is just going to make the code harder to understand.
- I don't feel like
for-rangeis an improvement over the more commonfor-in. - Having
for-rangegive a random order during iteration, but a fixed order in a debugging print, feels likely to bite.
- no
- No fall-through on
switchpleases me. -
Scoping to a block will take practice to recognize, took me a couple of passes to understand how this is a "blank switch":
switch someVar := 10; { case 1,2,3,4: // something default: // something else } - I appreciate the reasoning the author provides for deciding between
a
switchandif/else. Switch indicates a relationship between the evals.