{"id":43270611,"url":"https://github.com/treeder/gotils","last_synced_at":"2026-02-01T15:41:34.655Z","repository":{"id":56338009,"uuid":"185657090","full_name":"treeder/gotils","owner":"treeder","description":null,"archived":false,"fork":false,"pushed_at":"2024-09-05T23:43:24.000Z","size":137,"stargazers_count":6,"open_issues_count":5,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-08-14T01:14:17.819Z","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":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/treeder.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":"2019-05-08T18:11:50.000Z","updated_at":"2024-10-16T07:01:33.000Z","dependencies_parsed_at":"2024-06-20T22:09:06.181Z","dependency_job_id":null,"html_url":"https://github.com/treeder/gotils","commit_stats":null,"previous_names":[],"tags_count":70,"template":false,"template_full_name":null,"purl":"pkg:github/treeder/gotils","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/treeder%2Fgotils","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/treeder%2Fgotils/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/treeder%2Fgotils/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/treeder%2Fgotils/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/treeder","download_url":"https://codeload.github.com/treeder/gotils/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/treeder%2Fgotils/sbom","scorecard":{"id":897692,"data":{"date":"2025-08-11","repo":{"name":"github.com/treeder/gotils","commit":"077d86644352d31b326eee6289cf11ccb5c08280"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":3.8,"checks":[{"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":"SAST","score":0,"reason":"no SAST tool detected","details":["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":"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":"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":"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":"Token-Permissions","score":0,"reason":"detected GitHub workflow tokens with excessive permissions","details":["Warn: no topLevel permission defined: .github/workflows/main.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":"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/main.yml:14: update your workflow using https://app.stepsecurity.io/secureworkflow/treeder/gotils/main.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/main.yml:16: update your workflow using https://app.stepsecurity.io/secureworkflow/treeder/gotils/main.yml/master?enable=pin","Warn: downloadThenRun not pinned by hash: .github/workflows/main.yml:29","Info:   0 out of   2 GitHub-owned GitHubAction dependencies pinned","Info:   0 out of   1 downloadThenRun 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":"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":"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":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: Apache License 2.0: 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":"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":"Branch-Protection","score":-1,"reason":"internal error: error during branchesHandler.setup: internal error: githubv4.Query: Resource not accessible by integration","details":null,"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":10,"reason":"0 existing vulnerabilities detected","details":null,"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-24T14:21:50.467Z","repository_id":56338009,"created_at":"2025-08-24T14:21:50.467Z","updated_at":"2025-08-24T14:21:50.467Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28981456,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-01T15:35:50.179Z","status":"ssl_error","status_checked_at":"2026-02-01T15:35:38.075Z","response_time":56,"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":[],"created_at":"2026-02-01T15:41:34.587Z","updated_at":"2026-02-01T15:41:34.651Z","avatar_url":"https://github.com/treeder.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# gotils\n\nThis is where I experiment with Go stuff.\n\n[![Go Reference](https://pkg.go.dev/badge/github.com/treeder/gotils/v2.svg)](https://pkg.go.dev/github.com/treeder/gotils/v2)\n\n## Installing\n\n```\nimport \"github.com/treeder/gotils/v2\"\n```\n\n## Logging\n\n[A blog post about this](https://betterprogramming.pub/fun-or-not-with-golang-errors-26b2b0e231c5)\n\nWhy? I was getting annoyed with things like this all over the place:\n\n```go\nif err != nil {\n    log.Error(\"something bad\", zap.Error(err)) // log something here with your favorite logging library\n    return fmt.Errorf(\"something bad:\", err)\n}\n```\n\nThen as it goes back down the stack you don't know if you logged already or not so you keep logging and get duplicate messages. And you can't just pass the error back and log before you return the error because you lose all the context\nthat you added to the logging library via the structured fields and you lose the stacktrace. \n\n[Read more here](https://github.com/treeder/gotils/issues/2)\n\nSo I started thinking how to make this better by adding context to errors rather than to the logging library. I\nam aware of the [pkg/errors](https://github.com/pkg/errors) lib, but it's in maintenance mode now and isn't compatible\nwith the new error features (ie: error wrapping) and it doesn't let you add fields.\n\nSo a few things I'm trying here:\n\n1. Add context along the way\n1. Collect stacktrace at the deepest point where the error happens (as close to the root error as possible)\n1. Write error message, context fields and stacktrace in the appropriate format for your logging system\n\n```go\n// Add context:\nctx = gotils.With(ctx, \"foo\", \"bar\")\n// Return errors with embedded stacktrace\nreturn gotils.C(ctx).Errorf(\"something bad happened: %v\", err)\n// Then log it wherever you want:\nif err != nil {\n    // this writes to your provided logger or the console if no logger set in SetLoggable\n    gotils.Logf(ctx, \"error\", \"%v\", err)\n}\n```\n\nTo log in a particular format or to send them to another service, set a `Loggable` instance: \n\n```go\ngotils.SetLoggable(gcputils.NewLogger())\n```\n\n## HTTP Error Handler\n\nTo get use the above error context capturing and make HTTP error handling really clean and easy, try this.\n\nFirst have your http endpoint functions return an error:\n\n```go\nfunc foo(w http.ResponseWriter, r *http.Request) error {\n    // do stuff\n    return err\n}\n```\n\nThen wrap and add your http function like this:\n\n```go\nhttp.HandleFunc(\"/bar\", gotils.ErrorHandler(foo))\n```\n\nNow it will handle errors and return nice JSON error responses without you having to do anything.\n\n## HTTP Utils\n\n```go\n// GET JSON from API\nv := \u0026MyObject{}\nerr := gotils.GetJSON(url, v) // also GetString, GetBytes\n\n// POST JSON to an API\nerr := gotils.PostJSON(url, v)\n\n// And some response handling\ngotils.WriteObject(w, 200, v) // also WriteMessage, WriteError\n```\n\n## HTTP Handler utils\n\nUseful for creating APIs:\n\n```go\ninput := \u0026MyInput{}\nerr := gotils.ParseJSON(w, r, input)\nif err != nil {\n    return gotils.C(ctx).SetCode(http.StatusBadRequest).Errorf(\"invalid request input: %w\", err)\n}\n```\n\n\n## Update your installed Go Version\n\nThis is just a random utility to upgrade your Go version:\n\n```sh\ncurl -LSs https://raw.githubusercontent.com/treeder/gotils/master/update.sh | bash\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftreeder%2Fgotils","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftreeder%2Fgotils","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftreeder%2Fgotils/lists"}