Share E-Book
Scan to open this page

Scan with your phone to open this page

Author: Alan A. A. Donovan & Brian W. Kernighan

Rating 4.5 AI initial rating

No description

AI Reading Assistant

Whole-book reading guide from stratified index samples; jump to passages in the text

AI guide
【One-Line Pitch】 A rigorous, example-driven introduction to Go from two authors who helped define the language's culture: read it if you want to write idiomatic Go, not just Go that compiles. Best for programmers with some experience in another language who want depth on types, interfaces, concurrency, and the standard library. 【Book Arc】 - **Opening (~0%–10%)**: A hands-on tutorial builds small complete programs — echo, duplicate-line counter, animated GIF, URL fetcher, concurrent fetcher, and a web server — so you meet packages, maps, goroutines, and interfaces in working code before any formal treatment. - **Early (~10%–32%)**: Program structure and the mechanics of the language: names, declarations, variables, assignments, type declarations, packages and files, and scope, including the classic shadowing pitfalls of `:=` inside functions. - **Middle (~32%–55%)**: Basic data types in depth — integers, floating point (with precision caveats), booleans, strings and runes/UTF-8, constants and `iota` — then composite types: arrays, slices, and maps, with attention to sharing and comparison semantics. - **Late (~55%–80%)**: Functions, methods, and interfaces — the heart of Go's design — covering variadic and anonymous functions, method sets, embedding, and how `io.Writer`-style interfaces let unrelated types be used interchangeably. - **Ending (~80%–100%)**: Concurrency and the wider toolkit: goroutines, channels, `select`, shared-state alternatives, plus reflection, testing, and unsafe/low-level packages. (Excerpts do not cover these final chapters in detail.) 【Key Takeaways】 - **Go was designed against complexity** (Opening): the language grew from frustration with sprawling systems at Google; "complexity is multiplicative," so the design favors small, composable pieces over feature accumulation. - **Concurrency has deep roots, not a bolt-on** (Opening): Go's channels and goroutines descend from Hoare's CSP and Bell Labs languages like Newsqueak and Alef, which explains why concurrency feels native rather than library-based. - **Packages are the unit of organization** (Early): every file declares its package, `package main` plus `func main` defines an executable, and importing without using a package is a compile error — a deliberate hygiene rule. - **Scope and shadowing are real hazards** (Early): a `:=` inside a function can silently create a new local variable instead of assigning to a package-level one, a bug the compiler only sometimes catches. - **Zero values make maps and structs ergonomic** (Early): reading a missing map key yields the type's zero value, so `counts[line]++` works without initialization checks; map iteration order is intentionally randomized. - **Floating point demands care** (Middle): `float32` has roughly six digits of precision and can fail even simple equality (`f == f+1` can be true at 1<<24); prefer `float64` unless you have a reason not to. - **Strings are UTF-8, runes are code points** (Middle): `range` over a string decodes runes, not bytes, and the standard library offers helpers like `utf8.RuneCountInString` for the common cases. - **Interfaces unify disparate types** (Early/Middle): file, network, and in-memory outputs all satisfy `io.Writer`, letting the same function write to stdout, a file, or an HTTP response — the pattern the book returns to repeatedly. 【Reading Tips】 - **Do the tutorial chapter actively**: type and run the programs (dup, fetch, fetchall, the Lissajous server) rather than reading them; the exercises extend each one and are where the learning sticks. - **Deep-read the interfaces and concurrency chapters**: these carry the most conceptual weight and the most idiomatic payoff; skim the numeric-type minutiae if you already know IEEE 754. - **Watch for the "gotcha" asides**: shadowing, map iteration order, float precision, and unused-import errors are flagged in passing but matter in real code. - **Use it as a reference after the first pass**: the package/scope and composite-type chapters are worth revisiting when designing your own packages. 【Coverage Limits】 This guide is based on stratified excerpts covering roughly the first half of the book (tutorial through composite types); the later chapters on functions, methods, interfaces, concurrency, reflection, and testing are only partially represented, so their treatment here is necessarily thin.
Page 14
a programming langu age for writing exe cut able programs. Rob Pike and others began to exp eriment wit h CSP imp lementation s as actu al langu ages. The fi...
View in text
Excerpt 2
preted text; it’s ins pired by the invaluable utilit y curl. Obv iou sly one wou ld usu ally do more with such dat a, but this shows the basic idea. We will...
View in text
Excerpt 3
} f := tempconv.Fahrenheit(t) c := tempconv.Celsius(t) fmt.Printf("%s = %s, %s = %s\n", f, tempconv.FToC(f), c, tempconv.CToF(c)) } } The imp ort declarat io...
View in text
Excerpt 4
s of Unico de co de points, but for cor rec t us e of range lo ops on str ings, it’s more than a convent ion, it’s a necessity. What happens if we range over...
View in text
Excerpt 5
 _ = p.T{a: 1, b: 2} // compile error: can't reference a, b var _ = p.T{1, 2} // compile error: can't reference a, b Although the last line above doesn’t men...
View in text
Excerpt 6
meout = 1 * time.Minute deadline := time.Now().Add(timeout) for tries := 0; time.Now().Before(deadline); tries++ { _, err := http.Head(url) if err == nil { r...
View in text
Excerpt 7
Distance) to a specific receiver value p. This function can then be inv oke d without a receiver value; it needs only the non-receiver arguments. p := Point{...
View in text
Excerpt 8
ovan & Brian W. Kernighan revision 3b600c, date 29 Sep 2015 184  CHAPTER 7.  INTERFACES Figure 7.4. An int erface value holding a time.Time st ruc t. Interfa...
View in text
Tags
AI categories
GoProgramming LanguageSoftware
go
ISBN: 1838828109
Publish Year: 2015
Language: English
File Format: PDF
File Size: 4.8 MB
Text Preview (First 20 pages)
Registered users can read the full content for free

Register as a Gaohf Library member to read the complete e-book online for free and enjoy a better reading experience.

Generating text preview…