{"id":15490551,"url":"https://github.com/theodesp/go-invariant","last_synced_at":"2025-03-28T16:27:51.549Z","repository":{"id":57708839,"uuid":"57141111","full_name":"theodesp/go-invariant","owner":"theodesp","description":"A way to provide descriptive errors in development but generic errors in production for go programs.","archived":false,"fork":false,"pushed_at":"2018-10-09T08:36:10.000Z","size":832,"stargazers_count":1,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-10-19T09:18:37.784Z","etag":null,"topics":["golang","invariant"],"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/theodesp.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-04-26T15:45:10.000Z","updated_at":"2018-10-09T08:36:11.000Z","dependencies_parsed_at":"2022-09-26T21:20:40.585Z","dependency_job_id":null,"html_url":"https://github.com/theodesp/go-invariant","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/theodesp%2Fgo-invariant","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/theodesp%2Fgo-invariant/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/theodesp%2Fgo-invariant/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/theodesp%2Fgo-invariant/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/theodesp","download_url":"https://codeload.github.com/theodesp/go-invariant/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246061830,"owners_count":20717511,"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":["golang","invariant"],"created_at":"2024-10-02T07:22:04.387Z","updated_at":"2025-03-28T16:27:51.517Z","avatar_url":"https://github.com/theodesp.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# go-invariant\n\nA way to provide descriptive errors in development but generic errors in production.\n\nInstall\n=============\n\n```bash\n\ngo get github.com/theodesp/go-invariant\n\n```\n\n\nUsage\n====\n\nIt's intended for projects which require a simple invariant check and display\nof error messages depending on the current env variables\n\nExamples:\n\n```go\n// main.go\npackage main\n\nimport (\n\t\"github.com/theodesp/go-invariant\"\n\t\"fmt\"\n)\n\nfunc main() {\n\tres:= invariant.Invariant(1!=1,\"\")\n\tfmt.Println(res)\n}\n\n```\nand run on the command line\n```bash\n$ go run main.go\n    invariant requires an error message argument\n\n$ go run main.go -env production\n    invariant exception in production environment. Please use development flag to see the full error message\n```\n\n```go\n// main.go\npackage main\n\nimport (\n\t\"github.com/theodesp/go-invariant\"\n\t\"fmt\"\n)\n\nfunc main() {\n\tres:= invariant.Invariant(1!=1,\"You must say %s when talking to Dragons\", \"your majesty\")\n\tfmt.Println(res)\n}\n\n```\nand run on the command line\n```bash\n$ go run main.go\n    You must say your majesty when talking to Dragons\n\n$ go run main.go -env production\n    invariant exception in production environment. Please use development flag to see the full error message\n```\n\nNote: When **env** environment variable or command line switch\nis not *production*, the message is required.\nIf omitted, invariant will throw regardless of the truthness of the condition.\nWhen **env** is *production*, the message will be a generic one so it can be stripped away\nBy default **env** is assumed to be *development*.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftheodesp%2Fgo-invariant","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftheodesp%2Fgo-invariant","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftheodesp%2Fgo-invariant/lists"}