← All notes

Go constant: values for untyped Go constants and their operations

Answer: The go/constant package represents untyped Go constants and the operations defined on them, including a special Unknown value.

Values and kinds

A Value stands for an untyped Go constant. Kinds include Bool, String, Int, Float, Complex, and Unknown.

Unknown is used when a value cannot be represented precisely, for example when a number is too large. Operations on unknown values yield unknown values unless the docs say otherwise.

When possible, the smaller, or more precise for floats, representation is chosen.

Operations

Compare requires that the comparison must be defined for the operands.

If the result is not exact, its value is undefined. For an Unknown x, that computed result is 0.

See also

Claims

Sources

License: this note is CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Summary by iinventedlight (AI-assisted). Sources: The Go Authors, go/constant; The Go Authors, go/constant source. BSD-3-Clause (https://go.dev/LICENSE). Copyright The Go Authors. Text was condensed and changed from the originals.

License: CC-BY-4.0 · Summary by iinventedlight (AI-assisted). Sources: The Go Authors, go/constant; The Go Authors, go/constant source. BSD-3-Clause (https://go.dev/LICENSE). Copyright The Go Authors.

Cite this

Permanent ID: iil:note:em8hcfnk

iinventedlight. 2026. "Go constant: values for untyped Go constants and their operations." iinventedlight Library, iil:note:em8hcfnk, version of 2026-11-26. https://iinventedlight.com/library/notes/go-constant/. License: CC-BY-4.0.

@misc{iil_note_em8hcfnk,
  author = {{iinventedlight}},
  title = {{Go constant: values for untyped Go constants and their operations}},
  howpublished = {iinventedlight Library},
  year = {2026},
  date = {2026-11-26},
  url = {https://iinventedlight.com/library/notes/go-constant/},
  note = {Permanent ID iil:note:em8hcfnk. License: CC-BY-4.0.},
}

Markdown

Spotted a mistake? Use the MCP feedback tool or email hello@iinventedlight.com. Or Report a correction (no account needed).

Extra files beside this note

These files use this note's license, shown below. Paper extras retain their reproduction status; a link is not a reproduction.

All artifact files (JSON index)

For language models and agents: start at /llms.txt | /agents.md | /.well-known/agent-library.json. This page in Markdown: /library/notes/go-constant.md.