{"id":15330471,"url":"https://github.com/kezhuw/toml","last_synced_at":"2025-04-15T02:54:05.116Z","repository":{"id":57484284,"uuid":"49210496","full_name":"kezhuw/toml","owner":"kezhuw","description":"TOML parser and encoder for Go with reflection.","archived":false,"fork":false,"pushed_at":"2020-04-19T07:35:22.000Z","size":35,"stargazers_count":19,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-15T02:54:01.602Z","etag":null,"topics":["go","toml"],"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/kezhuw.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-01-07T14:50:30.000Z","updated_at":"2022-01-24T12:59:50.000Z","dependencies_parsed_at":"2022-08-26T12:24:01.141Z","dependency_job_id":null,"html_url":"https://github.com/kezhuw/toml","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kezhuw%2Ftoml","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kezhuw%2Ftoml/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kezhuw%2Ftoml/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kezhuw%2Ftoml/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kezhuw","download_url":"https://codeload.github.com/kezhuw/toml/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248997090,"owners_count":21195797,"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","toml"],"created_at":"2024-10-01T09:53:24.211Z","updated_at":"2025-04-15T02:54:05.086Z","avatar_url":"https://github.com/kezhuw.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# TOML parser and encoder for Go\n\nCompatible with [TOML][] version [v0.4.0](https://github.com/toml-lang/toml/blob/master/versions/en/toml-v0.4.0.md).\n\n[![GoDoc](https://godoc.org/github.com/kezhuw/toml?status.svg)](http://godoc.org/github.com/kezhuw/toml)\n[![Build Status](https://travis-ci.org/kezhuw/toml.svg?branch=master)](https://travis-ci.org/kezhuw/toml)\n\nRun `go get github.com/kezhuw/toml` to install.\n\n## Examples\nSnippets copied from Go test files.\n\n```go\npackage toml_test\n\nimport (\n\t\"fmt\"\n\t\"time\"\n\n\t\"github.com/kezhuw/toml\"\n)\n\nfunc ExampleUnmarshal_integer() {\n\tdata := []byte(`key = 12345`)\n\tvar out struct{ Key int }\n\n\terr := toml.Unmarshal(data, \u0026out)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tfmt.Println(out.Key)\n\t// Output: 12345\n}\n\nfunc ExampleUnmarshal_datetimeNative() {\n\tdata := []byte(`key = 2016-01-07T15:30:30.123456789Z`)\n\tvar out struct{ Key time.Time }\n\n\terr := toml.Unmarshal(data, \u0026out)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tfmt.Println(out.Key.Format(time.RFC3339Nano))\n\t// Output: 2016-01-07T15:30:30.123456789Z\n}\n\nfunc ExampleUnmarshal_array() {\n\tdata := []byte(`key = [1, 2, 3,4]`)\n\tvar out struct{ Key []int }\n\n\terr := toml.Unmarshal(data, \u0026out)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tfmt.Println(out.Key)\n\t// Output: [1 2 3 4]\n}\n\nfunc ExampleUnmarshal_table() {\n\tdata := []byte(`[key]\n\tname = \"name\"\n\tvalue = \"value\"`)\n\tvar out struct {\n\t\tKey struct {\n\t\t\tName  string\n\t\t\tValue string\n\t\t}\n\t}\n\n\terr := toml.Unmarshal(data, \u0026out)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tfmt.Printf(\"key.name = %q\\n\", out.Key.Name)\n\tfmt.Printf(\"key.value = %q\\n\", out.Key.Value)\n\t// Output:\n\t// key.name = \"name\"\n\t// key.value = \"value\"\n}\n\nfunc ExampleUnmarshal_inlineTable() {\n\tdata := []byte(`key = { name = \"name\", value = \"value\" }`)\n\tvar out struct {\n\t\tKey struct {\n\t\t\tName  string\n\t\t\tValue string\n\t\t}\n\t}\n\n\terr := toml.Unmarshal(data, \u0026out)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tfmt.Printf(\"key.name = %q\\n\", out.Key.Name)\n\tfmt.Printf(\"key.value = %q\\n\", out.Key.Value)\n\t// Output:\n\t// key.name = \"name\"\n\t// key.value = \"value\"\n}\n\nfunc ExampleUnmarshal_tableArray() {\n\tdata := []byte(`\n\t[[array]]\n\tdescription = \"Table In Array\"\n\t`)\n\tvar out struct {\n\t\tArray []struct{ Description string }\n\t}\n\n\terr := toml.Unmarshal(data, \u0026out)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tfmt.Println(out.Array[0].Description)\n\t// Output: Table In Array\n}\n\nfunc ExampleUnmarshal_interface() {\n\tdata := []byte(`key = [1, 2, 3, 4,]`)\n\tvar out struct{ Key interface{} }\n\n\terr := toml.Unmarshal(data, \u0026out)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tfmt.Println(out.Key)\n\t// Output: [1 2 3 4]\n}\n\nfunc ExampleUnmarshal_tagName() {\n\tdata := []byte(`KKKK = \"value\"`)\n\tvar out struct {\n\t\tKey string `toml:\"KKKK\"`\n\t}\n\n\terr := toml.Unmarshal(data, \u0026out)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tfmt.Println(out.Key)\n\t// Output: value\n}\n\nfunc ExampleUnmarshal_tagIgnore() {\n\tdata := []byte(`key = \"value\"`)\n\tvar out struct {\n\t\tKey string `toml:\"-\"`\n\t}\n\n\terr := toml.Unmarshal(data, \u0026out)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tfmt.Println(out.Key)\n\t// Output:\n}\n\nfunc ExampleUnmarshal_tagString() {\n\tdata := []byte(`key = \"12345\"`)\n\tvar out struct {\n\t\tKey int `toml:\",string\"`\n\t}\n\n\terr := toml.Unmarshal(data, \u0026out)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tfmt.Println(out.Key)\n\t// Output: 12345\n}\n\nfunc ExampleUnmarshal_tagOmitempty() {\n\tdata := []byte(``)\n\tvar out struct {\n\t\tKey string `toml:\",omitempty\"`\n\t}\n\tout.Key = \"Not empty, for now.\"\n\n\terr := toml.Unmarshal(data, \u0026out)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tfmt.Println(out.Key)\n\t// Output:\n}\n```\n\n```go\npackage toml_test\n\nimport (\n\t\"fmt\"\n\t\"time\"\n\n\t\"github.com/kezhuw/toml\"\n)\n\ntype duration time.Duration\n\nfunc (d *duration) UnmarshalText(b []byte) error {\n\tv, err := time.ParseDuration(string(b))\n\tif err != nil {\n\t\treturn err\n\t}\n\t*d = duration(v)\n\treturn nil\n}\n\nfunc ExampleUnmarshal_textUnmarshaler() {\n\tdata := []byte(`timeout = \"300ms\"`)\n\tvar out struct{ Timeout duration }\n\n\terr := toml.Unmarshal(data, \u0026out)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tfmt.Println(time.Duration(out.Timeout))\n\t// Output: 300ms\n}\n```\n\n## Links\nOther TOML libraries written in Go.\n\n- https://github.com/BurntSushi/toml     TOML parser and encoder for Go with reflection\n- https://github.com/pelletier/go-toml   Go library for the TOML language\n- https://github.com/naoina/toml         TOML parser and encoder library for Golang\n\n## License\nReleased under The MIT License (MIT). See [LICENSE](LICENSE) for the full license text.\n\n## Contribution\nFire issue or pull request if you have any questions.\n\n[TOML]: https://github.com/toml-lang/toml\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkezhuw%2Ftoml","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkezhuw%2Ftoml","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkezhuw%2Ftoml/lists"}