{"id":42427895,"url":"https://github.com/vpakhuchyi/censor","last_synced_at":"2026-01-28T03:29:18.031Z","repository":{"id":201246163,"uuid":"707305988","full_name":"vpakhuchyi/censor","owner":"vpakhuchyi","description":"A library for data sanitisation.","archived":false,"fork":false,"pushed_at":"2025-11-17T22:37:02.000Z","size":2562,"stargazers_count":6,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2026-01-14T21:41:25.650Z","etag":null,"topics":["censorship","formatter","go","golang","masking","sanitisation"],"latest_commit_sha":null,"homepage":"https://vpakhuchyi.github.io/censor","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/vpakhuchyi.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,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2023-10-19T16:15:18.000Z","updated_at":"2025-11-17T22:37:05.000Z","dependencies_parsed_at":"2023-10-30T13:24:41.055Z","dependency_job_id":"4bcf41ee-c2a0-40d7-82c8-d11005724fba","html_url":"https://github.com/vpakhuchyi/censor","commit_stats":null,"previous_names":["vpakhuchyi/sanitiser","vpakhuchyi/censor"],"tags_count":14,"template":false,"template_full_name":null,"purl":"pkg:github/vpakhuchyi/censor","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vpakhuchyi%2Fcensor","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vpakhuchyi%2Fcensor/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vpakhuchyi%2Fcensor/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vpakhuchyi%2Fcensor/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/vpakhuchyi","download_url":"https://codeload.github.com/vpakhuchyi/censor/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vpakhuchyi%2Fcensor/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28836690,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-28T02:10:51.810Z","status":"ssl_error","status_checked_at":"2026-01-28T02:10:50.806Z","response_time":57,"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":["censorship","formatter","go","golang","masking","sanitisation"],"created_at":"2026-01-28T03:29:17.119Z","updated_at":"2026-01-28T03:29:18.026Z","avatar_url":"https://github.com/vpakhuchyi.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Censor\n\n\u003cp align=\"center\"\u003e\u003cimg src=\"https://github.com/vpakhuchyi/censor/blob/main/static/logo.png?raw=true\" width=\"260\"\u003e\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\n  \u003ca href=\"https://goreportcard.com/report/github.com/vpakhuchyi/censor\"\u003e\u003cimg src=\"https://goreportcard.com/badge/github.com/vpakhuchyi/censor\" alt=\"PkgGoDev\"\u003e\u003c/a\u003e\n  \u003cimg src=\"https://raw.githubusercontent.com/vpakhuchyi/censor/badges/.badges/main/coverage.svg\"\u003e\n  \u003cimg src=\"https://github.com/vpakhuchyi/censor-doc/actions/workflows/deploy.yml/badge.svg?branch=main\"\u003e\n  \u003ca href=\"https://godoc.org/github.com/vpakhuchyi/censor\"\u003e\u003cimg src=\"https://godoc.org/github.com/vpakhuchyi/censor?status.svg\" alt=\"Go Report Card\" /\u003e\u003c/a\u003e\n\u003c/p\u003e\n\n**Censor** is a Go library focused on formatting values into strings, emphasizing the protection\nof sensitive information. Through advanced reflection and specialized formatters, it provides precise,\neasily readable output. Ideal for safeguarding confidential data or enhancing data presentation in Go projects.\n\n### Features\n\n- [x] Struct formatting with a default values masking of all the fields (recursively).\n- [x] Supports output in Text and JSON formats.\n- [x] Strings values masking based on provided regexp patterns.\n- [x] Wide range of supported types:\n    - `struct`, `map`, `slice`, `array`, `pointer`, `string`\n    - `float64/float32`, `int/int8/int16/int32/int64/rune`\n    - `uint/uint8/uint16/uint32/uint64/byte`, `bool`, `interface`\n- [x] Customizable configuration.\n\n### Installation\n\n```bash\ngo get -u github.com/vpakhuchyi/censor\n```\n\n### Documentation\n\nFind detailed documentation and practical examples for **Censor** at https://vpakhuchyi.github.io/censor.   \n\n### Usage\n\n**Censor** is a versatile tool designed to mask sensitive information in your Go applications, ensuring that\nonly specified data is displayed. It can be seamlessly integrated into your code to enhance security,\nparticularly in scenarios like logging where inadvertent exposure of sensitive data is a concern.\n\n```go\npackage main\n\nimport (\n  \"fmt\"\n  \"log/slog\"\n\n  \"github.com/vpakhuchyi/censor\"\n)\n\ntype request struct {\n  UserID   string  `censor:\"display\"` // Display value.\n  Address  address `censor:\"display\"`\n  Email    string  // Mask value.\n  FullName string\n}\n\ntype address struct {\n  City    string `censor:\"display\"`\n  Country string `censor:\"display\"`\n  Street  string\n  Zip     int\n}\n\n// Here is a request struct that contains sensitive information: Email, FullName and Password.\n// We could log only UserID, but it's much easier to control what we're logging by using **censor** \n// instead of checking each log line and making sure that we're not logging sensitive information.\nfunc main() {\n  r := request{\n    UserID:   \"123\",\n    Address:  address{City: \"Kharkiv\", Country: \"UA\", Street: \"Nauky Avenue\", Zip: 23335},\n    Email:    \"viktor.example.email@ggmail.com\",\n    FullName: \"Viktor Pakhuchyi\",\n  }\n\n  // In this example we're using censor as a global package-level variable with default configuration.\n  fmt.Println(string(censor.Any(r)))\n}\n\n// Here is what we'll see in the log:\n// {\"UserID\": \"123\",\"Address\": {\"City\": \"Kharkiv\",\"Country\": \"UA\",\"Street\": \"[CENSORED]\",\"Zip\": \"[CENSORED]\"},\"Email\": \"[CENSORED]\",\"FullName\": \"[CENSORED]\"}\n\n// All the fields values are masked by default (recursively) except \n// those fields that has specified `censor:\"display\"` tag.\n```\n\n### Handler for \"log/slog\"\n\nImport the `sloghandler` package that provides a handler for the `log/slog` package.\n\n```go\n  import \"github.com/vpakhuchyi/censor/sloghandler\"\n```\n\nInitialize a new censor instance and wrap the slog core with it:\n\n```go\n  // Define the configuration.  \n  cfg := censor.Config{\n    Encoder: censor.EncoderConfig{\n      DisplayMapType:       true,\n      MaskValue:      \"[CENSORED]\", \n      // Other configuration options...\n    },\n  }\n  \n  // Initialize a censor instance with the specified configuration.\n  c, err := censor.NewWithOpts(censor.WithConfig(\u0026cfg))\n  if err != nil {\n    // Handle error.\n  }\n  \n  // Create and register a new slog handler with the initialized instance.\n  opts := []sloghandler.Option{sloghandler.WithCensor(c)}\n  log := slog.New(sloghandler.NewJSONHandler(opts...))\n\n  // Use logger as usually.\n  log.Info(\"user\", slog.Any(\"payload\", payload))\n```\n\n### Handler for \"go.uber.org/zap\" \n\nImport the `zaphandler` package that provides a handler for the `go.uber.org/zap` package.\n\n```go\n  import \"github.com/vpakhuchyi/censor/zaphandler\"\n```\n\nInitialize a new censor instance and wrap the zap core with it:\n\n```go\n  // Define the configuration.  \n  cfg := censor.Config{\n    Encoder: censor.EncoderConfig{\n      DisplayMapType:       true,\n      MaskValue:      \"[CENSORED]\",\n      // Other configuration options...\n    },\n  }\n\n  // Initialize a censor instance with the specified configuration.\n  c, err := censor.NewWithOpts(censor.WithConfig(\u0026cfg))\n  if err != nil {\n    // Handle error.\n  }\n  \n  // Wrap the zap core with the Censor handler.\n  o := zap.WrapCore(func(core zapcore.Core) zapcore.Core {\n    return zaphandler.NewHandler(core, zaphandler.WithCensor(c))\n  })\n\n  // Initialize a new zap logger instance.\n  l, err := zap.NewProduction(o)\n  if err != nil {\n    // Handle error.\n  }\n  \n  // Use logger as usually.\n  l.Info(\"user\", zap.Any(\"payload\", payload))\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvpakhuchyi%2Fcensor","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvpakhuchyi%2Fcensor","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvpakhuchyi%2Fcensor/lists"}