hcl

package
v0.9.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 13, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package hcl provides the HCL configuration decoder for CONGA applications.

Register Decode with conga.App.RegisterDecoder to enable HCL configuration support:

app.RegisterDecoder(".hcl", hcl.Decode)

Key Mapping

A top-level HCL attribute matches a flag's config tag as written or, when it has no tag, the flag name spelled in the app's key casing (conga.ConfigKeyCase, kebab-case by default). Other spellings and letter cases are unknown fields:

# config.hcl
http-port = 8080
database-url = "postgres://localhost/db"
max-retries = 5

Blocks decode as nested maps keyed by block type. A labeled block (server "web" { ... }), a repeated block type, and a block that shares its name with an attribute are rejected.

Numbers

Numbers decode to int64, or to uint64 above the int64 range, or to float64 when they have a fraction. HCL keeps a number's value but not its spelling, so a whole number outside both 64-bit integer ranges is rejected whether it was written in full or with an exponent (1e30), as is a number that overflows float64.

Parse and semantic failures (undefined variables) and these rejections wrap ErrParse, and an empty document decodes to an empty map.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrParse indicates a syntax or semantic error in HCL configuration.
	ErrParse = errors.New("hcl parse error")
)

Functions

func Decode

func Decode(data []byte) (map[string]any, error)

Decode decodes HCL bytes into the generic map[string]any structure the configuration engine matches against flag bindings.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL