Hello World
1 | package main |
Values
1 | package main |
Variables
1 | package main |
Constants
1 | package main |
For
1 | package main |
If / Else
1 | package main |
Switch
1 | package main |
Arrays
1 | package main |
Slices
1 | package main |
Maps
1 | package main |
Range
1 | package main |
Functions
1 | package main |
Multiple Return Values
1 | package main |
Variadic Functions
1 | package main |
Closures
1 | package main |
Recursion
1 | package main |
Pointers
1 | package main |
Structs
1 | package main |
Methods
1 | package main |
Interfaces
1 | package main |
Errors
1 | package main |
Goroutines
1 | package main |
Channels
1 | package main |
Channel Buffering
1 | package main |
Channel Synchronization
1 | package main |
Channel Directions
1 | package main |
Select
1 | package main |
Timeouts
1 | package main |
Non-Blocking Channel Operations
1 | package main |
Closing Channels
1 | package main |
Range over Channels
1 | package main |
Timers
1 | package main |
Tickers
1 | package main |
Worker Pools
1 | package main |
Rate Limiting
1 | package main |
Atomic Counters
1 | package main |
Mutexes
1 | package main |
Stateful Goroutines
1 | package main |
Sorting
1 | package main |
Sorting by Functions
1 | package main |
Panic
1 | package main |
Defer
1 | package main |
Collection Functions
1 | package main |
String Functions
1 | package main |
String Formatting
1 | package main |
Regular Expressions
1 | package main |
JSON
1 | package main |
Time
1 | package main |
Epoch
1 | package main |
Time Formatting / Parsing
1 | package main |
In this Case:1609-09-12 19:02:35 PM +03:00 Sep Sat PDT
Type | Placeholder | Value |
---|---|---|
Year | 2006 | 1609 |
Year | 06 | 09 |
Month | 01 | 09 |
Month | 1 | 9 |
Month | Jan | Sep |
Month | January | September |
Day | 02 | 12 |
Day | 2 | 12 |
Week day | Mon | Sat |
Week day | Monday | Saturday |
Hours | 03 | 07 |
Hours | 3 | 7 |
Hours | 15 | 19 |
Minutes | 04 | 02 |
Minutes | 4 | 2 |
Seconds | 05 | 35 |
Seconds | 5 | 35 |
AM or PM | PM | PM |
Milliseconds | .000 | .123 |
Microseconds | .000000 | .123456 |
Nanoseconds | .000000000 | .123456789 |
Timezone offset | -0700 | +0300 |
Timezone offset | -07:00 | +03:00 |
Timezone offset | Z0700 | +0300 |
Timezone offset | Z07:00 | +03:00 |
Timezone | MST | PDT |
Random Numbers
1 | package main |
Number Parsing
1 | package main |
URL Parsing
1 | package main |
SHA1 Hashes
1 | package main |
Base64 Encoding
1 | package main |
Reading Files
1 | echo 'hello' > /tmp/dat |
1 | package main |
Writing Files
1 | package main |
1 | cat /tmp/dat1 |
Line Filters
1 | echo 'hello' > /tmp/lines |
1 | package main |
Command-Line Arguments
1 | go build command-line-arguments.go |
1 | package main |
Command-Line Flags
1 | package main |
1 | go build command-line-flags.go |
Environment Variables
1 | package main |
1 | go run environment-variables.go |
Spawning Processes
1 | package main |
Exec'ing Processes
1 | package main |
Signals
1 | package main |
Exit
1 | package main |