{"id":19167055,"url":"https://github.com/powerman/sensitive","last_synced_at":"2025-05-07T13:36:29.151Z","repository":{"id":38328951,"uuid":"311151496","full_name":"powerman/sensitive","owner":"powerman","description":"Package sensitive provides base types who's values should never be seen by the human eye, but still used for configuration.","archived":false,"fork":false,"pushed_at":"2022-10-27T22:34:45.000Z","size":117,"stargazers_count":4,"open_issues_count":7,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-05-06T03:58:07.492Z","etag":null,"topics":["go","golang","golang-library","sensitive-data"],"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/powerman.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":"2020-11-08T20:46:18.000Z","updated_at":"2023-09-28T09:26:57.000Z","dependencies_parsed_at":"2023-01-19T15:46:21.017Z","dependency_job_id":null,"html_url":"https://github.com/powerman/sensitive","commit_stats":null,"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/powerman%2Fsensitive","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/powerman%2Fsensitive/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/powerman%2Fsensitive/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/powerman%2Fsensitive/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/powerman","download_url":"https://codeload.github.com/powerman/sensitive/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252888001,"owners_count":21819942,"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","golang","golang-library","sensitive-data"],"created_at":"2024-11-09T09:35:37.209Z","updated_at":"2025-05-07T13:36:29.132Z","avatar_url":"https://github.com/powerman.png","language":"Go","readme":"# Go package with base types protected from the human eye\n\n[![Go Reference](https://pkg.go.dev/badge/github.com/powerman/sensitive.svg)](https://pkg.go.dev/github.com/powerman/sensitive)\n[![CI/CD](https://github.com/powerman/sensitive/workflows/CI/CD/badge.svg?event=push)](https://github.com/powerman/sensitive/actions?query=workflow%3ACI%2FCD)\n[![Coverage Status](https://coveralls.io/repos/github/powerman/sensitive/badge.svg?branch=master)](https://coveralls.io/github/powerman/sensitive?branch=master)\n[![Go Report Card](https://goreportcard.com/badge/github.com/powerman/sensitive)](https://goreportcard.com/report/github.com/powerman/sensitive)\n[![Release](https://img.shields.io/github/v/release/powerman/sensitive)](https://github.com/powerman/sensitive/releases/latest)\n\n**NOTE:** This project has been started as a fork of\nhttps://github.com/go-playground/sensitive, but as upstream repo have no\nactivity since initial commit and several new features were added here\n(see [Releases](https://github.com/powerman/sensitive/releases)) this repo\nwas detached and you can consider it an independent maintained alternative\nfor the upstream repo.\n\nPackage sensitive provides base types who's values should never be seen by\nthe human eye, but still used for configuration.\n\nSometimes you have a variable, such as a password, passed into your\nprogram via arguments or ENV variables.\nSome of these variables are very sensitive! and should not in any\ncircumstance be loggged or sent via JSON, despite JSON's \"-\", which people\nmay forget.\nThese variables, which are just typed primitive types, have their\noverridden `fmt.Formatter`, `encoding.MarshalText` \u0026 `json.Marshal`\nimplementations.\n\nAs an added bonus using them as their base type eg. String =\u003e string, you\nhave to explicitly cast the eg. string(s) This makes you think about what\nyou're doing and why you casting it providing additional safety.\n\nSupported types:\n- `Bool`\n- `Bytes`\n- `Decimal` (https://github.com/shopspring/decimal)\n- `Float32`\n- `Float64`\n- `Int`\n- `Int8`\n- `Int16`\n- `Int32`\n- `Int64`\n- `String` (the most useful)\n- `Uint`\n- `Uint8`\n- `Uint16`\n- `Uint32`\n- `Uint64`\n\n## Examples\n\n### Basic\n\n```go\n// go run _examples/basic/main.go mypassword\npackage main\n\nimport (\n\t\"encoding/json\"\n\t\"fmt\"\n\t\"os\"\n\n\t\"github.com/powerman/sensitive\"\n)\n\nfunc main() {\n\tpassword := sensitive.String(os.Args[1])\n\n\tfmt.Printf(\"%s\\n\", password)\n\tfmt.Printf(\"%v\\n\", password)\n\n\tb, _ := json.Marshal(password)\n\tfmt.Println(string(b))\n\n\tvar empty *sensitive.String\n\tb, _ = json.Marshal(empty)\n\tfmt.Println(string(b))\n\n\t// output:\n\t//\n\t//\n\t// \"\"\n\t// null\n}\n```\n\n### Custom Formatting\n\n```go\n// go run _examples/custom/main.go mypassword\npackage main\n\nimport (\n\t\"encoding/json\"\n\t\"fmt\"\n\t\"os\"\n\n\t\"github.com/powerman/sensitive\"\n)\n\nfunc init() {\n\t// override default Formatter\n\tsensitive.FormatStringFn = func(s sensitive.String, f fmt.State, c rune) {\n\t\tswitch c {\n\t\tdefault:\n\t\t        sensitive.Format(f, c, \"redacted\")\n\t\tcase 'v':\n\t\t        sensitive.Format(f, c, string(s)[:4]+\"*******\")\n\t\t}\n\t}\n}\n\nfunc main() {\n\tpassword := sensitive.String(os.Args[1])\n\n\tfmt.Printf(\"%s\\n\", password)\n\tfmt.Printf(\"%v\\n\", password)\n\n\tb, _ := json.Marshal(password)\n\tfmt.Println(string(b))\n\n\tvar empty *sensitive.String\n\tb, _ = json.Marshal(empty)\n\tfmt.Println(string(b))\n\n\t// output:\n\t// redacted\n\t// mypa*******\n\t// \"mypa*******\"\n\t// null\n}\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpowerman%2Fsensitive","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpowerman%2Fsensitive","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpowerman%2Fsensitive/lists"}