{"id":17678498,"url":"https://github.com/devdrops/dm-go","last_synced_at":"2025-03-30T18:17:20.426Z","repository":{"id":44715343,"uuid":"447039630","full_name":"devdrops/dm-go","owner":"devdrops","description":"Reusable packages and frameworks for Go services","archived":false,"fork":false,"pushed_at":"2022-01-29T01:44:24.000Z","size":44,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-02-05T20:42:19.986Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/devdrops.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-01-12T01:41:49.000Z","updated_at":"2022-01-29T01:32:36.000Z","dependencies_parsed_at":"2022-09-17T08:10:46.365Z","dependency_job_id":null,"html_url":"https://github.com/devdrops/dm-go","commit_stats":null,"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devdrops%2Fdm-go","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devdrops%2Fdm-go/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devdrops%2Fdm-go/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devdrops%2Fdm-go/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/devdrops","download_url":"https://codeload.github.com/devdrops/dm-go/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246358322,"owners_count":20764366,"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":[],"created_at":"2024-10-24T08:05:01.510Z","updated_at":"2025-03-30T18:17:20.402Z","avatar_url":"https://github.com/devdrops.png","language":"Go","readme":"# dm-go\n\nReusable packages and frameworks for Go services\n\n## Installation\n\n```bash\ngo get github.com/delivery-much/dm-go\n```\n\n## Packages\n\nImplemented packages in project, their use and some examples.\n\n### Logger\n\nPackage for log application, ready for production (JSON) and development. Construct the log with some parameters: if is json, the level and some base fields that will appear in all output logs. Using the Sugar [zap](https://github.com/uber-go/zap) package.\n\nLevel: `debug`, `info` (default), `warn`, `error`, `fatal`\n\nExample:\n\n```go\nconfig := logger.Configuration{\n    IsJSON: true,\n    Level:  \"info\",\n    BaseFields: logger.BaseFields{\n        ServiceName: \"default-service\",\n        CodeVersion: \"1.0.0\",\n        Env:         \"production\",\n    },\n}\nerr := logger.NewLogger(config)\nif err != nil {\n    panic(err)\n}\n\nlogger.Infow(\"failed to fetch URL\",\n    // Key and value after the message\n    \"url\", \"www.google.com\",\n    \"attempt\", 3,\n    \"backoff\", time.Second,\n)\n```\n\n### Middleware\n\nPackage with some middleware for routes and service.\n\nExample:\n\n```go\n// Middleware for generate or inject request id in context of request.\nrouter.Use(\n    middleware.RequestID(\"Key-Request-Id\"),\n)\n```\n\n### New Relic\n\nPackage with some helpers/middleware for send events to New Relic.\n\nExample:\n\n```go\nInitNewRelic(\"app-teste\", \"1234\")\n\n// Func for database monitoring\nnewRelicSegment := StartNewRelicDBSegment(ctx.Background(), \"select\", \"user\")\ndefer newRelicSegment()\n\n// Middleware for instruments handler functions using transactions and monitoring the route \nrouter.Post(newrelic.WrapHandleFunc(\"/test\", h.handleTest()))\n```\n\n### Render\n\nPackage with some helpers for render responses. To respond in JSON format.\n\n### String Utils\n\nPackage with some utility functions for string transformation\n\n#### MaskString(str string) string\n- MaskString masks the last half of a given string, changing any letter or number character to '*'\nExample:\n```golang\nMaskString(\"examplestring\") // returns \"exampl*******\"\nMaskString(\"\") // returns \"\"\n```\n\n#### MaskEmail(email string) string\n- MaskEmail masks an email string,\nleaving only the first four letters of the email id (i.e the part before the '@') and the email domain unmasked.\nif the email id has 4 or less characters, leaves only 1 character unmasked.\nExample:\n```golang\nMaskEmail(\"email_id@domain.com\") // returns \"emai*_**@domain.com\"\nMaskEmail(\"0101@domain.com\") // returns \"0***@domain.com\"\nMaskEmail(\"notanemail.com\") // returns \"notanemail.com\"\nMaskEmail(\"\") //returns \"\"\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdevdrops%2Fdm-go","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdevdrops%2Fdm-go","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdevdrops%2Fdm-go/lists"}