Ini file output


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

Mode=*flag input

BaseCX=*flag input
BaseCY=*flag input
Common=*flag input


What is the code you use that produces this output?

Its for a 3rd party application. It reads just the ini file.

No, what code do you use to write the INI file? Is the snippet you pasted above some output your code produces?

That’s the output I need to achieve.

The issue is, no sure where to start and can’t figure out the package.

I’ve never used this package before but it looks easy. This Go code

package main

import (

func main() {
	cfg := ini.Empty()

	sctInput := cfg.Section("Input")
	sctInput.NewKey("Common", "common")


writes this

Common = common

to /tmp/foo.ini.

It should be easy to write the flag values.

1 Like

Awesome, thank! Works!

1 Like

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.