Catalog / Go Programming Language Cheatsheet
Go Programming Language Cheatsheet
A concise reference to the Go programming language, covering syntax, data types, control structures, and common libraries, to facilitate quick lookups and efficient coding.
Basics & Syntax
Basic Structure
|
Variables & Data Types
Declaration: |
|
Basic Types: |
|
Constants: |
|
Arrays: |
|
Slices: |
|
Maps: |
|
Control Structures
If-Else: |
|
For Loop: |
|
Range Loop: |
|
Switch: |
|
Functions & Methods
Function Definition
|
Multiple Return Values
Functions can return multiple values. It’s common to return a value and an error. |
Methods
|
Variadic Functions
|
Concurrency
Goroutines
|
Channels
Declaration: |
|
Send: |
|
Receive: |
|
Buffered Channel: |
|
Close Channel: |
|
Select Statement
|
Mutex Locks
Declaration: |
|
Lock: |
|
Unlock: |
|
Standard Library
fmt Package
Printing: |
|
Formatted Printing: |
|
Error Printing: |
|
String Formatting: |
|
net/http Package
|
os Package
Environment Variables: |
|
Command Line Args: |
|
Exit: |
|
io Package
Read from Reader: |
|
Write to Writer: |
|
Copy: |
|