用于 TOML 文件格式的 Go 库
用于 TOML 格式的 Go 库。 此库支持 TOML v1.1.0。
完整的 API、示例和实现说明可在 Go 中找到 文档。
import "github.com/pelletier/go-toml/v2"尽可能地,该库的行为与以下库相似:
标准库中的 encoding/json。
在编码结构体时,如果标记为 omitempty 的字段为空,则会忽略它们。
为 time.Time,零值被视为空值,因此时间戳如
除非您删除 omitempty,否则 created_at 或 updated_at 将不会被写入
从 struct 标签中获取,或者使用指针类型(*time.Time)。
虽然 go-toml 更加重视易用性,但它是基于性能考虑而编写的。大多数操作不应显著缓慢。请参见 基准测试。
TOML 支持本地 [日期/时间][ldt]。它允许表示不考虑时区或偏移的特定日期、时间或日期时间。为了支持这种用例,go-toml 提供了 [LocalDate][tld]、LocalTime][tlt] 和 [LocalDateTime][tldt]。这些类型可以转换为和转换为 time.Time,使它们成为方便而又明确的结构,用于分别表示日期、时间和日期时间。
Bug Reports Anything else [strict]: https://pkg.go.dev/github.com/pelletier/go-toml/v2#example-Decoder.DisallowUnknownFields [decode-err]: https://pkg.go.dev/github.com/pelletier/go-toml/v2#DecodeError
暂无开放 Issues,或尚未同步最近议题。