ini icon indicating copy to clipboard operation
ini copied to clipboard

ini keys with `:` in the key name get wrapped in backticks (`)

Open wbhob opened this issue 1 year ago • 0 comments

Version

v1.67.0

Describe the bug

If a section key contains a : symbol and you try to deserialize from a struct, the resulting key in the ini file is wrapped in backticks (`). My use case is that I am programmatically editing a Samba configuration file, and I do not have control over the definitions.

To reproduce

type Global struct {
	VfsObjects             string `ini:"vfs objects"`            
	FruitMetadata          string `ini:"fruit:metadata"`     
}

var path = "/etc/samba/smb.conf"

func main()  {
	global := &Global{
		VfsObjects:    "catia fruit streams_xattr",
		FruitMetadata: "stream",
	}
        file, _ := ini.Load(path)
        file.Section("global").ReflectFrom(global)
        file.Save(path)
}

cating the path prints:

[global]
vfs objects      = catia fruit streams_xattr
`fruit:metadata` = stream

Expected behavior

I would expect it to write:

[global]
vfs objects    = catia fruit streams_xattr
fruit:metadata = stream

Additional context

Here's more information about Samba and the Smb Conf file: https://www.samba.org/samba/docs/4.9/man-html/smb.conf.5.html

Code of Conduct

  • [X] I agree to follow this project's Code of Conduct

wbhob avatar Oct 01 '24 22:10 wbhob