shalke
(eduard)
1
Hi,
I would like to write an application config in go using flags and then have it output into an .ini file.
I’ve done this with JSON files, but can’t figure out the ini.
Any suggestions?
Ini file will look like so:
Name=*flag input
[Output]
Mode=*flag input
[Input]
BaseCX=*flag input
BaseCY=*flag input
Common=*flag input
Thanks!
lutzhorn
(Lutz Horn)
2
What is the code you use that produces this output?
shalke
(eduard)
3
Its for a 3rd party application. It reads just the ini file.
lutzhorn
(Lutz Horn)
4
No, what code do you use to write the INI file? Is the snippet you pasted above some output your code produces?
shalke
(eduard)
5
That’s the output I need to achieve.
The issue is, no sure where to start and can’t figure out the https://github.com/go-ini/ini package.
lutzhorn
(Lutz Horn)
6
I’ve never used this package before but it looks easy. This Go code
package main
import (
"github.com/go-ini/ini"
)
func main() {
cfg := ini.Empty()
sctInput := cfg.Section("Input")
sctInput.NewKey("Common", "common")
cfg.SaveTo("/tmp/foo.ini")
}
writes this
[Input]
Common = common
to /tmp/foo.ini
.
It should be easy to write the flag values.
1 Like
system
(system)
Closed
8
This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.