{"id":34842327,"url":"https://github.com/serialt/sugar","last_synced_at":"2026-05-25T04:34:20.343Z","repository":{"id":53472702,"uuid":"517193309","full_name":"serialt/sugar","owner":"serialt","description":"Lib for sugar","archived":false,"fork":false,"pushed_at":"2023-11-27T16:21:48.000Z","size":76,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"v3","last_synced_at":"2025-12-27T02:20:45.973Z","etag":null,"topics":[],"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/serialt.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":"2022-07-24T00:31:21.000Z","updated_at":"2022-10-06T09:44:59.000Z","dependencies_parsed_at":"2023-11-27T17:31:37.694Z","dependency_job_id":"89b1b3ba-72ea-4c73-bea3-cad4a6042b0d","html_url":"https://github.com/serialt/sugar","commit_stats":null,"previous_names":[],"tags_count":22,"template":false,"template_full_name":null,"purl":"pkg:github/serialt/sugar","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/serialt%2Fsugar","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/serialt%2Fsugar/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/serialt%2Fsugar/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/serialt%2Fsugar/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/serialt","download_url":"https://codeload.github.com/serialt/sugar/tar.gz/refs/heads/v3","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/serialt%2Fsugar/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33461089,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-25T02:24:28.008Z","status":"ssl_error","status_checked_at":"2026-05-25T02:23:23.339Z","response_time":57,"last_error":"SSL_read: 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":[],"created_at":"2025-12-25T17:13:35.931Z","updated_at":"2026-05-25T04:34:20.332Z","avatar_url":"https://github.com/serialt.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# sugar lib\n\n封装好的一些常用方法\n\n### 使用方法\n\n```\ngo get github.com/serialt/sugar/v3\n\ngo get golang.org/x/exp/slog\n\n```\n\n### 库使用方法\n\n#### 简单使用日志\n\n```go\npackage main\n\nimport (\n\t\"github.com/serialt/sugar/v3\"\n\t\"golang.org/x/exp/slog\"\n)\n\nfunc init() {\n\tslog.SetDefault(sugar.New())\n}\n\nfunc main() {\n\tslog.Debug(\"debug\", \"hello\", \"world\")\n\tslog.Info(\"info\", \"hello\", \"world\")\n\tslog.Error(\"error\", \"hello\", \"world\")\n}\n\n```\n\n#### 可选参数\n\n```go\npackage main\n\nimport (\n\tsugar \"github.com/serialt/sugar/v3\"\n\t\"golang.org/x/exp/slog\"\n)\n\nfunc init() {\n\tslog.SetDefault(sugar.New(\n\t\tsugar.WithLevel(\"debug\"),\n\t))\n}\nfunc main() {\n\n\tslog.Debug(\"debug msg\")\n\tslog.Info(\"info msg\")\n}\n\n```\n\n\n#### 复杂使用\n```go\npackage main\n\nimport (\n\tsugar \"github.com/serialt/sugar/v3\"\n\tflag \"github.com/spf13/pflag\"\n\t\"golang.org/x/exp/slog\"\n)\n\ntype Config struct {\n\tServer   string\n\tPort     string\n\tLogLevel string\n}\n\nvar (\n\tcfgfile string\n\tconfig  *Config\n)\n\nfunc init() {\n\n\tflag.StringVarP(\u0026cfgfile, \"config\", \"c\", \"config.yaml\", \"Config file\")\n\tflag.CommandLine.SortFlags = false\n\tflag.Parse()\n\n\terr := sugar.LoadConfig(cfgfile, \u0026config)\n\tif err != nil {\n\t\tconfig = new(Config)\n\t}\n\tslog.SetDefault(sugar.New(\n\t\tsugar.WithLevel(config.LogLevel),\n\t))\n}\nfunc main() {\n\tslog.Info(\"struct\", \"cfg\", config)\n\tslog.Debug(\"debug msg\")\n\tslog.Info(\"info msg\")\n}\n\n```\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fserialt%2Fsugar","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fserialt%2Fsugar","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fserialt%2Fsugar/lists"}