The Go Programming Language Quotes
The Go Programming Language
by
Alan A.A. Donovan1,765 ratings, 4.43 average rating, 144 reviews
Open Preview
The Go Programming Language Quotes
Showing 1-30 of 32
“Novices are sometimes tempted to use buffered channels within a single goroutine as a queue, lured by their pleasingly simple syntax, but this is a mistake. Channels are deeply connected to goroutine scheduling, and without another goroutine receiving from the channel, a sender—and perhaps the whole program—risks becoming blocked forever. If all you need is a simple queue, make one using a slice.”
― The Go Programming Language
― The Go Programming Language
“The LimitReader function in the io package accepts an io.Reader r and a number of bytes n, and returns another Reader that reads from r but reports an end-of-file condition after n bytes. Implement it.”
― The Go Programming Language
― The Go Programming Language
“Write a function CountingWriter with the signature below that, given an io.Writer, returns a new Writer that wraps the original, and a pointer to an int64 variable that at any moment contains the number of bytes written to the new Writer. Click here to view code image func CountingWriter(w io.Writer) (io.Writer, *int64)”
― The Go Programming Language
― The Go Programming Language
“Exercise 7.10: The sort.Interface type can be adapted to other uses. Write a function IsPalindrome(s sort.Interface) bool that reports whether the sequence s is a palindrome, in other words, reversing the sequence would not change it. Assume that the elements at indices i and j are equal if !s.Less(i, j) && !s.Less(j, i).”
― The Go Programming Language
― The Go Programming Language
“This pattern can be used to temporarily save and restore all kinds of global variables”
― The Go Programming Language
― The Go Programming Language
“// NOTE: never put passwords in source code!”
― The Go Programming Language
― The Go Programming Language
“Unlike garbage variables, leaked goroutines are not automatically collected, so it is important to make sure that goroutines terminate themselves when no longer needed. The”
― The Go Programming Language
― The Go Programming Language
“Newcomers to Go, especially those from a background in strongly typed languages, may find this lack of explicit intention unsettling, but it is rarely a problem in practice.”
― The Go Programming Language
― The Go Programming Language
“var _ io.Writer = (*bytes.Buffer)(nil)”
― The Go Programming Language
― The Go Programming Language
“In a realistic program, convention dictates that if any method of Point has a pointer receiver, then all methods of Point should have a pointer receiver, even ones that don’t strictly need it.”
― The Go Programming Language
― The Go Programming Language
“The two print statements below have the same effect. log.Println(findLinks(url))
links, err := findLinks(url)
log.Println(links, err)”
― The Go Programming Language
links, err := findLinks(url)
log.Println(links, err)”
― The Go Programming Language
“In contrast, typical Go implementations use variable-size stacks that start small and grow as needed up to a limit on the order of a gigabyte. This lets us use recursion safely and without worrying about overflow.”
― The Go Programming Language
― The Go Programming Language
“Sometimes this sensible initial behavior happens for free, but sometimes the type designer has to work at it.”
― The Go Programming Language
― The Go Programming Language
“In practice, the order is random, varying from one execution to the next. This is intentional; making the sequence vary helps force programs to be robust across implementations”
― The Go Programming Language
― The Go Programming Language
“The subtle part is that the input slice and the output slice share the same underlying array. This avoids the need to allocate another array, though of course the contents of data are partly overwritten, as evidenced by the second print statement:”
― The Go Programming Language
― The Go Programming Language
“But what if it could vary? This brings us to iota.”
― The Go Programming Language
― The Go Programming Language
“The alternative would be calamitous. If len returned an unsigned number, then i too would be a uint, and the condition i >= 0 would always be true by definition.”
― The Go Programming Language
― The Go Programming Language
“It’s all bits at the bottom, of course, but computers operate fundamentally on fixed-size numbers called words,”
― The Go Programming Language
― The Go Programming Language
“but normal practice in Go is to deal with the error in the if block and then return, so that the successful execution path is not indented.”
― The Go Programming Language
― The Go Programming Language
“Simplicity requires more work at the beginning of a project to reduce an idea to its essence and more discipline over the lifetime of a project to distinguish good changes from bad or pernicious ones.”
― The Go Programming Language
― The Go Programming Language
“The final two chapters of the book examine the reflect and unsafe packages, which few Go programmers regularly use—and even fewer need to use. If you haven’t written any substantial Go programs yet, now would be a good time to do that.”
― The Go Programming Language
― The Go Programming Language
“Package main is special. It defines a standalone executable program, not a library. Within package main the function main is also special—it’s where execution of the program begins.”
― The Go Programming Language
― The Go Programming Language
“A package consists of one or more .go source files in a single directory that define what the package d”
― The Go Programming Language
― The Go Programming Language
“In Go, the sign of the remainder is always the same as the sign of the dividend, so -5%3 and -5%-3 are both -2.”
― The Go Programming Language
― The Go Programming Language
“The zero-value mechanism ensures that a variable always holds a well-defined value of its type; in Go there is no such thing as an uninitialized variable.”
― The Go Programming Language
― The Go Programming Language
“Go does not permit unused local variables, so this would result in a compilation error.”
― The Go Programming Language
― The Go Programming Language
“The first form, a short variable declaration, is the most compact, but it may be used only within a function, not for package-level variables.”
― The Go Programming Language
― The Go Programming Language
“Exercise 1.3: Experiment to measure the difference in running time between our potentially inefficient versions and the one that uses strings.Join. (Section 1.6 illustrates part of the time package, and Section 11.4 shows how to write benchmark tests for systematic performance evaluation.)”
― The Go Programming Language
― The Go Programming Language
“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.”
― The Go Programming Language
― The Go Programming Language
“Testing is fundamentally a pragmatic endeavor, a trade-off between the cost of writing tests and the cost of failures that could have been prevented by tests.”
― The Go Programming Language
― The Go Programming Language
