{"id":13413947,"url":"https://github.com/pelletier/go-toml","last_synced_at":"2025-05-13T15:06:33.921Z","repository":{"id":7101733,"uuid":"8393979","full_name":"pelletier/go-toml","owner":"pelletier","description":"Go library for the TOML file format","archived":false,"fork":false,"pushed_at":"2025-04-07T14:17:10.000Z","size":2325,"stargazers_count":1805,"open_issues_count":29,"forks_count":215,"subscribers_count":28,"default_branch":"v2","last_synced_at":"2025-05-03T07:55:05.337Z","etag":null,"topics":["go","golang","hacktoberfest","toml","toml-parsing"],"latest_commit_sha":null,"homepage":"https://github.com/pelletier/go-toml","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/pelletier.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2013-02-24T17:45:51.000Z","updated_at":"2025-05-03T07:00:54.000Z","dependencies_parsed_at":"2024-03-19T17:56:06.887Z","dependency_job_id":"2829c00b-a1d3-4420-9839-f1ae987f9d7b","html_url":"https://github.com/pelletier/go-toml","commit_stats":{"total_commits":803,"total_committers":98,"mean_commits":8.193877551020408,"dds":0.4308841843088418,"last_synced_commit":"923b2ab4787c6297011a37d73c4e0ca1a051747d"},"previous_names":[],"tags_count":56,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pelletier%2Fgo-toml","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pelletier%2Fgo-toml/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pelletier%2Fgo-toml/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pelletier%2Fgo-toml/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pelletier","download_url":"https://codeload.github.com/pelletier/go-toml/tar.gz/refs/heads/v2","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252553195,"owners_count":21766849,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["go","golang","hacktoberfest","toml","toml-parsing"],"created_at":"2024-07-30T20:01:53.417Z","updated_at":"2025-05-05T18:33:38.212Z","avatar_url":"https://github.com/pelletier.png","language":"Go","funding_links":[],"categories":["Go","Text Processing","开源类库","文本处理","Open source library","Template Engines","Repositories","Bot Building","Specific Formats","文本处理`解析和操作文本的代码库`"],"sub_categories":["Markup Languages","配置","标记语言","Construction","查询语","HTTP Clients"],"readme":"# go-toml v2\n\nGo library for the [TOML](https://toml.io/en/) format.\n\nThis library supports [TOML v1.0.0](https://toml.io/en/v1.0.0).\n\n[🐞 Bug Reports](https://github.com/pelletier/go-toml/issues)\n\n[💬 Anything else](https://github.com/pelletier/go-toml/discussions)\n\n## Documentation\n\nFull API, examples, and implementation notes are available in the Go\ndocumentation.\n\n[![Go Reference](https://pkg.go.dev/badge/github.com/pelletier/go-toml/v2.svg)](https://pkg.go.dev/github.com/pelletier/go-toml/v2)\n\n## Import\n\n```go\nimport \"github.com/pelletier/go-toml/v2\"\n```\n\nSee [Modules](#Modules).\n\n## Features\n\n### Stdlib behavior\n\nAs much as possible, this library is designed to behave similarly as the\nstandard library's `encoding/json`.\n\n### Performance\n\nWhile go-toml favors usability, it is written with performance in mind. Most\noperations should not be shockingly slow. See [benchmarks](#benchmarks).\n\n### Strict mode\n\n`Decoder` can be set to \"strict mode\", which makes it error when some parts of\nthe TOML document was not present in the target structure. This is a great way\nto check for typos. [See example in the documentation][strict].\n\n[strict]: https://pkg.go.dev/github.com/pelletier/go-toml/v2#example-Decoder.DisallowUnknownFields\n\n### Contextualized errors\n\nWhen most decoding errors occur, go-toml returns [`DecodeError`][decode-err],\nwhich contains a human readable contextualized version of the error. For\nexample:\n\n```\n1| [server]\n2| path = 100\n |        ~~~ cannot decode TOML integer into struct field toml_test.Server.Path of type string\n3| port = 50\n```\n\n[decode-err]: https://pkg.go.dev/github.com/pelletier/go-toml/v2#DecodeError\n\n### Local date and time support\n\nTOML supports native [local date/times][ldt]. It allows to represent a given\ndate, time, or date-time without relation to a timezone or offset. To support\nthis use-case, go-toml provides [`LocalDate`][tld], [`LocalTime`][tlt], and\n[`LocalDateTime`][tldt]. Those types can be transformed to and from `time.Time`,\nmaking them convenient yet unambiguous structures for their respective TOML\nrepresentation.\n\n[ldt]: https://toml.io/en/v1.0.0#local-date-time\n[tld]: https://pkg.go.dev/github.com/pelletier/go-toml/v2#LocalDate\n[tlt]: https://pkg.go.dev/github.com/pelletier/go-toml/v2#LocalTime\n[tldt]: https://pkg.go.dev/github.com/pelletier/go-toml/v2#LocalDateTime\n\n### Commented config\n\nSince TOML is often used for configuration files, go-toml can emit documents\nannotated with [comments and commented-out values][comments-example]. For\nexample, it can generate the following file:\n\n```toml\n# Host IP to connect to.\nhost = '127.0.0.1'\n# Port of the remote server.\nport = 4242\n\n# Encryption parameters (optional)\n# [TLS]\n# cipher = 'AEAD-AES128-GCM-SHA256'\n# version = 'TLS 1.3'\n```\n\n[comments-example]: https://pkg.go.dev/github.com/pelletier/go-toml/v2#example-Marshal-Commented\n\n## Getting started\n\nGiven the following struct, let's see how to read it and write it as TOML:\n\n```go\ntype MyConfig struct {\n\tVersion int\n\tName    string\n\tTags    []string\n}\n```\n\n### Unmarshaling\n\n[`Unmarshal`][unmarshal] reads a TOML document and fills a Go structure with its\ncontent. For example:\n\n```go\ndoc := `\nversion = 2\nname = \"go-toml\"\ntags = [\"go\", \"toml\"]\n`\n\nvar cfg MyConfig\nerr := toml.Unmarshal([]byte(doc), \u0026cfg)\nif err != nil {\n\tpanic(err)\n}\nfmt.Println(\"version:\", cfg.Version)\nfmt.Println(\"name:\", cfg.Name)\nfmt.Println(\"tags:\", cfg.Tags)\n\n// Output:\n// version: 2\n// name: go-toml\n// tags: [go toml]\n```\n\n[unmarshal]: https://pkg.go.dev/github.com/pelletier/go-toml/v2#Unmarshal\n\n### Marshaling\n\n[`Marshal`][marshal] is the opposite of Unmarshal: it represents a Go structure\nas a TOML document:\n\n```go\ncfg := MyConfig{\n\tVersion: 2,\n\tName:    \"go-toml\",\n\tTags:    []string{\"go\", \"toml\"},\n}\n\nb, err := toml.Marshal(cfg)\nif err != nil {\n\tpanic(err)\n}\nfmt.Println(string(b))\n\n// Output:\n// Version = 2\n// Name = 'go-toml'\n// Tags = ['go', 'toml']\n```\n\n[marshal]: https://pkg.go.dev/github.com/pelletier/go-toml/v2#Marshal\n\n## Unstable API\n\nThis API does not yet follow the backward compatibility guarantees of this\nlibrary. They provide early access to features that may have rough edges or an\nAPI subject to change.\n\n### Parser\n\nParser is the unstable API that allows iterative parsing of a TOML document at\nthe AST level. See https://pkg.go.dev/github.com/pelletier/go-toml/v2/unstable.\n\n## Benchmarks\n\nExecution time speedup compared to other Go TOML libraries:\n\n\u003ctable\u003e\n\t\u003cthead\u003e\n\t\t\u003ctr\u003e\u003cth\u003eBenchmark\u003c/th\u003e\u003cth\u003ego-toml v1\u003c/th\u003e\u003cth\u003eBurntSushi/toml\u003c/th\u003e\u003c/tr\u003e\n\t\u003c/thead\u003e\n\t\u003ctbody\u003e\n\t\t\u003ctr\u003e\u003ctd\u003eMarshal/HugoFrontMatter-2\u003c/td\u003e\u003ctd\u003e1.9x\u003c/td\u003e\u003ctd\u003e2.2x\u003c/td\u003e\u003c/tr\u003e\n\t\t\u003ctr\u003e\u003ctd\u003eMarshal/ReferenceFile/map-2\u003c/td\u003e\u003ctd\u003e1.7x\u003c/td\u003e\u003ctd\u003e2.1x\u003c/td\u003e\u003c/tr\u003e\n\t\t\u003ctr\u003e\u003ctd\u003eMarshal/ReferenceFile/struct-2\u003c/td\u003e\u003ctd\u003e2.2x\u003c/td\u003e\u003ctd\u003e3.0x\u003c/td\u003e\u003c/tr\u003e\n\t\t\u003ctr\u003e\u003ctd\u003eUnmarshal/HugoFrontMatter-2\u003c/td\u003e\u003ctd\u003e2.9x\u003c/td\u003e\u003ctd\u003e2.7x\u003c/td\u003e\u003c/tr\u003e\n\t\t\u003ctr\u003e\u003ctd\u003eUnmarshal/ReferenceFile/map-2\u003c/td\u003e\u003ctd\u003e2.6x\u003c/td\u003e\u003ctd\u003e2.7x\u003c/td\u003e\u003c/tr\u003e\n\t\t\u003ctr\u003e\u003ctd\u003eUnmarshal/ReferenceFile/struct-2\u003c/td\u003e\u003ctd\u003e4.6x\u003c/td\u003e\u003ctd\u003e5.1x\u003c/td\u003e\u003c/tr\u003e\n\t \u003c/tbody\u003e\n\u003c/table\u003e\n\u003cdetails\u003e\u003csummary\u003eSee more\u003c/summary\u003e\n\u003cp\u003eThe table above has the results of the most common use-cases. The table below\ncontains the results of all benchmarks, including unrealistic ones. It is\nprovided for completeness.\u003c/p\u003e\n\n\u003ctable\u003e\n\t\u003cthead\u003e\n\t\t\u003ctr\u003e\u003cth\u003eBenchmark\u003c/th\u003e\u003cth\u003ego-toml v1\u003c/th\u003e\u003cth\u003eBurntSushi/toml\u003c/th\u003e\u003c/tr\u003e\n\t\u003c/thead\u003e\n\t\u003ctbody\u003e\n\t\t\u003ctr\u003e\u003ctd\u003eMarshal/SimpleDocument/map-2\u003c/td\u003e\u003ctd\u003e1.8x\u003c/td\u003e\u003ctd\u003e2.7x\u003c/td\u003e\u003c/tr\u003e\n\t\t\u003ctr\u003e\u003ctd\u003eMarshal/SimpleDocument/struct-2\u003c/td\u003e\u003ctd\u003e2.7x\u003c/td\u003e\u003ctd\u003e3.8x\u003c/td\u003e\u003c/tr\u003e\n\t\t\u003ctr\u003e\u003ctd\u003eUnmarshal/SimpleDocument/map-2\u003c/td\u003e\u003ctd\u003e3.8x\u003c/td\u003e\u003ctd\u003e3.0x\u003c/td\u003e\u003c/tr\u003e\n\t\t\u003ctr\u003e\u003ctd\u003eUnmarshal/SimpleDocument/struct-2\u003c/td\u003e\u003ctd\u003e5.6x\u003c/td\u003e\u003ctd\u003e4.1x\u003c/td\u003e\u003c/tr\u003e\n\t\t\u003ctr\u003e\u003ctd\u003eUnmarshalDataset/example-2\u003c/td\u003e\u003ctd\u003e3.0x\u003c/td\u003e\u003ctd\u003e3.2x\u003c/td\u003e\u003c/tr\u003e\n\t\t\u003ctr\u003e\u003ctd\u003eUnmarshalDataset/code-2\u003c/td\u003e\u003ctd\u003e2.3x\u003c/td\u003e\u003ctd\u003e2.9x\u003c/td\u003e\u003c/tr\u003e\n\t\t\u003ctr\u003e\u003ctd\u003eUnmarshalDataset/twitter-2\u003c/td\u003e\u003ctd\u003e2.6x\u003c/td\u003e\u003ctd\u003e2.7x\u003c/td\u003e\u003c/tr\u003e\n\t\t\u003ctr\u003e\u003ctd\u003eUnmarshalDataset/citm_catalog-2\u003c/td\u003e\u003ctd\u003e2.2x\u003c/td\u003e\u003ctd\u003e2.3x\u003c/td\u003e\u003c/tr\u003e\n\t\t\u003ctr\u003e\u003ctd\u003eUnmarshalDataset/canada-2\u003c/td\u003e\u003ctd\u003e1.8x\u003c/td\u003e\u003ctd\u003e1.5x\u003c/td\u003e\u003c/tr\u003e\n\t\t\u003ctr\u003e\u003ctd\u003eUnmarshalDataset/config-2\u003c/td\u003e\u003ctd\u003e4.1x\u003c/td\u003e\u003ctd\u003e2.9x\u003c/td\u003e\u003c/tr\u003e\n\t\t\u003ctr\u003e\u003ctd\u003egeomean\u003c/td\u003e\u003ctd\u003e2.7x\u003c/td\u003e\u003ctd\u003e2.8x\u003c/td\u003e\u003c/tr\u003e\n\t \u003c/tbody\u003e\n\u003c/table\u003e\n\u003cp\u003eThis table can be generated with \u003ccode\u003e./ci.sh benchmark -a -html\u003c/code\u003e.\u003c/p\u003e\n\u003c/details\u003e\n\n## Modules\n\ngo-toml uses Go's standard modules system.\n\nInstallation instructions:\n\n- Go ≥ 1.16: Nothing to do. Use the import in your code. The `go` command deals\n  with it automatically.\n- Go ≥ 1.13: `GO111MODULE=on go get github.com/pelletier/go-toml/v2`.\n\nIn case of trouble: [Go Modules FAQ][mod-faq].\n\n[mod-faq]: https://github.com/golang/go/wiki/Modules#why-does-installing-a-tool-via-go-get-fail-with-error-cannot-find-main-module\n\n## Tools\n\nGo-toml provides three handy command line tools:\n\n * `tomljson`: Reads a TOML file and outputs its JSON representation.\n\n\t```\n\t$ go install github.com/pelletier/go-toml/v2/cmd/tomljson@latest\n\t$ tomljson --help\n\t```\n\n * `jsontoml`: Reads a JSON file and outputs a TOML representation.\n\n\t```\n\t$ go install github.com/pelletier/go-toml/v2/cmd/jsontoml@latest\n\t$ jsontoml --help\n\t```\n\n * `tomll`: Lints and reformats a TOML file.\n\n\t```\n\t$ go install github.com/pelletier/go-toml/v2/cmd/tomll@latest\n\t$ tomll --help\n\t```\n\n### Docker image\n\nThose tools are also available as a [Docker image][docker]. For example, to use\n`tomljson`:\n\n```\ndocker run -i ghcr.io/pelletier/go-toml:v2 tomljson \u003c example.toml\n```\n\nMultiple versions are available on [ghcr.io][docker].\n\n[docker]: https://github.com/pelletier/go-toml/pkgs/container/go-toml\n\n## Migrating from v1\n\nThis section describes the differences between v1 and v2, with some pointers on\nhow to get the original behavior when possible.\n\n### Decoding / Unmarshal\n\n#### Automatic field name guessing\n\nWhen unmarshaling to a struct, if a key in the TOML document does not exactly\nmatch the name of a struct field or any of the `toml`-tagged field, v1 tries\nmultiple variations of the key ([code][v1-keys]).\n\nV2 instead does a case-insensitive matching, like `encoding/json`.\n\nThis could impact you if you are relying on casing to differentiate two fields,\nand one of them is a not using the `toml` struct tag. The recommended solution\nis to be specific about tag names for those fields using the `toml` struct tag.\n\n[v1-keys]: https://github.com/pelletier/go-toml/blob/a2e52561804c6cd9392ebf0048ca64fe4af67a43/marshal.go#L775-L781\n\n#### Ignore preexisting value in interface\n\nWhen decoding into a non-nil `interface{}`, go-toml v1 uses the type of the\nelement in the interface to decode the object. For example:\n\n```go\ntype inner struct {\n\tB interface{}\n}\ntype doc struct {\n\tA interface{}\n}\n\nd := doc{\n\tA: inner{\n\t\tB: \"Before\",\n\t},\n}\n\ndata := `\n[A]\nB = \"After\"\n`\n\ntoml.Unmarshal([]byte(data), \u0026d)\nfmt.Printf(\"toml v1: %#v\\n\", d)\n\n// toml v1: main.doc{A:main.inner{B:\"After\"}}\n```\n\nIn this case, field `A` is of type `interface{}`, containing a `inner` struct.\nV1 sees that type and uses it when decoding the object.\n\nWhen decoding an object into an `interface{}`, V2 instead disregards whatever\nvalue the `interface{}` may contain and replaces it with a\n`map[string]interface{}`. With the same data structure as above, here is what\nthe result looks like:\n\n```go\ntoml.Unmarshal([]byte(data), \u0026d)\nfmt.Printf(\"toml v2: %#v\\n\", d)\n\n// toml v2: main.doc{A:map[string]interface {}{\"B\":\"After\"}}\n```\n\nThis is to match `encoding/json`'s behavior. There is no way to make the v2\ndecoder behave like v1.\n\n#### Values out of array bounds ignored\n\nWhen decoding into an array, v1 returns an error when the number of elements\ncontained in the doc is superior to the capacity of the array. For example:\n\n```go\ntype doc struct {\n\tA [2]string\n}\nd := doc{}\nerr := toml.Unmarshal([]byte(`A = [\"one\", \"two\", \"many\"]`), \u0026d)\nfmt.Println(err)\n\n// (1, 1): unmarshal: TOML array length (3) exceeds destination array length (2)\n```\n\nIn the same situation, v2 ignores the last value:\n\n```go\nerr := toml.Unmarshal([]byte(`A = [\"one\", \"two\", \"many\"]`), \u0026d)\nfmt.Println(\"err:\", err, \"d:\", d)\n// err: \u003cnil\u003e d: {[one two]}\n```\n\nThis is to match `encoding/json`'s behavior. There is no way to make the v2\ndecoder behave like v1.\n\n#### Support for `toml.Unmarshaler` has been dropped\n\nThis method was not widely used, poorly defined, and added a lot of complexity.\nA similar effect can be achieved by implementing the `encoding.TextUnmarshaler`\ninterface and use strings.\n\n#### Support for `default` struct tag has been dropped\n\nThis feature adds complexity and a poorly defined API for an effect that can be\naccomplished outside of the library.\n\nIt does not seem like other format parsers in Go support that feature (the\nproject referenced in the original ticket #202 has not been updated since 2017).\nGiven that go-toml v2 should not touch values not in the document, the same\neffect can be achieved by pre-filling the struct with defaults (libraries like\n[go-defaults][go-defaults] can help). Also, string representation is not well\ndefined for all types: it creates issues like #278.\n\nThe recommended replacement is pre-filling the struct before unmarshaling.\n\n[go-defaults]: https://github.com/mcuadros/go-defaults\n\n#### `toml.Tree` replacement\n\nThis structure was the initial attempt at providing a document model for\ngo-toml. It allows manipulating the structure of any document, encoding and\ndecoding from their TOML representation. While a more robust feature was\ninitially planned in go-toml v2, this has been ultimately [removed from\nscope][nodoc] of this library, with no plan to add it back at the moment. The\nclosest equivalent at the moment would be to unmarshal into an `interface{}` and\nuse type assertions and/or reflection to manipulate the arbitrary\nstructure. However this would fall short of providing all of the TOML features\nsuch as adding comments and be specific about whitespace.\n\n\n#### `toml.Position` are not retrievable anymore\n\nThe API for retrieving the position (line, column) of a specific TOML element do\nnot exist anymore. This was done to minimize the amount of concepts introduced\nby the library (query path), and avoid the performance hit related to storing\npositions in the absence of a document model, for a feature that seemed to have\nlittle use. Errors however have gained more detailed position\ninformation. Position retrieval seems better fitted for a document model, which\nhas been [removed from the scope][nodoc] of go-toml v2 at the moment.\n\n### Encoding / Marshal\n\n#### Default struct fields order\n\nV1 emits struct fields order alphabetically by default. V2 struct fields are\nemitted in order they are defined. For example:\n\n```go\ntype S struct {\n\tB string\n\tA string\n}\n\ndata := S{\n\tB: \"B\",\n\tA: \"A\",\n}\n\nb, _ := tomlv1.Marshal(data)\nfmt.Println(\"v1:\\n\" + string(b))\n\nb, _ = tomlv2.Marshal(data)\nfmt.Println(\"v2:\\n\" + string(b))\n\n// Output:\n// v1:\n// A = \"A\"\n// B = \"B\"\n\n// v2:\n// B = 'B'\n// A = 'A'\n```\n\nThere is no way to make v2 encoder behave like v1. A workaround could be to\nmanually sort the fields alphabetically in the struct definition, or generate\nstruct types using `reflect.StructOf`.\n\n#### No indentation by default\n\nV1 automatically indents content of tables by default. V2 does not. However the\nsame behavior can be obtained using [`Encoder.SetIndentTables`][sit]. For example:\n\n```go\ndata := map[string]interface{}{\n\t\"table\": map[string]string{\n\t\t\"key\": \"value\",\n\t},\n}\n\nb, _ := tomlv1.Marshal(data)\nfmt.Println(\"v1:\\n\" + string(b))\n\nb, _ = tomlv2.Marshal(data)\nfmt.Println(\"v2:\\n\" + string(b))\n\nbuf := bytes.Buffer{}\nenc := tomlv2.NewEncoder(\u0026buf)\nenc.SetIndentTables(true)\nenc.Encode(data)\nfmt.Println(\"v2 Encoder:\\n\" + string(buf.Bytes()))\n\n// Output:\n// v1:\n//\n// [table]\n//   key = \"value\"\n//\n// v2:\n// [table]\n// key = 'value'\n//\n//\n// v2 Encoder:\n// [table]\n//   key = 'value'\n```\n\n[sit]: https://pkg.go.dev/github.com/pelletier/go-toml/v2#Encoder.SetIndentTables\n\n#### Keys and strings are single quoted\n\nV1 always uses double quotes (`\"`) around strings and keys that cannot be\nrepresented bare (unquoted). V2 uses single quotes instead by default (`'`),\nunless a character cannot be represented, then falls back to double quotes. As a\nresult of this change, `Encoder.QuoteMapKeys` has been removed, as it is not\nuseful anymore.\n\nThere is no way to make v2 encoder behave like v1.\n\n#### `TextMarshaler` emits as a string, not TOML\n\nTypes that implement [`encoding.TextMarshaler`][tm] can emit arbitrary TOML in\nv1. The encoder would append the result to the output directly. In v2 the result\nis wrapped in a string. As a result, this interface cannot be implemented by the\nroot object.\n\nThere is no way to make v2 encoder behave like v1.\n\n[tm]: https://golang.org/pkg/encoding/#TextMarshaler\n\n#### `Encoder.CompactComments` has been removed\n\nEmitting compact comments is now the default behavior of go-toml. This option\nis not necessary anymore.\n\n#### Struct tags have been merged\n\nV1 used to provide multiple struct tags: `comment`, `commented`, `multiline`,\n`toml`, and `omitempty`. To behave more like the standard library, v2 has merged\n`toml`, `multiline`, `commented`, and `omitempty`. For example:\n\n```go\ntype doc struct {\n\t// v1\n\tF string `toml:\"field\" multiline:\"true\" omitempty:\"true\" commented:\"true\"`\n\t// v2\n\tF string `toml:\"field,multiline,omitempty,commented\"`\n}\n```\n\nHas a result, the `Encoder.SetTag*` methods have been removed, as there is just\none tag now.\n\n#### `Encoder.ArraysWithOneElementPerLine` has been renamed\n\nThe new name is `Encoder.SetArraysMultiline`. The behavior should be the same.\n\n#### `Encoder.Indentation` has been renamed\n\nThe new name is `Encoder.SetIndentSymbol`. The behavior should be the same.\n\n\n#### Embedded structs behave like stdlib\n\nV1 defaults to merging embedded struct fields into the embedding struct. This\nbehavior was unexpected because it does not follow the standard library. To\navoid breaking backward compatibility, the `Encoder.PromoteAnonymous` method was\nadded to make the encoder behave correctly. Given backward compatibility is not\na problem anymore, v2 does the right thing by default: it follows the behavior\nof `encoding/json`. `Encoder.PromoteAnonymous` has been removed.\n\n[nodoc]: https://github.com/pelletier/go-toml/discussions/506#discussioncomment-1526038\n\n### `query`\n\ngo-toml v1 provided the [`go-toml/query`][query] package. It allowed to run\nJSONPath-style queries on TOML files. This feature is not available in v2. For a\nreplacement, check out [dasel][dasel].\n\nThis package has been removed because it was essentially not supported anymore\n(last commit May 2020), increased the complexity of the code base, and more\ncomplete solutions exist out there.\n\n[query]: https://github.com/pelletier/go-toml/tree/f99d6bbca119636aeafcf351ee52b3d202782627/query\n[dasel]: https://github.com/TomWright/dasel\n\n## Versioning\n\nExpect for parts explicitly marked otherwise, go-toml follows [Semantic\nVersioning](https://semver.org). The supported version of\n[TOML](https://github.com/toml-lang/toml) is indicated at the beginning of this\ndocument. The last two major versions of Go are supported (see [Go Release\nPolicy](https://golang.org/doc/devel/release.html#policy)).\n\n## License\n\nThe MIT License (MIT). Read [LICENSE](LICENSE).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpelletier%2Fgo-toml","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpelletier%2Fgo-toml","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpelletier%2Fgo-toml/lists"}