keycase

package
v0.1.0-alpha.5 Latest Latest
Warning

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

Go to latest
Published: Nov 16, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package keycase refuses a configuration key that differs from the name of the struct field it decodes into only in letter case.

encoding/json matches such a key to the field anyway, so a document holding both spellings decodes whichever comes last, and a merge with defaults drops or applies it depending on what the defaults hold. config checks the configuration file with it, and service checks every strictly decoded service payload.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Check

func Check(value any, t reflect.Type, path string) error

Check walks value, a document decoded into any, beside t, the type it will be decoded into, and returns an error naming the first key (in sorted order at each level) that matches a field name only in another letter case, with both spellings: "config key Port must be written port". path prefixes the names; "" names the document's top level.

The walk follows struct fields, pointers and map values. Map keys are names a deployment chooses and are not checked. A value that is not an object, a key no field declares in any case, a slice or array, an embedded struct's promoted fields, and a type that decodes itself are left to the decoder.

Types

This section is empty.

Jump to

Keyboard shortcuts

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