{"id":13413955,"url":"https://github.com/BurntSushi/toml","last_synced_at":"2025-03-14T20:30:51.528Z","repository":{"id":37412558,"uuid":"8425622","full_name":"BurntSushi/toml","owner":"BurntSushi","description":"TOML parser for Golang with reflection.","archived":false,"fork":false,"pushed_at":"2024-10-28T11:11:16.000Z","size":833,"stargazers_count":4574,"open_issues_count":16,"forks_count":527,"subscribers_count":82,"default_branch":"master","last_synced_at":"2024-10-29T19:59:49.315Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/BurntSushi.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"COPYING","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":"arp242"}},"created_at":"2013-02-26T05:05:48.000Z","updated_at":"2024-10-29T17:46:48.000Z","dependencies_parsed_at":"2023-12-07T11:25:03.636Z","dependency_job_id":"905867c2-0ff4-4dd4-a079-fd9759265c5f","html_url":"https://github.com/BurntSushi/toml","commit_stats":{"total_commits":404,"total_committers":56,"mean_commits":7.214285714285714,"dds":0.6410891089108911,"last_synced_commit":"b7406c026f5af05e3e826cb01c78bc2841be4703"},"previous_names":[],"tags_count":14,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BurntSushi%2Ftoml","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BurntSushi%2Ftoml/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BurntSushi%2Ftoml/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BurntSushi%2Ftoml/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/BurntSushi","download_url":"https://codeload.github.com/BurntSushi/toml/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":242777368,"owners_count":20183557,"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":[],"created_at":"2024-07-30T20:01:53.598Z","updated_at":"2025-03-14T20:30:51.522Z","avatar_url":"https://github.com/BurntSushi.png","language":"Go","funding_links":["https://github.com/sponsors/arp242"],"categories":["Members","开源类库","文本处理","Go","Text Processing","Open source library","文本處理","语言资源库","Bot Building","文本处理`解析和操作文本的代码库`","Template Engines","Specific Formats","\u003cspan id=\"文字处理-text-processing\"\u003e文字处理 Text Processing\u003c/span\u003e"],"sub_categories":["配置","交流","Advanced Console UIs","Construction","查询语","Markup Languages","HTTP Clients","高級控制台界面","go","标记语言","高级控制台界面","Middlewares","\u003cspan id=\"高级控制台用户界面-advanced-console-uis\"\u003e高级控制台用户界面 Advanced Console UIs\u003c/span\u003e"],"readme":"TOML stands for Tom's Obvious, Minimal Language. This Go package provides a\nreflection interface similar to Go's standard library `json` and `xml` packages.\n\nCompatible with TOML version [v1.0.0](https://toml.io/en/v1.0.0).\n\nDocumentation: https://pkg.go.dev/github.com/BurntSushi/toml\n\nSee the [releases page](https://github.com/BurntSushi/toml/releases) for a\nchangelog; this information is also in the git tag annotations (e.g. `git show\nv0.4.0`).\n\nThis library requires Go 1.18 or newer; add it to your go.mod with:\n\n    % go get github.com/BurntSushi/toml@latest\n\nIt also comes with a TOML validator CLI tool:\n\n    % go install github.com/BurntSushi/toml/cmd/tomlv@latest\n    % tomlv some-toml-file.toml\n\n### Examples\nFor the simplest example, consider some TOML file as just a list of keys and\nvalues:\n\n```toml\nAge = 25\nCats = [ \"Cauchy\", \"Plato\" ]\nPi = 3.14\nPerfection = [ 6, 28, 496, 8128 ]\nDOB = 1987-07-05T05:45:00Z\n```\n\nWhich can be decoded with:\n\n```go\ntype Config struct {\n\tAge        int\n\tCats       []string\n\tPi         float64\n\tPerfection []int\n\tDOB        time.Time\n}\n\nvar conf Config\n_, err := toml.Decode(tomlData, \u0026conf)\n```\n\nYou can also use struct tags if your struct field name doesn't map to a TOML key\nvalue directly:\n\n```toml\nsome_key_NAME = \"wat\"\n```\n\n```go\ntype TOML struct {\n    ObscureKey string `toml:\"some_key_NAME\"`\n}\n```\n\nBeware that like other decoders **only exported fields** are considered when\nencoding and decoding; private fields are silently ignored.\n\n### Using the `Marshaler` and `encoding.TextUnmarshaler` interfaces\nHere's an example that automatically parses values in a `mail.Address`:\n\n```toml\ncontacts = [\n    \"Donald Duck \u003cdonald@duckburg.com\u003e\",\n    \"Scrooge McDuck \u003cscrooge@duckburg.com\u003e\",\n]\n```\n\nCan be decoded with:\n\n```go\n// Create address type which satisfies the encoding.TextUnmarshaler interface.\ntype address struct {\n\t*mail.Address\n}\n\nfunc (a *address) UnmarshalText(text []byte) error {\n\tvar err error\n\ta.Address, err = mail.ParseAddress(string(text))\n\treturn err\n}\n\n// Decode it.\nfunc decode() {\n\tblob := `\n\t\tcontacts = [\n\t\t\t\"Donald Duck \u003cdonald@duckburg.com\u003e\",\n\t\t\t\"Scrooge McDuck \u003cscrooge@duckburg.com\u003e\",\n\t\t]\n\t`\n\n\tvar contacts struct {\n\t\tContacts []address\n\t}\n\n\t_, err := toml.Decode(blob, \u0026contacts)\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t}\n\n\tfor _, c := range contacts.Contacts {\n\t\tfmt.Printf(\"%#v\\n\", c.Address)\n\t}\n\n\t// Output:\n\t// \u0026mail.Address{Name:\"Donald Duck\", Address:\"donald@duckburg.com\"}\n\t// \u0026mail.Address{Name:\"Scrooge McDuck\", Address:\"scrooge@duckburg.com\"}\n}\n```\n\nTo target TOML specifically you can implement `UnmarshalTOML` TOML interface in\na similar way.\n\n### More complex usage\nSee the [`_example/`](/_example) directory for a more complex example.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FBurntSushi%2Ftoml","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FBurntSushi%2Ftoml","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FBurntSushi%2Ftoml/lists"}