{"id":22801513,"url":"https://github.com/better-go/pkg","last_synced_at":"2025-08-20T06:05:28.040Z","repository":{"id":40285284,"uuid":"268710160","full_name":"better-go/pkg","owner":"better-go","description":"golang pkg, common utils","archived":false,"fork":false,"pushed_at":"2023-05-05T02:43:31.000Z","size":825,"stargazers_count":28,"open_issues_count":13,"forks_count":7,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-04-19T20:19:49.711Z","etag":null,"topics":["common","golang","golang-library","golang-package","utils"],"latest_commit_sha":null,"homepage":"https://github.com/better-go/pkg/wiki","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/better-go.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}},"created_at":"2020-06-02T05:35:24.000Z","updated_at":"2024-09-19T17:50:40.000Z","dependencies_parsed_at":"2024-06-18T22:49:23.809Z","dependency_job_id":"355fd1ba-6f15-4ef7-ae88-17261136b939","html_url":"https://github.com/better-go/pkg","commit_stats":{"total_commits":175,"total_committers":3,"mean_commits":"58.333333333333336","dds":0.02285714285714291,"last_synced_commit":"f56a4571b836da72f4511ce502124dde57370c5f"},"previous_names":[],"tags_count":22,"template":false,"template_full_name":null,"purl":"pkg:github/better-go/pkg","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/better-go%2Fpkg","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/better-go%2Fpkg/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/better-go%2Fpkg/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/better-go%2Fpkg/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/better-go","download_url":"https://codeload.github.com/better-go/pkg/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/better-go%2Fpkg/sbom","scorecard":{"id":235261,"data":{"date":"2025-08-11","repo":{"name":"github.com/better-go/pkg","commit":"f56a4571b836da72f4511ce502124dde57370c5f"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":3.1,"checks":[{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Code-Review","score":0,"reason":"Found 0/30 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Token-Permissions","score":0,"reason":"detected GitHub workflow tokens with excessive permissions","details":["Warn: no topLevel permission defined: .github/workflows/codeql-analysis.yml:1","Warn: no topLevel permission defined: .github/workflows/sync.yml:1","Info: no jobLevel write permissions found"],"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Dangerous-Workflow","score":10,"reason":"no dangerous workflow patterns detected","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"SAST","score":10,"reason":"SAST tool detected: CodeQL","details":["Info: SAST configuration detected: CodeQL","Warn: no pull requests merged into dev branch"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Pinned-Dependencies","score":0,"reason":"dependency not pinned by hash detected -- score normalized to 0","details":["Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/codeql-analysis.yml:38: update your workflow using https://app.stepsecurity.io/secureworkflow/better-go/pkg/codeql-analysis.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/codeql-analysis.yml:42: update your workflow using https://app.stepsecurity.io/secureworkflow/better-go/pkg/codeql-analysis.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/codeql-analysis.yml:53: update your workflow using https://app.stepsecurity.io/secureworkflow/better-go/pkg/codeql-analysis.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/codeql-analysis.yml:67: update your workflow using https://app.stepsecurity.io/secureworkflow/better-go/pkg/codeql-analysis.yml/master?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/sync.yml:13: update your workflow using https://app.stepsecurity.io/secureworkflow/better-go/pkg/sync.yml/master?enable=pin","Info:   0 out of   4 GitHub-owned GitHubAction dependencies pinned","Info:   0 out of   1 third-party GitHubAction dependencies pinned"],"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: MIT License: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'master'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"Vulnerabilities","score":0,"reason":"39 existing vulnerabilities detected","details":["Warn: Project is vulnerable to: GO-2023-2402 / GHSA-45x7-px36-x8w8","Warn: Project is vulnerable to: GO-2024-3321 / GHSA-v778-237x-gjrc","Warn: Project is vulnerable to: GO-2025-3487 / GHSA-hcg3-q754-cr77","Warn: Project is vulnerable to: GO-2024-2611 / GHSA-8r3f-844c-mc37","Warn: Project is vulnerable to: GO-2022-0969 / GHSA-69cg-p879-7622","Warn: Project is vulnerable to: GO-2023-1495 / GHSA-fxg5-wq6x-vr4w","Warn: Project is vulnerable to: GO-2022-1144 / GHSA-xrjj-mj9h-534m","Warn: Project is vulnerable to: GO-2023-1571 / GHSA-vvpx-j8f3-3w6h","Warn: Project is vulnerable to: GO-2023-1988 / GHSA-2wrh-6pvc-2jm9","Warn: Project is vulnerable to: GO-2023-2102 / GHSA-4374-p667-p6c8","Warn: Project is vulnerable to: GO-2023-2153 / GHSA-m425-mq94-257g / GHSA-qppj-fm5r-hxr3","Warn: Project is vulnerable to: GO-2024-2687 / GHSA-4v7x-pqxf-cx7m","Warn: Project is vulnerable to: GO-2024-3333","Warn: Project is vulnerable to: GO-2025-3503 / GHSA-qxp5-gwg8-xv66","Warn: Project is vulnerable to: GO-2025-3595 / GHSA-vvgc-356p-c3xw","Warn: Project is vulnerable to: GO-2022-1059 / GHSA-69ch-w2m2-3vjp","Warn: Project is vulnerable to: GHSA-3vp4-m3rf-835h","Warn: Project is vulnerable to: GO-2023-1737 / GHSA-2c4m-59x9-fr2g","Warn: Project is vulnerable to: GO-2020-0017 / GHSA-w73w-5m7g-f7qc","Warn: Project is vulnerable to: GO-2024-2456 / GHSA-449p-3h89-pw88","Warn: Project is vulnerable to: GO-2024-2466 / GHSA-mw99-9chc-xw7r","Warn: Project is vulnerable to: GO-2025-3367 / GHSA-r9px-m959-cxf4","Warn: Project is vulnerable to: GO-2025-3368 / GHSA-v725-9546-7q7m","Warn: Project is vulnerable to: GO-2021-0053 / GHSA-c3h9-896r-86jm","Warn: Project is vulnerable to: GO-2022-0380 / GHSA-2c64-vj8g-vwrq / GHSA-4w5x-x539-ppf5","Warn: Project is vulnerable to: GO-2022-0402 / GHSA-h2fg-54x9-5qhq / GHSA-hmm9-r2m2-qg9w","Warn: Project is vulnerable to: GO-2022-0386 / GHSA-62mh-w5cv-p88c","Warn: Project is vulnerable to: GO-2022-0968 / GHSA-gwc9-m7rh-j2ww","Warn: Project is vulnerable to: GO-2021-0356 / GHSA-8c26-wmh5-6g9v","Warn: Project is vulnerable to: GO-2024-2961","Warn: Project is vulnerable to: GO-2022-0236 / GHSA-h86h-8ppg-mxmh","Warn: Project is vulnerable to: GO-2021-0238 / GHSA-83g2-8m93-v3w7","Warn: Project is vulnerable to: GO-2022-0288","Warn: Project is vulnerable to: GO-2022-0493 / GHSA-p782-xgp4-8hr8","Warn: Project is vulnerable to: GO-2021-0113 / GHSA-ppp9-7jff-5vj2","Warn: Project is vulnerable to: GO-2024-3250 / GHSA-29wx-vh33-7x7r","Warn: Project is vulnerable to: GO-2025-3553 / GHSA-mh63-6h87-95cp","Warn: Project is vulnerable to: GO-2024-2604 / GHSA-fgxv-gw55-r5fq","Warn: Project is vulnerable to: GO-2025-3488 / GHSA-6v2p-p543-phr9"],"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}}]},"last_synced_at":"2025-08-17T05:34:14.115Z","repository_id":40285284,"created_at":"2025-08-17T05:34:14.115Z","updated_at":"2025-08-17T05:34:14.115Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":271273949,"owners_count":24730897,"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","status":"online","status_checked_at":"2025-08-20T02:00:09.606Z","response_time":69,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":["common","golang","golang-library","golang-package","utils"],"created_at":"2024-12-12T08:11:17.736Z","updated_at":"2025-08-20T06:05:27.877Z","avatar_url":"https://github.com/better-go.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# pkg\n\n[![Go Version](https://img.shields.io/github/go-mod/go-version/better-go/pkg?filename=go.mod)](https://github.com/better-go/pkg/blob/master/go.mod)\n[![Go Report Card](https://goreportcard.com/badge/github.com/better-go/pkg)](https://goreportcard.com/report/github.com/better-go/pkg)\n[![](https://img.shields.io/github/release/better-go/pkg.svg?label=Release)](https://github.com/better-go/pkg/releases)\n[![Release Date](https://img.shields.io/github/release-date/better-go/pkg)](https://github.com/better-go/pkg/releases)\n[![MIT License](https://img.shields.io/github/license/better-go/pkg)](https://github.com/better-go/pkg/blob/master/LICENSE)\n[![Stars](https://img.shields.io/github/stars/better-go/pkg?style=social)](https://img.shields.io/github/stars/better-go/pkg?style=social)\n\n- [x] golang pkg, common utils\n- [x] 集成各种常用 lib, 开箱即用\n\n## related:\n\n- https://github.com/better-go/cookiecutter-go\n    - `go 微服务`: 项目创建脚手架.\n\n## quickstart:\n\n- ✅ 使用 [go.work](go.work) 拆分子包\n    - [log](log)\n    - [database](database)\n    - [x/gin](x/gin)\n    - [x/go-zero](x/go-zero)\n    - [x/go-micro](x/go-micro)\n\n\u003e 快速导包：\n\n- ✅ 导入包：\n\n```go\nimport (\n// 子包\n\"github.com/better-go/pkg/log\"\n\n)\n\n```\n\n- ✅ install:\n\n```bash\n\n# use latest version:\ngo get -u -v github.com/better-go/pkg\n\n# use specific tag:\ngo get -u -v github.com/better-go/pkg@v0.2.0\n\n```\n\n- ✅ usage:\n\n```golang\n\nimport (\n\"github.com/better-go/pkg/random\"\n)\n\nfunc Example() {\n// snowflake id:\nuserID := random.SnowFlakeID()\nfmt.Printf(\"userID:%v\\n\", userID)\n}\n\n```\n\n## features:\n\n- [x] `log`: [log/log.go](log/log.go) 集成 `uber.log`, 开箱即用.\n- [x] sync/async: `go func()` 优雅异步.\n- [x] `retry`: 通用重试wrap: 支持 backoff\n- [x] `orm` 集成: `gorm` 扩展\n    - mysql 支持\n    - 集成 `gorm v1, v2` 版本\n- [x] `cache`: 集成 `redis`\n- [x] `mq`:\n    - [x] kafka: 集成 `kafka`\n    - [x] rabbitmq: 集成 `rabbitmq`, 有详细使用示例代码\n        - 生产者: [mq/rabbitmq/producer.go](mq/rabbitmq/producer.go)\n        - 消费者: [mq/rabbitmq/consumer.go](mq/rabbitmq/consumer.go)\n- [x] `net`:\n    - [x] http: 集成 `gin` + `auth` API 路由鉴权\n    - [x] websocket: 集成 `websocket`, 双向通信, 有详细使用示例代码\n        - server: [net/ws/websocket_server.go](net/ws/websocket_server.go)\n            - usage: [net/ws/example/ws_server.go](net/ws/example/ws_server.go)\n    - [x] socketIO: 类似 `websocket`, 双向通信, 有详细使用示例代码\n        - server:\n            - usage: [net/ws/example/socket_io/socket_io_server.go](net/ws/example/socket_io/socket_io_server.go)\n    - [x] graphql: 集成\n        - client: [net/graphql/graphql_client.go](net/graphql/graphql_client.go)\n        - server: [net/graphql/graphql_server.go](net/graphql/graphql_server.go)\n- [x] `config`:\n    - [x] toml 格式配置文件读取\n- [x] `random`:\n    - [x] `uuid`: ID 生成器\n    - [x] `snowflake`: twitter 雪花算法: 18位纯数字(有序+递增+唯一)\n- [x] `text`:\n    - [x] xss: 预防 xss 校验\n- [x] `time`: 大量时间方法扩展\n    - 生成时间戳\n- [x] [container](container): 扩展数据类型\n    - [dict](container/dict/dict.go): 字典数据类型\n        - [StringDict](container/dict/string.go): `map[string]string` 扩展, 支持生成 `url encode string`\n        - [Dict](): `map[string]interface{}` 扩展\n- [x] [convert](convert): 数据格式转换工具\n    - [string](convert/string.go): `string to int`, `int to string`\n    - [struct](convert/struct.go): `struct` 转换成 `map[string][]string`\n    - [map](convert/map.go): `map[string][]string` 转换成 `map[string]string`\n- [x] [crypto](crypto)`: 加密/解密工具\n    - [x] [signature](crypto/signature/sign.go): 通用签名机制: 生成/验证 - 支持 `md5/sha256/sha512` + `nonce` + `ts`\n    - [x] [password](crypto/password.go): 密码: 加密/验证 - 使用 `bcrypt` 算法\n- [x] `com`: 第三方企业 API SDK 接入\n    - [x] jpush: 极光推送\n    - [x] sendcloud: 搜狐短信服务\n- [x] [cronjob](cronjob/cron.go): 集成 `cron job` 库, 开箱即用,\n    - 使用示例: [cronjob/example/example.go](cronjob/example/example.go)\n- [x] `x`: 扩展一些框架\n    - [x] `gin`: 扩展代码\n        - 路由 wrap: [x/gin/router.go](x/gin/router.go) 自动处理 request args binding 和 response\n    - [x] `go-micro`:\n    - [x] `go-zero`:\n        - [x] 微服务启动器: [x/go-zero/cmd/cmd.go](x/go-zero/cmd/cmd.go)\n\n## wiki:\n\n- https://github.com/better-go/pkg/wiki\n- go 编程规范\n\n## development:\n\n- setup:\n\n```bash\n\n# required tool:\nbrew install go-task/tap/go-task\n\n# this project root folder:\ncd pkg/\n\n# init:\ntask init\n\n# get go pkg:\ntask tidy\n\n```\n\n## reference:\n\n- uber.log\n- 目录结构参考: https://github.com/micro/go-plugins\n- 目录风格, 参考 go 标准库, 以及 `x` 库\n    - https://pkg.go.dev/search?q=golang.org/x\n- https://github.com/golang/text\n\n```bash\n\ngo get golang.org/x/text\ngo get golang.org/x/oauth2\ngo get golang.org/x/net\ngo get golang.org/x/crypto\n\n```\n\n## research:\n\n- https://go.libhunt.com/\n    - go pkg diff\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbetter-go%2Fpkg","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbetter-go%2Fpkg","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbetter-go%2Fpkg/lists"}