{"id":13560770,"url":"https://github.com/ssrathi/go-scrub","last_synced_at":"2025-07-20T23:06:04.594Z","repository":{"id":57691341,"uuid":"481005062","full_name":"ssrathi/go-scrub","owner":"ssrathi","description":"A scrubbing utility to hide sensitive fields from a struct prior to logging","archived":false,"fork":false,"pushed_at":"2022-11-15T12:35:18.000Z","size":191,"stargazers_count":43,"open_issues_count":1,"forks_count":8,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-04-03T16:39:22.958Z","etag":null,"topics":["go","golang","redaction"],"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/ssrathi.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":"2022-04-12T23:31:43.000Z","updated_at":"2025-02-01T10:32:14.000Z","dependencies_parsed_at":"2022-09-19T08:30:24.579Z","dependency_job_id":null,"html_url":"https://github.com/ssrathi/go-scrub","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/ssrathi/go-scrub","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ssrathi%2Fgo-scrub","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ssrathi%2Fgo-scrub/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ssrathi%2Fgo-scrub/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ssrathi%2Fgo-scrub/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ssrathi","download_url":"https://codeload.github.com/ssrathi/go-scrub/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ssrathi%2Fgo-scrub/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":266211932,"owners_count":23893379,"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","redaction"],"created_at":"2024-08-01T13:00:49.359Z","updated_at":"2025-07-20T23:06:04.567Z","avatar_url":"https://github.com/ssrathi.png","language":"Go","funding_links":[],"categories":["Go"],"sub_categories":[],"readme":"[![Builds](https://github.com/ssrathi/go-scrub/workflows/Build/badge.svg?branch=master)](https://github.com/ssrathi/go-scrub/actions?query=branch%3Amaster+workflow%3ABuild)\n[![Go Report Card](https://goreportcard.com/badge/github.com/ssrathi/go-scrub)](https://goreportcard.com/report/github.com/ssrathi/go-scrub)\n[![GoDoc](https://godoc.org/github.com/ssrathi/go-scrub?status.svg)](https://godoc.org/github.com/ssrathi/go-scrub)\n\n# go-scrub\n\nA scrubbing utility in Golang to hide sensitive fields from a struct prior to logging.\n\nSince the scrubbing utility function needs to work on any Golang struct where its fields and members are known only at runtime, we can leverage [\"reflect\"](https://pkg.go.dev/reflect), a powerful package from the Golang standard library, to scrub sensitive fields at any level of a deeply nested structure recursively.\n\n# Blog post\n\nBlog post with a detailed explanation: https://www.nutanix.dev/2022/04/22/golang-the-art-of-reflection/\n\n[\u003cimg src=\"https://raw.githubusercontent.com/ssrathi/go-scrub/master/assests/Blog-Header.jpg\" alt=\"Blog Link\" width=\"400\" height=\"200\"/\u003e](https://www.nutanix.dev/2022/04/22/golang-the-art-of-reflection/)\n\n## Installation\n```\ngo install github.com/ssrathi/go-scrub@latest\n```\n\n## Usage\n```go\n  import \"github.com/ssrathi/go-scrub\"\n\n  // Have a struct with some sensitive fields.\n  type testScrub struct {\n    Username string\n    Password string\n    Codes    []string\n  }\n\n  // Create a struct with some sensitive data.\n  T := testScrub{\n     Username: \"administrator\",\n     Password: \"my_secret_passphrase\",\n     Codes:    []string{\"pass1\", \"pass2\", \"pass3\"},\n  }\n\n  // Create a set of field names to scrub (default is 'password').\n  fieldsToScrub := map[string]bool{\n    \"password\": true,\n    \"codes\": true,\n  }\n\n  // Call the util API to get a JSON formatted string with scrubbed field values.\n  out := scrub.Scrub(\u0026T, fieldsToScrub)\n\n  // Log the scrubbed string without worrying about prying eyes!\n  log.Println(out)\n  OUTPUT: {\"Username\":\"administrator\",\"Password\":\"********\",\"Codes\":[\"********\",\"********\",\"********\"]}\n```\n\n## Contributing\n\nContributions are most welcome! Please create a new issue and link your PR to it.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fssrathi%2Fgo-scrub","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fssrathi%2Fgo-scrub","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fssrathi%2Fgo-scrub/lists"}