{"id":13831661,"url":"https://github.com/brettlangdon/forge","last_synced_at":"2025-03-16T21:30:24.478Z","repository":{"id":33741061,"uuid":"37395751","full_name":"brettlangdon/forge","owner":"brettlangdon","description":"Configuration file syntax and parsing for golang","archived":false,"fork":false,"pushed_at":"2017-03-22T20:04:32.000Z","size":81,"stargazers_count":109,"open_issues_count":10,"forks_count":3,"subscribers_count":10,"default_branch":"master","last_synced_at":"2025-03-16T05:41:21.658Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/brettlangdon.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG","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":"2015-06-14T02:16:32.000Z","updated_at":"2025-03-04T10:40:33.000Z","dependencies_parsed_at":"2022-07-12T09:52:03.436Z","dependency_job_id":null,"html_url":"https://github.com/brettlangdon/forge","commit_stats":null,"previous_names":[],"tags_count":12,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/brettlangdon%2Fforge","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/brettlangdon%2Fforge/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/brettlangdon%2Fforge/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/brettlangdon%2Fforge/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/brettlangdon","download_url":"https://codeload.github.com/brettlangdon/forge/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243936394,"owners_count":20371505,"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-08-04T10:01:35.924Z","updated_at":"2025-03-16T21:30:24.098Z","avatar_url":"https://github.com/brettlangdon.png","language":"Go","readme":"forge\n=====\n\n[![Build Status](https://travis-ci.org/brettlangdon/forge.svg?branch=master)](https://travis-ci.org/brettlangdon/forge)\n[![GoDoc](https://godoc.org/github.com/brettlangdon/forge?status.svg)](https://godoc.org/github.com/brettlangdon/forge)\n\nForge is a configuration syntax and parser.\n\n## Installation\n\n`go get github.com/brettlangdon/forge`\n\n## Documentation\n\nDocumentation can be viewed on godoc: https://godoc.org/github.com/brettlangdon/forge\n\n## Example\n\nYou can see example usage in the `example` folder.\n\n```cfg\n# example.cfg\n\n# Global directives\nglobal = \"global value\";\n# Primary section\nprimary {\n  string = \"primary string value\";\n  single = 'single quotes are allowed too';\n\n  # Semicolons are optional\n  integer = 500\n  float = 80.80\n  boolean = true\n  negative = FALSE\n  nothing = NULL\n\n  list = [50.5, true, false, \"hello\", 'world'];\n\n  # Include external files\n  include \"./include*.cfg\";\n  # Primary-sub section\n  sub {\n      key = \"primary sub key value\";\n  }\n}\n\n# Secondary section\nsecondary {\n  another = \"secondary another value\";\n  global_reference = global;\n  primary_sub_key = primary.sub.key;\n  another_again = .another;  # References secondary.another\n  _under = 50;\n}\n```\n\n```go\npackage main\n\nimport (\n\t\"fmt\"\n\t\"json\"\n\n\t\"github.com/brettlangdon/forge\"\n)\n\nfunc main() {\n\t// Parse a `SectionValue` from `example.cfg`\n\tsettings, err := forge.ParseFile(\"example.cfg\")\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\t// Get a single value\n\tif settings.Exists(\"global\") {\n\t\t// Get `global` casted as a string\n\t\tvalue, _ := settings.GetString(\"global\")\n\t\tfmt.Printf(\"global = \\\"%s\\\"\\r\\n\", value)\n\t}\n\n\t// Get a nested value\n\tvalue, err := settings.Resolve(\"primary.included_setting\")\n\tfmt.Printf(\"primary.included_setting = \\\"%s\\\"\\r\\n\", value.GetValue())\n\n\t// You can also traverse down the sections manually\n\tprimary, err := settings.GetSection(\"primary\")\n\tstrVal, err := primary.GetString(\"included_setting\")\n\tfmt.Printf(\"primary.included_setting = \\\"%s\\\"\\r\\n\", strVal)\n\n\t// Convert settings to a map\n\tsettingsMap := settings.ToMap()\n\tfmt.Printf(\"global = \\\"%s\\\"\\r\\n\", settingsMap[\"global\"])\n\n\t// Convert settings to JSON\n\tjsonBytes, err := settings.ToJSON()\n\tfmt.Printf(\"\\r\\n\\r\\n%s\\r\\n\", string(jsonBytes))\n}\n```\n\n## Issues/Requests?\n\nPlease feel free to open a github issue for any issues you have or any feature requests.\n","funding_links":[],"categories":["Go"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbrettlangdon%2Fforge","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbrettlangdon%2Fforge","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbrettlangdon%2Fforge/lists"}