How to define a map in TOML?
For example, I want to define something like:
[FOO]
Usernames_Passwords='{"user1":"pass1","user2":"pass2"}'
and then in go convert them to a map[string]string
TOML is a file format for configuration files. It is intended to be easy to read and write due to obvious semantics which aim to be "minimal", and is designed to map unambiguously to a dictionary. Its specification is open-source, and receives community contributions.
TOML stands for Tom's Obvious, Minimal Language. It is a data serialisation language designed to be a minimal configuration file format that's easy to read due to obvious semantics.
TOML is case-sensitive. A TOML file must be a valid UTF-8 encoded Unicode document. Whitespace means tab (0x09) or space (0x20).
A TOML file is a configuration file saved in the open source TOML (Tom's Obvious, Minimal Language) file format. It is used to configure the parameters and settings of various software projects. TOML files contain configuration information in key-value pairs and are meant to be more readable than .
You can have maps like this:
name = { first = "Tom", last = "Preston-Werner" }
point = { x = 1, y = 2 }
See: https://github.com/toml-lang/toml#user-content-inline-table
In your case, it looks like you want a password table, or an array of maps. You can make it like this:
[[user_entry]]
name = "user1"
pass = "pass1"
[[user_entry]]
name = "user2"
pass = "pass2"
Or more concisely:
user_entry = [{ name = "user1", pass = "pass1" },
{ name = "user2", pass = "pass2" }]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With