{"id":43961536,"url":"https://github.com/andrewbenton/go-secrets","last_synced_at":"2026-02-07T05:33:24.154Z","repository":{"id":57659958,"uuid":"474586732","full_name":"andrewbenton/go-secrets","owner":"andrewbenton","description":"Golang generics for hiding secret values from accidental exposure","archived":false,"fork":false,"pushed_at":"2025-06-12T23:00:15.000Z","size":39,"stargazers_count":0,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-10-16T23:41:00.474Z","etag":null,"topics":["generics","golang","library","secrets"],"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/andrewbenton.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","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}},"created_at":"2022-03-27T09:08:25.000Z","updated_at":"2022-03-27T09:24:52.000Z","dependencies_parsed_at":"2024-03-04T05:00:19.737Z","dependency_job_id":null,"html_url":"https://github.com/andrewbenton/go-secrets","commit_stats":null,"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"purl":"pkg:github/andrewbenton/go-secrets","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andrewbenton%2Fgo-secrets","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andrewbenton%2Fgo-secrets/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andrewbenton%2Fgo-secrets/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andrewbenton%2Fgo-secrets/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/andrewbenton","download_url":"https://codeload.github.com/andrewbenton/go-secrets/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andrewbenton%2Fgo-secrets/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29187221,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-07T05:07:31.176Z","status":"ssl_error","status_checked_at":"2026-02-07T05:06:15.227Z","response_time":63,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["generics","golang","library","secrets"],"created_at":"2026-02-07T05:33:23.022Z","updated_at":"2026-02-07T05:33:24.145Z","avatar_url":"https://github.com/andrewbenton.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"Generic Golang Secrets\n======================\n\nThis package uses Go 1.18's secrets to implement a wrapping structure that will\nunmarshal secret values but marshals them to the default / blank value.  This\nis useful when dealing with values that you don't want to have accidentally\nexposed in a type safe manner.\n\nExample\n-------\n\n```go\nimport (\n    \"encoding/json\"\n    \"fmt\"\n\n    secret \"github.com/andrewbenton/go-secrets\"\n)\n\ntype myConfig struct {\n    Username string                `json:\"username\"`\n    Password secret.Secret[string] `json:\"password\"`\n}\n\nfunc main() {\n    input := `{\"username\": \"andrew\", \"password\": \"super secret password\"}`\n\n    var cfg myConfig\n    if err := json.Unmarshal(input, \u0026cfg); err != nil {\n        panic(err)\n    }\n\n    // secret is hidden when marshaling\n    data, err := json.Marshal(cfg)\n    if err != nil {\n        panic(err)\n    }\n\n    fmt.Println(string(data))\n\n    // recursive reflection based printing won't reveal the secret\n    fmt.Printf(\"%#v\\n\", cfg)\n\n    // secret isn't shown!\n    fmt.Println(cfg)\n\n    // secret still isn't shown!\n    fmt.Println(cfg.Password)\n\n    // secret can be directly accessed\n    fmt.Println(cfg.Password.Get())\n}\n```\n\nPerformance\n-----------\n\nPerformance isn't the primary concern of this library, however it's important\nto recognize that the additional functionality required to keep secrets hidden\ncosts more.  The tests below contrast the JSON marshaling and unmarshaling\nperformance of a `string` vs a `Secret[string]`.  These results were executed\nagainst an AMD Ryzen 9 7900X running in 105W Eco mode.\n\nGo 1.22.0:\n```\nBenchmarkJsonMarshal-24                 10483046               104.5 ns/op\nBenchmarkJsonUnmarshal-24                6155026               175.8 ns/op\nBenchmarkSecret_MarshalJSON-24           7724763               147.7 ns/op\nBenchmarkSecret_UnmarshalJSON-24         3029302               397.4 ns/op\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fandrewbenton%2Fgo-secrets","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fandrewbenton%2Fgo-secrets","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fandrewbenton%2Fgo-secrets/lists"}