You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This new minor release brings back the commented struct field tag from go-toml v1. It makes it easier to generate default or example configuration files. For instance:
typeTLSstruct {
Cipherstring`toml:"cipher"`Versionstring`toml:"version"`
}
typeConfigstruct {
Hoststring`toml:"host" comment:"Host IP to connect to."`Portint`toml:"port" comment:"Port of the remote server."`TlsTLS`toml:"TLS,commented" comment:"Encryption parameters (optional)"`
}
example:=Config{
Host: "127.0.0.1",
Port: 4242,
Tls: TLS{
Cipher: "AEAD-AES128-GCM-SHA256",
Version: "TLS 1.3",
},
}
out, err:=toml.Marshal(example)
generates this TOML document:
# Host IP to connect to.host = '127.0.0.1'# Port of the remote server.port = 4242# Encryption parameters (optional)# [TLS]# cipher = 'AEAD-AES128-GCM-SHA256'# version = 'TLS 1.3'
This feature was often mentioned as a blocker to upgrading from go-toml v1. Hopefully bringing it back in scope will help folks make the transition!
An other noteworthy improvement is on type mismatch errors. They now include the human-readable context, and include the struct field name of the faulty value if applicable.
Before:
toml: cannot store TOML string into a Go int
After:
1| [server]
2| path = "/my/path"
3| port = "bad"
| ~~~~~ cannot decode TOML string into struct field toml_test.Server.Port of type int
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
This new minor release brings back the
commented
struct field tag from go-toml v1. It makes it easier to generate default or example configuration files. For instance:generates this TOML document:
This feature was often mentioned as a blocker to upgrading from go-toml v1. Hopefully bringing it back in scope will help folks make the transition!
An other noteworthy improvement is on type mismatch errors. They now include the human-readable context, and include the struct field name of the faulty value if applicable.
Before:
After:
What's Changed
What's new
Fixed bugs
Other changes
Go 1.21
by @michalbiesek in Add support forGo 1.21
#885New Contributors
Go 1.21
#885Full Changelog: v2.0.9...v2.1.0
This discussion was created from the release v2.1.0.
Beta Was this translation helpful? Give feedback.
All reactions