go-hocon

HOCON (Typesafe Config) parser in pure Go โ€” substitutions, includes, units, a JSON superset.

pure Go ยท zero cgo JSON superset ${โ€ฆ} substitutions include deep merge += self-append duration / size units typed getters 100% coverage 6 arches + wasm
Documentation GitHub
Documentation (MkDocs Material + mike) License: BSD-3-Clause Go 1.26.4+ Coverage 100%

go-hocon is a pure-Go (CGO_ENABLED=0) parser for HOCON, the Human-Optimized Config Object Notation used by Typesafe Config. HOCON is a superset of JSON that adds unquoted keys and strings, = as an alias for :, optional commas and root braces, # and // comments, dotted-path keys, deep merging of duplicate keys, array and value concatenation, ${path} / ${?path} substitutions with environment fallback, += self-append, include directives and duration / size unit suffixes. Includes and environment lookups run through injectable seams, so callers and tests never need touch the filesystem or process environment. Typed accessors read dotted paths and Render serialises back to HOCON or JSON. Standard library only, 100% coverage, six arches and WebAssembly.

Lexer & parser ready

Unquoted keys and strings, = / :, optional commas and root braces, # and // comments, dotted-path keys, triple-quoted strings and unicode escapes โ€” the full HOCON surface over JSON.

Merging & concatenation ready

Deep object merge of duplicate keys, array and value concatenation, and += self-append, applied as the tree is built.

Substitutions ready

${path} and optional ${?path} substitutions with environment fallback and self-reference, resolved after the whole tree is assembled.

Includes & environment seams ready

include directives and environment lookups run through injectable WithIncludeResolver / WithEnv seams โ€” no filesystem or process environment needed, in production or in tests.

Typed access & rendering ready

GetString / GetInt / GetFloat / GetBool / GetDuration / GetBytes / GetList / GetObject / GetOrElse / HasPath over dotted paths, WithFallback, and Render back to HOCON or JSON.

The HOCON parsing engine of the go-hocon org: lex, parse, merge, resolve and render, all in dependency-free pure Go with injectable include / environment seams, validated against the reference puppetlabs/ruby-hocon gem. Part of a wider family of pure-Go config/data-format engines alongside go-eyaml and go-augeas.