Library Hours
Monday to Friday: 9 a.m. to 9 p.m.
Saturday: 9 a.m. to 5 p.m.
Sunday: 1 p.m. to 9 p.m.
Naper Blvd. 1 p.m. to 5 p.m.
     
Limit search to available items
Results Page:  Previous Next
Author Bodner, Jon, author.

Title Learning Go : an idiomatic approach to real-world Go programming / Jon Bodner.

Edition First edition.
Publication Info. Beijing ; Boston : O'Reilly, 2021.
©2021
Location Call No. Status
 Nichols Adult Nonfiction  004.6782 GO 2021    AVAILABLE
QR Code
Description xvii, 352 pages : illustrations ; 24 cm
Note Includes index.
Contents Preface -- 1. Setting up your go environment ; Installing the go tools ; The go workspace ; The go command ; go run and go build ; Getting third-party go tools ; Formatting your code ; Linting and vetting ; Choose your tools ; Visual studio code ; GoLand ; The go playground ; Makefiles ; Staying up to date ; Wrapping up -- 2. Primitive types and declarations ; Built-in types ; The zero value ; Literals ; Booleans ; Numeric types ; A taste of strings and runes ; Explicit type conversion ; var versus := ; Using const ; Typed and untyped constants ; Unused variables ; Naming variables and constants ; Wrapping up -- 3. Composite types ; Arrays—Too rigid to use directly ; Slices ; len ; append ; Capacity ; make ; Declaring your slice ; Slicing slices ; Converting arrays to slices ; copy ; Strings and runes and bytes ; Maps ; Reading and writing a map ; The comma ok idiom ; Deleting from maps ; Using maps as sets ; Structs ; Anonymous structs ; Comparing and converting structs ; Wrapping up -- 4. Blocks, shadows, and control structures ; Blocks ; Shadowing variables ; Detecting shadowed variables ; if ; for, four ways ; The complete for statement ; The condition-only for statement ; The infinite for statement ; break and continue ; The for-range statement ; Labeling your for statements ; Choosing the right for statement ; switch ; Blank switches ; Choosing between if and switch ; goto—Yes, goto ; Wrapping up -- 5. Functions ; Declaring and calling functions ; Simulating named and optional parameters ; Variadic input parameters and slices ; Multiple return values ; Multiple return values are multiple values ; Ignoring returned values ; Named return values ; Blank returns—never use these! ; Functions are values ; Function type declarations ; Anonymous functions ; Closures ; Passing functions as parameters ; Returning functions from functions ; defer ; Go is call by value ; Wrapping up -- 6. Pointers ; A quick pointer primer ; Don’t fear the pointers ; Pointers indicate mutable parameters ; Pointers are a last resort ; Pointer passing performance ; The zero value versus no value ; The difference between maps and slices ; Slices as buffers ; Reducing the garbage collector’s workload ; Wrapping up -- 7. Types, methods, and interfaces ; Types in go ; Methods ; Pointer receivers and value receivers ; Code your methods for nil instances ; Methods are functions too ; Functions versus methods ; Type declarations aren’t inheritance ; Types are executable documentation ; iota is for enumerations—sometimes ; Use embedding for composition ; Embedding is not inheritance ; A quick lesson on interfaces ; Interfaces are type-safe duck typing ; Embedding and interfaces ; Accept interfaces, return structs ; Interfaces and nil ; The empty interface says nothing ; Type assertions and type switches ; Use type assertions and type switches sparingly ; Function types are a bridge to interfaces ; Implicit interfaces make dependency injection easier ; Wire ; Go isn’t particularly object-oriented (and that’s great) ; Wrapping up -- 8. Errors ; How to handle errors: the basics ; Use strings for simple errors ; Sentinel errors ; Errors are values ; Wrapping errors ; Is and as ; Wrapping errors with defer ; panic and recover ; Getting a stack trace from an error ; Wrapping up -- 9. Modules, packages, and imports ; Repositories, modules, and packages ; go.mod ; Building packages ; Imports and exports ; Creating and accessing a package ; Naming packages ; How to organize your module ; Overriding a package’s name ; Package comments and godoc ; The internal package ; The init function: avoid if possible ; Circular dependencies ; Gracefully renaming and reorganizing your api ; Working with modules ; Importing third-party code ; Working with versions ; Minimum version selection ; Updating to compatible versions ; Updating to incompatible versions ; Vendoring ; pkg.go.dev ; Additional information ; Publishing your module ; Versioning your module ; Module proxy servers ; Specifying a proxy server ; Private repositories ; Wrapping up -- 10. Concurrency in go ; When to use concurrency ; Goroutines ; Channels ; Reading, writing, and buffering ; for-range and channels ; Closing a channel ; How channels behave ; select ; Concurrency practices and patterns ; Keep your apis concurrency-free ; Goroutines, for loops, and varying variables ; Always clean up your goroutines ; The done channel pattern ; Using a cancel function to terminate a goroutine ; When to use buffered and unbuffered channels ; Backpressure ; Turning off a case in a select ; How to time out code ; Using waitgroups ; Running code exactly once ; Putting our concurrent tools together ; When to use mutexes instead of channels ; Atomics—You probably don’t need these ; Where to learn more about concurrency ; Wrapping up -- 11. The standard library ; io and friends ; time ; Monotonic time ; Timers and timeouts ; encoding/json ; Use struct tags to add metadata ; Unmarshaling and marshaling ; JSON, readers, and writers ; Encoding and decoding JSON streams ; Custom JSON parsing ; net/http ; The client ; The server ; Wrapping up -- 12. The context ; What is the context? ; Cancellation ; Timers ; Handling context cancellation in your own code ; Values ; Wrapping up -- 13. Writing tests ; The basics of testing ; Reporting test failures ; Setting up and tearing down ; Storing sample test data ; Caching test results ; Testing your public api ; Use go-cmp to compare test results ; Table tests ; Checking your code coverage ; Benchmarks ; Stubs in go ; httptest ; Integration tests and build tags ; Finding concurrency problems with the race checker ; Wrapping up -- 14. Here there be dragons: reflect, unsafe, and cgo ; Reflection lets us work with types at runtime ; Types, kinds, and values ; Making new values ; Use reflection to check if an interface’s value is nil ; Use reflection to write a data marshaler ; Build functions with reflection to automate repetitive tasks ; You can build structs with reflection, but don’t ; Reflection can’t make methods ; Only use reflection if it’s worthwhile ; unsafe is unsafe ; Use unsafe to convert external binary data ; unsafe strings and slices ; unsafe tools ; Cgo is for integration, not performance ; Wrapping up -- 15. A look at the future: generics in go ; Generics reduce repetitive code and increase type safety ; Introducing generics in go ; Use type lists to specify operators ; Generic functions abstract algorithms ; Type lists limit constants and implementations ; Things that are left out ; Idiomatic go and generics ; Further futures unlocked ; Wrapping up.
Summary Go is rapidly becoming the preferred language for building web services. While there are plenty of tutorials available that teach Go's syntax to developers with experience in other programming languages, tutorials aren't enough. They don't teach Go's idioms, so developers end up recreating patterns that don't make sense in a Go context. This practical guide provides the essential background you need to write clear and idiomatic Go. No matter your level of experience, you'll learn how to think like a Go developer. Author Jon Bodner introduces the design patterns experienced Go developers have adopted and explores the rationale for using them. You'll also get a preview of Go's upcoming generics support and how it fits into the language. Learn how to write idiomatic code in Go and design a Go project; Understand the reasons for the design decisions in Go; Set up a Go development environment for a solo developer or team; Learn how and when to use reflection, unsafe, and cgo; Discover how Go's features allow the language to run efficiently; Know which Go features you should use sparingly or not at all.
Subject Go (Computer program language)
Computer programming.
Web applications -- Programming.
Open source software.
ISBN 9781492077213
1492077216
Patron reviews: add a review
Click for more information
BOOK
No one has rated this material

You can...
Also...
- Find similar reads
- Add a review
- Sign-up for Newsletter
- Suggest a purchase
- Can't find what you want?
More Information