Comments (3)
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)
from ini.
@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
from ini.
@unknwon somehow section mapping via tags, as described by @rpieczon isn't working anymore.
Could you please give an advice what I'm missing.
This issue is a feature request, which means what's been descried is something missing :)
from ini.
Related Issues (20)
- Append() get file already closed when trying to append a second io.Reader HOT 1
- Allow NonUniqueSections not working for Embedded Structs
- If the configuration item of my ini configuration file contains #, it will cause an error in reading the configuration. HOT 4
- Able to set incremental keys HOT 1
- 无法创建一个新的键? HOT 1
- "=" character not escaped properly HOT 1
- key prefixes
- Serialization for arrays of rune not a possibility?
- API Documentation link is not working
- Marshal and unmarshal functions
- same-key-with-multiple-values demo result is not correct
- DeleteKey not work
- Add line number and column output to error HOT 2
- Allow empty key values
- Fail to read file: key-value delimiter not found: }
- SaveTo without Indentation
- semicolon issue
- Error parse values
- using []string in a struct goes wrong if any of the strings contains a comma ','
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ini.