{"id":29296937,"url":"https://github.com/unkn0wn-root/go-gitcfg","last_synced_at":"2026-05-19T02:07:51.112Z","repository":{"id":302928311,"uuid":"1013969635","full_name":"unkn0wn-root/go-gitcfg","owner":"unkn0wn-root","description":"Go library for reading and working with Git configuration files","archived":false,"fork":false,"pushed_at":"2025-07-05T18:48:07.000Z","size":27,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-07-05T19:57:40.749Z","etag":null,"topics":["git","go","golang"],"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/unkn0wn-root.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-07-04T19:38:59.000Z","updated_at":"2025-07-05T18:48:10.000Z","dependencies_parsed_at":"2025-07-05T19:57:42.033Z","dependency_job_id":null,"html_url":"https://github.com/unkn0wn-root/go-gitcfg","commit_stats":null,"previous_names":["unkn0wn-root/gogitcfg","unkn0wn-root/go-gitcfg"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/unkn0wn-root/go-gitcfg","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/unkn0wn-root%2Fgo-gitcfg","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/unkn0wn-root%2Fgo-gitcfg/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/unkn0wn-root%2Fgo-gitcfg/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/unkn0wn-root%2Fgo-gitcfg/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/unkn0wn-root","download_url":"https://codeload.github.com/unkn0wn-root/go-gitcfg/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/unkn0wn-root%2Fgo-gitcfg/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":263932060,"owners_count":23531711,"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":["git","go","golang"],"created_at":"2025-07-06T16:07:52.569Z","updated_at":"2026-05-19T02:07:51.069Z","avatar_url":"https://github.com/unkn0wn-root.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# go-gitcfg\n\nA Go library for reading and working with Git configuration files. Supports both global and repository-specific configurations.\n\n## Quick Start\n\n### Load Global Configuration\n\n```go\npackage main\n\nimport (\n    \"fmt\"\n    \"github.com/unkn0wn-root/go-gitcfg\"\n)\n\nfunc main() {\n    // Load global Git configuration\n    config, err := gitcfg.LoadGlobal()\n    if err != nil {\n        panic(err)\n    }\n\n    // Get user information\n    user, err := config.GetUser()\n    if err != nil {\n        panic(err)\n    }\n\n    fmt.Printf(\"User: %s \u003c%s\u003e\\n\", user.Name, user.Email)\n}\n```\n\n### Type-Safe Value Access\n\n```go\n// Generic type-safe access\nname, err := gitcfg.Get[string](config, \"user.name\")\neditor, err := gitcfg.Get[string](config, \"core.editor\")\nautocrlf, err := gitcfg.Get[bool](config, \"core.autocrlf\")\nfilemode, err := gitcfg.Get[bool](config, \"core.filemode\")\ntimeout, err := gitcfg.Get[int](config, \"http.timeout\")\n\n// With default values\ntimeout := gitcfg.GetWithDefault[int](config, \"http.timeout\", 30)\neditor := gitcfg.GetWithDefault[string](config, \"core.editor\", \"vim\")\n```\n\n### Load Different Configuration Sources\n\n```go\n// Load only global configuration\nconfig, err := gitcfg.LoadGlobal()\n\n// Load only local repository configuration\nconfig, err := gitcfg.LoadLocal(\"/path/to/repo\")\n\n// Load all configuration sources in precedence order\nconfig, err := gitcfg.LoadAll(\"/path/to/repo\")\n\n// Load with specific options\nconfig, err := gitcfg.Load(\n    gitcfg.WithGlobal(),\n    gitcfg.WithLocal(),\n    gitcfg.WithRepoPath(\"/path/to/repo\"),\n)\n```\n\n### Structured Config Access\n\n```go\n// User configuration\nuser, err := config.GetUser()\nfmt.Printf(\"Name: %s, Email: %s\\n\", user.Name, user.Email)\n\n// Remote URL (simplified access)\nremoteURL, err := config.GetRemoteURL(\"origin\")\nfmt.Printf(\"URL: %s\\n\", remoteURL)\n\n// Direct section access for complex configurations\nremoteSection := config.GetSection(\"remote.origin\")\nfor key, value := range remoteSection {\n    fmt.Printf(\"%s = %s\\n\", key, value)\n}\n```\n\n### Working with Sections and Keys\n\n```go\n// Check if key exists\nif config.Has(\"user.name\") {\n    fmt.Println(\"User name is configured\")\n}\n\n// Get all sections\nsections := config.GetSections()\nfmt.Printf(\"Found sections: %v\\n\", sections)\n\n// Get entire section as map\nuserSection := config.GetSection(\"user\")\nfor key, value := range userSection {\n    fmt.Printf(\"%s = %s\\n\", key, value)\n}\n\n// Check if section exists\nif config.HasSection(\"user\") {\n    fmt.Println(\"User section exists\")\n}\n```\n\n### With context\n\n```go\nimport \"context\"\n\nctx := context.WithTimeout(context.Background(), 30*time.Second)\n\n// Load with context\nconfig, err := gitcfg.LoadWithContext(ctx, gogitcfg.WithGlobal())\n\n// Reload with context\nerr = config.ReloadWithContext(ctx)\n```\n\n## Configuration Sources\n\nThe library supports all standard Git configuration sources:\n\n- **System**: `/etc/gitconfig` (system-wide)\n- **Global**: `~/.gitconfig` (user-specific)\n- **Local**: `.git/config` (repository-specific)\n- **Worktree**: `.git/config.worktree` (worktree-specific)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Funkn0wn-root%2Fgo-gitcfg","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Funkn0wn-root%2Fgo-gitcfg","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Funkn0wn-root%2Fgo-gitcfg/lists"}