explaingit

a8m/golang-cheat-sheet

8,801Audience · developerComplexity · 1/5Setup · easy

TLDR

A single-page Go language reference with short annotated code examples covering variables, functions, loops, collections, structs, interfaces, errors, and concurrency, for developers coming from another language.

Mindmap

mindmap
  root((Go Cheat Sheet))
    Basics
      Variables and constants
      Functions and returns
      Data types
    Collections
      Arrays and slices
      Maps
    Types
      Structs and interfaces
      Pointers and errors
    Concurrency
      Goroutines
      Channels
Click or tap to explore — scroll the page freely

Code map

Detail Auto

An interactive map of this repo's files and how they connect — its source is parsed live in your browser. Click Visualize to build it.

filefunction / class

Things people build with this

USE CASE 1

Quickly look up Go syntax and idioms while learning the language without reading a full book.

USE CASE 2

Reference how goroutines and channels work when writing concurrent Go code.

USE CASE 3

Compare Go's approach to structs and interfaces against the class-based patterns you know from other languages.

Tech stack

Go

Getting it running

Difficulty · easy Time to first run · 5min

In plain English

This is a reference sheet for the Go programming language, aimed at developers who already know another programming language and want a quick overview of Go's syntax and features without reading through a full tutorial or book. It covers the core language in one long document with short, annotated code examples throughout. The sheet is divided into numbered sections. It starts with the basic building blocks: how to declare variables and constants, how to write functions, and the built-in data types. Go has some distinctive behaviors that the sheet highlights, such as the ability to return multiple values from a single function, a single loop keyword (for) that covers all looping patterns, and uppercase versus lowercase naming as the mechanism for controlling what code is visible outside a package. It then moves into collection types (arrays, slices, and maps), Go's approach to structs and interfaces in place of traditional classes, how Go represents and passes around pointers, and how to work with errors. The final sections cover concurrency, which is one of Go's most talked-about features: goroutines are described as lightweight units of work that can run alongside each other, and channels are the mechanism those goroutines use to pass data between themselves safely. The source material for most of the code examples came from the official Go Tour, which is an interactive introduction maintained by the Go team itself. The README credits that tour and recommends newcomers start there rather than with this sheet. The repository is a single reference document with no software to install or run. It is useful for quick lookups once you have some Go familiarity, not as a first introduction to programming concepts. No license is specified in the README.

Copy-paste prompts

Prompt 1
Based on the golang-cheat-sheet, show me a Go example that uses goroutines and channels to process a list of URLs concurrently.
Prompt 2
Using the patterns from the golang-cheat-sheet, write a Go function that returns multiple values including an error.
Prompt 3
Show me how Go's for loop replaces while, do-while, and range-based loops using the patterns from the golang-cheat-sheet.
Prompt 4
Write a Go struct with methods and an interface, following the conventions described in the golang-cheat-sheet.
Open on GitHub → Explain another repo

← a8m on gitmyhub — every repo by this author, as a profile.

Verify against the repo before relying on details.