{"id":46456075,"url":"https://github.com/iamwavecut/tool","last_synced_at":"2026-03-06T01:53:25.050Z","repository":{"id":59943069,"uuid":"540123329","full_name":"iamwavecut/tool","owner":"iamwavecut","description":null,"archived":false,"fork":false,"pushed_at":"2025-11-20T13:40:13.000Z","size":67,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-11-20T15:25:37.143Z","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/iamwavecut.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":"2022-09-22T18:45:19.000Z","updated_at":"2025-11-20T13:38:14.000Z","dependencies_parsed_at":"2024-06-08T16:24:37.392Z","dependency_job_id":"c4cd4f7c-a725-44f2-aa00-e9a6fa51475f","html_url":"https://github.com/iamwavecut/tool","commit_stats":{"total_commits":19,"total_committers":1,"mean_commits":19.0,"dds":0.0,"last_synced_commit":"135c5de46745a701e99bd5e8225e640373a271ce"},"previous_names":[],"tags_count":23,"template":false,"template_full_name":null,"purl":"pkg:github/iamwavecut/tool","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iamwavecut%2Ftool","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iamwavecut%2Ftool/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iamwavecut%2Ftool/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iamwavecut%2Ftool/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/iamwavecut","download_url":"https://codeload.github.com/iamwavecut/tool/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iamwavecut%2Ftool/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30158233,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-05T22:39:40.138Z","status":"ssl_error","status_checked_at":"2026-03-05T22:39:24.771Z","response_time":93,"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-03-06T01:53:24.406Z","updated_at":"2026-03-06T01:53:25.042Z","avatar_url":"https://github.com/iamwavecut.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# 🛠️ Tool Utilities\n\n[![Go Reference](https://pkg.go.dev/badge/github.com/iamwavecut/tool.svg)](https://pkg.go.dev/github.com/iamwavecut/tool)\n[![Go Report Card](https://goreportcard.com/badge/github.com/iamwavecut/tool)](https://goreportcard.com/report/github.com/iamwavecut/tool)\n[![Test Coverage](https://img.shields.io/badge/coverage-TBD-lightgrey)](https://goreportcard.com/report/github.com/iamwavecut/tool) \n\nThis library provides a collection of utility functions designed to simplify common tasks and improve code robustness. It includes a main `tool` package and a `safetool` sub-package, where functions are designed to return errors instead of panicking.\n\n## ✨ Features\n\n-   **Convenient Utilities**: A collection of helper functions for various tasks.\n-   **Safe Alternatives**: The `safetool` sub-package offers functions that return errors, promoting more resilient error handling.\n-   **Well-Tested**: Includes a comprehensive test suite to ensure reliability.\n\n## 🚀 Installation\n\nTo install the `tool` package, use `go get`:\n\n```bash\ngo get -u github.com/iamwavecut/tool\n```\n\n## 📦 Packages\n\nThis repository contains the following main packages:\n\n### `tool`\n\nThe main package containing various utility functions. These functions will return zero values or errors instead of panicking on unexpected input or errors.\n\n### `safetool`\n\nThe `safetool` package provides alternative implementations of functions found in the `tool` package. These \"safe\" versions are designed to return an `error` instead of muting errors, allowing for more controlled error handling in your applications.\n\n---\n\n#### Common exported functions (with identical interfaces in both packages):\n\n*   `In(needle, ...haystack) bool` - deprecated in favor of `slices.Contains`\n*   `IsZero(comparable) bool` - returns true if the value is the zero value for its type\n*   `NilPtr(comparable) *comparable` - returns a pointer to the input value if it's not zero, otherwise returns nil\n*   `NonZero(comparable) comparable` - returns the first non-zero value from the input arguments\n*   `Ptr(any) *any` - returns a pointer to the input value\n*   `RetryFunc(attempts int, sleep time.Duration, f func() error) error` - retries a function with exponential backoff\n*   `Strtr(subject string, oldToNew map[string]string) string` - replaces substrings in a string based on a mapping\n*   `Val(*any) any` - returns the value pointed to by the pointer, or zero value if pointer is nil\n*   `ZeroVal(any) any` - returns the zero value of the type, regardless of the input value\n\n---\n\n#### `tool`-specific exported functions:\n\n*   `Catch(func(error))` - catches panics and calls a function with the error\n*   `Console(...any)` - prints to the console\n*   `ConvertSlice([]T, Y) []Y` - converts a slice of one type to another\n*   `Err(...any) error` - returns an error with the input arguments\n*   `ExecTemplate(string, []|map) string` - executes a template\n*   `Jsonify(any) safetool.Varchar` - returns a Varchar from the input value\n*   `MultiMute(...any) []any` - returns a slice of the input arguments with no latest error\n*   `Must(error, verbose ?bool)` - panics if the error is not nil\n*   `MustReturn(any, error) any` - panics if the error is not nil\n*   `Objectify(in any, target any) bool` - decodes a JSON string into the target object\n*   `RandInt(min, max int) int` - returns a random integer between min and max\n*   `Recoverer(maxPanics int, f func(), jobID ...string) error` - recovers from panics and returns the error\n*   `Return(any, _ error) any` - returns the input value\n*   `SetLogger(l StdLogger)` - sets the logger\n*   `Try(err error, verbose ?bool) bool` - returns true if the error is nil\n\n---\n\n#### `safetool`-specific exported functions:\n\n*   `ConvertSlice([]T, Y) ([]Y, error)` - converts a slice of one type to another\n*   `ExecTemplate(string, []|map) (string, error)` - executes a template\n*   `FindRootCaller() string` - returns the root caller filepath of the application\n*   `GetRelativePath(string) (string, error)` - returns a relative path from the directory of the root caller to the given filePath\n*   `Jsonify(any) (safetool.Varchar, error)` - returns an encoded JSON string from the input value represented as a `Varchar`\n*   `Objectify(in any, target any) error` - decodes a JSON string into the target object\n*   `RandInt(min, max int) (int, error)` - returns a random integer between min and max\n*   `Zero(any) any` - returns the zero value for the input type\n\n## 🤝 Contributing\n\nContributions are welcome! Please feel free to submit a pull request or open an issue if you have suggestions or find a bug.\n\n1.  Fork the Project\n2.  Create your Feature Branch (`git checkout -b feature/AmazingFeature`)\n3.  Commit your Changes (`git commit -m 'Add some AmazingFeature'`)\n4.  Push to the Branch (`git push origin feature/AmazingFeature`)\n5.  Open a Pull Request\n\n## 📜 License\n\nThis project is licensed under the [MIT License](LICENSE).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fiamwavecut%2Ftool","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fiamwavecut%2Ftool","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fiamwavecut%2Ftool/lists"}