Releases: pelletier/go-toml
v2.3.0
This is the first release built largely with the help of AI coding agents. Highlights include the complete removal of the unsafe package. go-toml is now fully safe Go code, with a geomean overhead of only ~1.4% vs v2.2.4 and zero additional allocations on benchmarks. This release also adds omitzero struct tag support, improves UnmarshalText/Unmarshaler handling for tables and array tables, and fixes several bugs including nil pointer marshaling, leap second handling, and datetime unmarshaling panics.
What's Changed
What's new
- marshal: don't escape quotes unnecessarily by @virtuald in #991
- Add
omitzerotag support by @NathanBaulch in #998 - Support custom IsZero() methods with omitzero tag by @pelletier in #1020
- UnmarshalText fallbacks to struct unmarshaling for tables and arrays by @pelletier in #1026
- [unstable] Support Unmarshaler interface for tables and array tables by @pelletier in #1027
Fixed bugs
- Add missing UnmarshalTOML call by @pelletier in #996
- Handle array table into an empty slice by @pelletier in #997
- Unwrap strict errors by @bersace in #1012
- Fix leap second handling found by fuzz by @pelletier in #1019
- Fix nil pointer map values not being marshaled by @pelletier in #1025
- Fix panic when unmarshaling datetime values to incompatible types (#1028) by @pelletier in #1029
- Fix parser error pointing to wrong line at EOF without trailing newline by @pelletier in #1041
Documentation
- Improve Unmarshaling README by @heckelson in #1016
- Create AGENTS.md guidelines file by @pelletier in #1017
Other changes
- Unsafe package removal by @pelletier in #1021
- Bump CI and test scripts to Go 1.26 by @pelletier in #1030
New Contributors
- @virtuald made their first contribution in #991
- @NathanBaulch made their first contribution in #999
- @bersace made their first contribution in #1012
- @flyn-org made their first contribution in #1013
- @heckelson made their first contribution in #1016
Full Changelog: v2.2.4...v2.3.0
v2.2.4
Highlight
In this release, @mikattack removed the last dependency of go-toml! 🎉 (#981)
What's Changed
Documentation
- Fix typos in comments and tests by @alexandear in #972
Other changes
- Replace
stretchr/testifywith an internal test suite by @mikattack in #981 - Update to go 1.24 by @pelletier in #982
New Contributors
- @alexandear made their first contribution in #972
- @mikattack made their first contribution in #981
Full Changelog: v2.2.3...v2.2.4
v2.2.3
What's Changed
What's new
- Allow
int,uint, andfloatas map keys by @daniel-weisse in #958
Performance
Fixed bugs
- Fix reflect.Pointer backward compatibility by @xxxVitoxxx in #956
Documentation
Other changes
- go.mod: bump minimum language version to 1.21 by @mvdan in #949
- Bump testing to go 1.23 by @pelletier in #961
New Contributors
- @mvdan made their first contribution in #949
- @testwill made their first contribution in #951
- @xxxVitoxxx made their first contribution in #956
Full Changelog: v2.2.2...v2.2.3
v2.2.2
v2.2.1
What's Changed
Fixed bugs
- Encode: fix indentation when marshalling slices as array tables by @daniel-weisse in #944
New Contributors
- @daniel-weisse made their first contribution in #944
Full Changelog: v2.2.0...v2.2.1
v2.2.0
What's Changed
What's new
- Encode: support pointers to embedded structs by @dangra in #924
- Encode: support
json.Numbertype by @dangra in #923 - Decode: unstable/Unmarshal interface by @rszyma in #940
Fixed bugs
- Decode: fix reuse of slice for array tables by @pelletier in #934
Documentation
- Fix typo in README by @jwilk in #925
- Fix indentation of README examples by @rdbo in #928
- Fix marshaler typos by @pelletier in #927
Other changes
- Go 1.22 support by @pelletier in #935
New Contributors
- @dangra made their first contribution in #924
- @jwilk made their first contribution in #925
- @rdbo made their first contribution in #928
- @rszyma made their first contribution in #940
Full Changelog: v2.1.1...v2.2.0
v2.1.1
What's Changed
Fixed bugs
- Fix unmarshaling of nested non-exported struct by @pelletier in #917
New Contributors
Full Changelog: v2.1.0...v2.1.1
v2.1.0
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:
type TLS struct {
Cipher string `toml:"cipher"`
Version string `toml:"version"`
}
type Config struct {
Host string `toml:"host" comment:"Host IP to connect to."`
Port int `toml:"port" comment:"Port of the remote server."`
Tls TLS `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
What's Changed
What's new
- Encoder: add back the commented option by @pelletier in #893
Fixed bugs
- Decode: fix panic when parsing '0' as a float by @ocean2811 in #887
- Encode: fix ignored indent of array tables by @pelletier in #889
- Unstable/parser: add raw to integers by @pelletier in #890
- Decode: improve errors on integers and strings by @pelletier in #891
- Decode: fix wrong indention for comments on tables by @Felixoid in #892
Other changes
- Add support for
Go 1.21by @michalbiesek in #885
New Contributors
- @michalbiesek made their first contribution in #885
- @ocean2811 made their first contribution in #887
Full Changelog: v2.0.9...v2.1.0
v2.0.9
What's Changed
Fixed bugs
- Encode: fix support for arrays by @MrJetBOX in #876
- Decode: assign empty struct to empty defined sections by @dbarrosop in #879
Other changes
- build(deps): bump github.com/stretchr/testify from 1.8.3 to 1.8.4 by @dependabot in #877
New Contributors
- @MrJetBOX made their first contribution in #876
- @dbarrosop made their first contribution in #879
Full Changelog: v2.0.8...v2.0.9
v2.0.8
What's Changed
What's new
- Support MarshalText/UnmarshalText for map keys by @gordon-klotho in #863
- Experimental: comments support in unstable/Parser by @pelletier in #860
Fixed bugs
- Decode: fix decode into unsettable structs by @pelletier in #868
Documentation
- Add example on how to use TextUnmarshaler by @pelletier in #867
New Contributors
- @manunio made their first contribution in #861
- @gordon-klotho made their first contribution in #863
Full Changelog: v2.0.7...v2.0.8