Chapters
Table Of Contents
Windows install and setup
Mac OS install and setup
Linux install and setup
Hello, World!
Take a guided tour
Access documentation offline
Run Go in online playground
GOPATH, GOROOT, GOBIN
Booleans
Integers
Floating-point numbers
Characters and runes
Strings
Constants
Enums
Arrays
Slices
Maps
Structures
Interfaces
Empty interface
Pointers
Unions
Channels
Zero values
Type casting
Type aliases
Basic variable declaration
Multiple variable assignment
Blank identifier
Typed vs. untyped constants
iota
Emulating enums
Find string in another string
Compare strings
Convert to lower case or upper case
Convert to int, float
Trim strings
Split and join strings
Format text
Parse text
Replace strings
Read file line by line
Normalize newlines
Basics of pointers
Dereferencing pointers
Pointer vs. value methods
Create array
Array indexes
Multidimensional array
Create a slice
Length and capacity
Append to slice
Filter a slice
Remove elements from slice
Duplicate (create a copy of) a slice
Zero value of slice
Declare and initialize a map
Create a map
Get value by key
Get map size (number of map entries)
Zero value of a map
Copy a map
Iterate over a map with range
Delete from a map
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)
Struct tags
Duplicate a struct (make a copy)
Empty struct
Methods
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
range over a string
range over a slice
range over a map
range over a channel
Parameters
Return values
Named return values
Variadic functions
Function literals
Variables of function type
Closures
Creating error values
Custom error types
Returning an error
Handling an error
Handling errors in short programs
Add callstack to error messages
Writing good error messages
Defer in depth
Defer gotchas
Panic
Recover
Recovering from panic
Use cases for panic
Hello World goroutine
Create goroutines
Wait for goroutines to finish
Limiting concurrency with a semaphore
Using range to read from a channel
Timeout 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 initialization
Package naming best practices
Reading files
Writing files
File operations
Directory operations
File path operations
I/O related interfaces
Format time
Parse time
Format time like strftime
Compare time and date
Raw access to command line arguments
Libraries for advanced parsing of command-line arguments
Logging libraries
Timing out process execution
os.Exec gotchas
hex
base64
Parsing arbitrary JSON documents
Decoding into anonymous structs
Decoding JSON from a file
Configuring JSON serialization
Custom JSON marshaling
Go to JSON type mappings
Easy generation of JSON struct definition
Pull (streaming) XML parsing
Hybrid XML parsing: combine pull and unmarshal
Parse XML from file
Configuring XML parsing and serialization
Custom XML marshaling
Easy generation of XML struct definition
Configuring CSV parsing and writing
Querying
MySQL
Opening a database
HTTP POST
PUT request of JSON object
Timeout requests with a context
GET with URL parameters and a JSON response
Set User-Agent
3 ways of doing HTTP requests
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
Methods as data
if action
range action
Built-in functions
Custom functions
HTML templates
Primitive types
Pointers
Structs
Slice
reflect.Kind
Uses for reflection
Context with value
Writing cancellable functions
Context is a tree of values
context.TODO() vs. context.Background()
Stringer
Basic fmt
Assigning signals to a channel
sync.Pool
Basic Test
Table-driven unit tests
Testing using setUp and tearDown function
Benchmarks
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 behaviors 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
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?
Structs
Methods
Interface & polymorphism
Embedded structs
Pointer Vs Value receiver
Use golang/dep
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 with AES GCM
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
Parsing the error types using bitfield checks
Getting token from HTTP Authorization header
Using the StandardClaims type by itself to parse a token
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
  ↑ ↓ to navigate     ↵ to select     Esc to close