Targets · Go · Reserved words

Reserved words

Go keeps a set of words for its own syntax, so a program cannot use them as names. When a Program name collides with one, the renderer appends a single underscore — type becomes type_ — so the program keeps the name it chose and the output still compiles. Because _ is illegal in a Program identifier, the escape can never collide with a name a program actually chose.

Contents

How a Program becomes Go, in parts. Start with the introduction, then follow each part into the rendered output and the runtime it links against.

The full list

Every word Go reserves, with the identifier a colliding Program name is escaped to. The rule is uniform — append a single _:

Reserved wordRendered identifier
breakbreak_
casecase_
chanchan_
constconst_
continuecontinue_
defaultdefault_
deferdefer_
elseelse_
fallthroughfallthrough_
forfor_
funcfunc_
gogo_
gotogoto_
ifif_
importimport_
interfaceinterface_
mapmap_
packagepackage_
rangerange_
returnreturn_
selectselect_
structstruct_
switchswitch_
typetype_
varvar_