Essential Books
  ↑ ↓ to navigate     ↵ to select     Esc to close

Essential Go

Table Of Contents
Install Go toolchain
Windows setup
Mac OS setup
Linux setup
Hello, World!
Take a guided tour
Access documentation offline
Run Go in online playground
Release history
Floating-point numbers
Characters and runes
Empty interface
Zero values
Type aliases
Type casting
Basic variable declaration
Multiple variable assignment
Blank identifier
Typed vs. untyped constants
Emulating enums
Find string in another string
Compare strings
Convert string to lower case or upper case
Remove white space, characters, substrings
Split and join strings
Format text
Parse text
Replace strings
Read text file line by line
Normalize newlines
Basic pointers
Dereferencing pointers
Pointer vs. value methods
Create array
Array indexes
Multidimensional array
Create a slice
Length and capacity
Zero value of slice
Append to slice
Add slices
Filter a slice
Remove elements from slice
Duplicate (create a copy of) a slice
Declare and initialize a map
Create a map
Get value by key
Count number of map entries
Zero value of a map
Copy a map
Iterate over keys, values or both with range
Delete map element
Use map as a set
Maps with slices as values
Concurrent access of maps
Basic declaration
Struct literals
Anonymous structs
Composition and embedding
Exported vs. unexported fields (private vs public)
Duplicate a struct (make a copy)
Empty struct
Simple interface
Determining underlying type from interface
Testing Interface Implementation
Type assertion
Type switch
if statement
switch statement
goto statements
Different forms of for loop
break and continue
while loop
Timed loop
range over a string
range over slice
range over a map
range over a channel
Variadic functions
Return values
Named return values
Variables of function type
Literal functions
Creating errors
Create custom error type
Returning an error
Handling an error
Handling errors in short programs
Add callstack to error messages
Good practices for error messages
Defer basics
Defer gotchas
Recovering from panic
Panic use cases
Hello World goroutine
Create goroutines
Wait for goroutines to finish
Limiting concurrency with semaphore
Using range to read from a channel
Timout reading from channel with select
Closing channels
Buffered vs. unbuffered channels
Non-blocking receive with select
Signaling channel with chan struct{}
Checking if channel has data available
Read-Write mutes (RWMutex)
Mutex gotchas
Detecting races
Installing packages locally with go get
Importing packages
Creating a package
Package initalization
Package naming best practices
Reading and writing to a file using ioutil
Listing all the files and folders in the current directory
Listing all folders in the current directory
Format time
Parse time
Format time like strftime
Compare time and date
Raw access to comman line arguments
Libraries for advanced parsing of command-line arguments
Logging libraries
Using bytes.Reader to read from a string
Timing Out with Interrupt and then Kill
Executing a Command then Continue and Wait
Simple Command Execution
Running a Command twice
Basic GET
Time out request with a context
PUT request of JSON object
GET with URL parameters and a JSON response
Hello World
Create a HTTPS Server
HTTP Hello World with custom server and mux
Responding to an HTTP Request using Templates
Serving content using ServeMux
Using a handler function
Handling http method, accessing query strings & request body
Encoding to a String
Decoding a String
Basic JSON decoding
Using anonymous structs for decoding
Basic JSON encoding
Decoding JSON data from a file
Configuring JSON struct fields
Marshaling structs with private fields
Encoding/Decoding using Go structs
Basic decoding / unmarshalling of nested elements with data
Creating a config file in YAML format
Opening a database
MongoDB: connect & insert & remove & update & query
How to encode data and write to file with gob?
How to read data from file and decode with go?
How to encode an interface with gob?
How to decode an interface with gob?
Output values of struct variable to stdout using a text template
Defining functions for calling from template
Single item template
Multiple item template
Templates with custom logic
Templates with structs
HTML templates
How HTML templates prevent malicious code injection
Type of value - package "reflect"
Basic reflect.Value Usage
Context tree represented as a directed graph
Using a context to cancel work
Basic fmt
Assigning signals to a channel
Basic Test
Table-driven unit tests
Testing using setUp and tearDown function
Benchmark tests
Example tests (self documenting tests)
Testing HTTP requests
Set/Reset Mock Function In Tests
View code coverage in HTML format
Sending Email with smtp.SendMail()
Cgo: First steps tutorial
Calling C Function From Go
Wire C and Go code in all directions
Basic cpu and memory profiling
Using Benchmarks to Create Profile
Basic memory Profiling
Set CPU/Block profile rate
Accessing Profile File
Build tags
File suffix
Defining separate behaviours in different platforms
Simple cross compilation with go build
Compile all architectures using a Makefile
Cross compilation by using gox
Simple Example: Compile helloworld.go for arm architecture on Linux machine
Separate integration tests
Optimize implementations based on architecture
Interface & Polymorphism
Embedded structs
Pointer Vs Value receiver
Use govendor to add external packages
Using trash to manage ./vendor
Use golang/dep
vendor.json using Govendor tool
Defining and using a plugin
Normal Handler Function
Middleware Calculate time required for handlerFunc to execute
CORS Middleware
Auth Middleware
Recovery Handler to prevent server from crashing
Using Protobuf with Go
Read input from console
Encryption and decryption
Parsing and validating a token using the HMAC signing method
Creating a token using a custom claims type
Creating, signing, and encoding a JWT token using the HMAC signing method
Using the StandardClaims type by itself to parse a token
Parsing the error types using bitfield checks
Getting token from HTTP Authorization header
Basic concepts
Loading and saving image
Cropping image
Convert color image to grayscale
Disabling inline expansion
go fmt
go run
go build
go clean
go get
go env
go test