We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Let me configure dedicated section for each structure's root level property. Currently all root level properties goes into 'DEFAULT' section.
type SampleStruct struct { Property1 string `ini:"section1#prop1"` Property2 string `ini:"section2#prop2"` }
input := SampleStruct{ Property1: "value1", Property2: "value2", } file := ini.Empty() ini.ReflectFrom(file, &input) cfg.WriteTo(os.Stdout)
Would generate:
[section1] prop1: value1 [section2] prop2: value2
type SampleStruct struct { Property1 string `ini:"prop1" section:"section1"` Property2 string `ini:"prop2" section:"section2"` }
No response
The text was updated successfully, but these errors were encountered:
Hey, if you just want to change the section for the entire struct, you can do:
file := ini.Empty() -ini.ReflectFrom(file, &input) +file.Section("section1").ReflectFrom(&input)
Sorry, something went wrong.
@unknwon somehow section mapping via tags, as described by @rpieczon isn't working anymore. Could you please give an advice what I'm missing.
Example code:
type Teststruct struct { Prop1 `ini:"prop1" section:"section1"` Prop2 `ini:"prop2" section:"section2"` } func (tst *Teststruct) MarshalINI() ([]byte, error) { file := ini.Empty() err := file.ReflectFrom(tst) if err != nil { return nil, err } buf := bytes.NewBuffer(nil) _, err = file.WriteTo(buf) if err != nil { return nil, err } return buf.Bytes(), nil }
Expected output: [section1] prop1 = val1
[section2] prop2 = val2
Given output: prop1 = val1 prop2 = val2
This issue is a feature request, which means what's been descried is something missing :)
No branches or pull requests
Describe the feature
Let me configure dedicated section for each structure's root level property.
Currently all root level properties goes into 'DEFAULT' section.
Describe the solution you'd like
Would generate:
Describe alternatives you've considered
Additional context
No response
Code of Conduct
The text was updated successfully, but these errors were encountered: