From 88dcc90dde05844cd2b0b5353776429b766e475a Mon Sep 17 00:00:00 2001 From: Mitar Date: Wed, 22 Dec 2021 16:10:11 +0100 Subject: [PATCH] Document nested data structure. --- README.md | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/README.md b/README.md index fa8624c..de49d9b 100644 --- a/README.md +++ b/README.md @@ -384,6 +384,21 @@ var CLI struct { For flags, multiple key+value pairs should be separated by `mapsep:"rune"` tag (defaults to `;`) eg. `--set="key1=value1;key2=value2"`. +## Nested data structure + +Kong support a nested data structure as well with `embed:""`. You can combine `embed:""` with `prefix:""`: + +```go +var CLI struct { + Logging struct { + Level string `enum:"debug,info,warn,error" default:"info"` + Type string `enum:"json,console" default:"console"` + } `embed:"" prefix:"logging."` +} +``` + +This configures Kong to accept flags `--logging.level` and `--logging.type`. + ## Custom named decoders Kong includes a number of builtin custom type mappers. These can be used by