Skip to content

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

Open
@wbhob

Description

@wbhob

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

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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions