From e9ecd9d60fa194607f464ab90760abd43975360e Mon Sep 17 00:00:00 2001 From: Christophe de Vienne Date: Thu, 12 Dec 2019 11:31:18 +0100 Subject: [PATCH] IniParser: write 'func' options with "ini-name" If a 'ini-name' tag is set on the option, write it to file even if the option is a function. --- ini.go | 2 +- ini_test.go | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/ini.go b/ini.go index e714d3d..84ba5c3 100644 --- a/ini.go +++ b/ini.go @@ -216,7 +216,7 @@ func writeGroupIni(cmd *Command, group *Group, namespace string, writer io.Write comments := (options & IniIncludeComments) != IniNone for _, option := range group.options { - if option.isFunc() || option.Hidden { + if option.Hidden || option.isFunc() && len(option.tag.Get("ini-name")) == 0 { continue } diff --git a/ini_test.go b/ini_test.go index ad4852e..7de78b0 100644 --- a/ini_test.go +++ b/ini_test.go @@ -49,6 +49,9 @@ int-map = b:3 verbose = true verbose = true +; Call phone number +call = + ; A slice of pointers to string ; PtrSlice = @@ -113,6 +116,9 @@ Opt = ; Show verbose debug information ; verbose = +; Call phone number +; call = + ; A slice of pointers to string ; PtrSlice = @@ -176,6 +182,9 @@ EnvDefault2 = env-def ; Show verbose debug information ; verbose = +; Call phone number +; call = + ; A slice of pointers to string ; PtrSlice =