-
Notifications
You must be signed in to change notification settings - Fork 371
New issue
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
Reflect From Struct - section name configuration for root level properties #325
Labels
feature
Categorizes as related to a new feature
Comments
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) |
@unknwon somehow section mapping via tags, as described by @rpieczon isn't working anymore. 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: [section2] Given output: |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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: