Code2Img

Go code screenshots.

How to screenshot Go code properly: what Go snippets actually look like, how auto-detection behaves, the theme that reads best, and the settings that keep the card legible.

What people actually paste

Go is the least colourful of the ten languages and that is the whole design problem: keywords (func, type, range, defer, chan), a handful of builtins, and then long stretches of identifiers. What people paste is idiomatic Go — func (s Server) handle(w http.ResponseWriter, r http.Request), an error check on the very next line, and a struct definition with backtick tags (json:"name,omitempty"). Struct tags are the one genuinely Go-specific visual element: a backtick string inside a type declaration that a generic highlighter will render as one anonymous string blob.

How auto-detection behaves

Go is rule 3, behind Python and Ruby but ahead of everything else. Three triggers: a line starting package main, func name(, or the short variable declaration :=. The := rule is the broad one and it is why Go usually wins even on a fragment with no package clause. Two real misses: a snippet that is only a struct with tags (no func, no :=) has no Go shape to match, so it falls through to the typescript default; and a Go fragment pasted without the package line plus a var block instead of := can land on JavaScript. Nice edge case in the other direction: := inside a Python walrus snippet is harmless, because the Python rule already fired.

Theme that reads best

github-dark is the right default for Go precisely because it is quiet: few saturated hues means the reader's eye goes to the identifiers, which is where the information is. github-light mirrors it for docs. Avoid synthwave-84 here — it makes a language with four token classes look like a graphics demo and the card stops communicating code.

Three tips

Other languages

The same advice, for the languages people paste most.

How Code2Img compares

Feature by feature, against the other code screenshot tools.