{"id":27880851,"url":"https://github.com/atomicgo/constraints","last_synced_at":"2025-05-05T04:38:40.311Z","repository":{"id":205538641,"uuid":"714487366","full_name":"atomicgo/constraints","owner":"atomicgo","description":"🦖 Drop-in replacement for golang.org/x/exp/constraints with more predefined constraints","archived":false,"fork":false,"pushed_at":"2024-08-08T17:04:08.000Z","size":38,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-12-10T21:43:25.253Z","etag":null,"topics":["atomicgo","constraints","generics","go","golang","golang-library","hacktoberfest"],"latest_commit_sha":null,"homepage":"https://atomicgo.dev","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/atomicgo.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},"funding":{"github":["MarvinJWendt"]}},"created_at":"2023-11-05T01:46:41.000Z","updated_at":"2024-08-08T17:04:11.000Z","dependencies_parsed_at":null,"dependency_job_id":"c2880e4d-1b7c-4d85-8e76-720b138d3d18","html_url":"https://github.com/atomicgo/constraints","commit_stats":null,"previous_names":["atomicgo/constraints"],"tags_count":2,"template":false,"template_full_name":"atomicgo/template","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/atomicgo%2Fconstraints","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/atomicgo%2Fconstraints/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/atomicgo%2Fconstraints/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/atomicgo%2Fconstraints/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/atomicgo","download_url":"https://codeload.github.com/atomicgo/constraints/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252442480,"owners_count":21748448,"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":["atomicgo","constraints","generics","go","golang","golang-library","hacktoberfest"],"created_at":"2025-05-05T04:38:39.597Z","updated_at":"2025-05-05T04:38:40.304Z","avatar_url":"https://github.com/atomicgo.png","language":"Go","funding_links":["https://github.com/sponsors/MarvinJWendt"],"categories":[],"sub_categories":[],"readme":"\u003c!--\n\n\n\n┌───────────────────────────────────────────────────────────────────┐\n│                                                                   │\n│                          IMPORTANT NOTE                           │\n│                                                                   │\n│               This file is automatically generated                │\n│           All manual modifications will be overwritten            │\n│                                                                   │\n└───────────────────────────────────────────────────────────────────┘\n\n\n\n--\u003e\n\n\u003ch1 align=\"center\"\u003eAtomicGo | constraints\u003c/h1\u003e\n\n\u003cp align=\"center\"\u003e\n\u003cimg src=\"https://img.shields.io/endpoint?url=https%3A%2F%2Fatomicgo.dev%2Fapi%2Fshields%2Fconstraints\u0026style=flat-square\" alt=\"Downloads\"\u003e\n\n\u003ca href=\"https://github.com/atomicgo/constraints/releases\"\u003e\n\u003cimg src=\"https://img.shields.io/github/v/release/atomicgo/constraints?style=flat-square\" alt=\"Latest Release\"\u003e\n\u003c/a\u003e\n\n\u003ca href=\"https://codecov.io/gh/atomicgo/constraints\" target=\"_blank\"\u003e\n\u003cimg src=\"https://img.shields.io/github/actions/workflow/status/atomicgo/constraints/go.yml?style=flat-square\" alt=\"Tests\"\u003e\n\u003c/a\u003e\n\n\u003ca href=\"https://codecov.io/gh/atomicgo/constraints\" target=\"_blank\"\u003e\n\u003cimg src=\"https://img.shields.io/codecov/c/gh/atomicgo/constraints?color=magenta\u0026logo=codecov\u0026style=flat-square\" alt=\"Coverage\"\u003e\n\u003c/a\u003e\n\n\u003ca href=\"https://codecov.io/gh/atomicgo/constraints\"\u003e\n\u003c!-- unittestcount:start --\u003e\u003cimg src=\"https://img.shields.io/badge/Unit_Tests-126-magenta?style=flat-square\" alt=\"Unit test count\"\u003e\u003c!-- unittestcount:end --\u003e\n\u003c/a\u003e\n\n\u003ca href=\"https://opensource.org/licenses/MIT\" target=\"_blank\"\u003e\n\u003cimg src=\"https://img.shields.io/badge/License-MIT-yellow.svg?style=flat-square\" alt=\"License: MIT\"\u003e\n\u003c/a\u003e\n  \n\u003ca href=\"https://goreportcard.com/report/github.com/atomicgo/constraints\" target=\"_blank\"\u003e\n\u003cimg src=\"https://goreportcard.com/badge/github.com/atomicgo/constraints?style=flat-square\" alt=\"Go report\"\u003e\n\u003c/a\u003e   \n\n\u003c/p\u003e\n\n---\n\n\u003cp align=\"center\"\u003e\n\u003cstrong\u003e\u003ca href=\"https://pkg.go.dev/atomicgo.dev/constraints#section-documentation\" target=\"_blank\"\u003eDocumentation\u003c/a\u003e\u003c/strong\u003e\n|\n\u003cstrong\u003e\u003ca href=\"https://github.com/atomicgo/atomicgo/blob/main/CONTRIBUTING.md\" target=\"_blank\"\u003eContributing\u003c/a\u003e\u003c/strong\u003e\n|\n\u003cstrong\u003e\u003ca href=\"https://github.com/atomicgo/atomicgo/blob/main/CODE_OF_CONDUCT.md\" target=\"_blank\"\u003eCode of Conduct\u003c/a\u003e\u003c/strong\u003e\n\u003c/p\u003e\n\n---\n\n\u003cp align=\"center\"\u003e\n  \u003cimg src=\"https://raw.githubusercontent.com/atomicgo/atomicgo/main/assets/header.png\" alt=\"AtomicGo\"\u003e\n\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\n\u003ctable\u003e\n\u003ctbody\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n\u003c/p\u003e\n\u003ch3  align=\"center\"\u003e\u003cpre\u003ego get atomicgo.dev/constraints\u003c/pre\u003e\u003c/h3\u003e\n\u003cp align=\"center\"\u003e\n\u003ctable\u003e\n\u003ctbody\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n\u003c/p\u003e\n\n\u003c!-- gomarkdoc:embed:start --\u003e\n\n\u003c!-- Code generated by gomarkdoc. DO NOT EDIT --\u003e\n\n# constraints\n\n```go\nimport \"atomicgo.dev/constraints\"\n```\n\nPackage constraints provides constraints for type parameters aka. generics in Go.\n\nThis is a more comprehensive drop\\-in replacement for golang.org/x/exp/constraints.\n\n## Index\n\n- [type Addable](\u003c#Addable\u003e)\n- [type Comparable](\u003c#Comparable\u003e)\n- [type Complex](\u003c#Complex\u003e)\n- [type Float](\u003c#Float\u003e)\n- [type Integer](\u003c#Integer\u003e)\n- [type Number](\u003c#Number\u003e)\n- [type Numeric](\u003c#Numeric\u003e)\n- [type Orderable](\u003c#Orderable\u003e)\n- [type Ordered](\u003c#Ordered\u003e)\n- [type Signed](\u003c#Signed\u003e)\n- [type Unsigned](\u003c#Unsigned\u003e)\n\n\n\u003ca name=\"Addable\"\u003e\u003c/a\u003e\n## type [Addable](\u003chttps://github.com/atomicgo/constraints/blob/main/comparison.go#L14-L16\u003e)\n\nAddable is a constraint that matches any type that can be added with the \\+ operator.\n\n```go\ntype Addable interface {\n    Number | ~string\n}\n```\n\n\u003ca name=\"Comparable\"\u003e\u003c/a\u003e\n## type [Comparable](\u003chttps://github.com/atomicgo/constraints/blob/main/comparison.go#L4-L6\u003e)\n\nComparable is a constraint that matches any type that can be compared with the == and \\!= operators.\n\n```go\ntype Comparable interface {\n    comparable\n}\n```\n\n\u003ca name=\"Complex\"\u003e\u003c/a\u003e\n## type [Complex](\u003chttps://github.com/atomicgo/constraints/blob/main/numbers.go#L9-L11\u003e)\n\nComplex is a constraint that matches any complex number type.\n\n```go\ntype Complex interface {\n    ~complex64 | ~complex128\n}\n```\n\n\u003ca name=\"Float\"\u003e\u003c/a\u003e\n## type [Float](\u003chttps://github.com/atomicgo/constraints/blob/main/numbers.go#L21-L23\u003e)\n\nFloat is a constraint that matches any floating point number type.\n\n```go\ntype Float interface {\n    ~float32 | ~float64\n}\n```\n\n\u003ca name=\"Integer\"\u003e\u003c/a\u003e\n## type [Integer](\u003chttps://github.com/atomicgo/constraints/blob/main/numbers.go#L26-L28\u003e)\n\nInteger is a constraint that matches any integer type.\n\n```go\ntype Integer interface {\n    Signed | Unsigned\n}\n```\n\n\u003ca name=\"Number\"\u003e\u003c/a\u003e\n## type [Number](\u003chttps://github.com/atomicgo/constraints/blob/main/numbers.go#L16-L18\u003e)\n\nNumber is a constraint that matches any real number type. The Number constraint does not include Complex numbers, as those are not ordered. If you also need Complex numbers, use the Numeric constraint.\n\n```go\ntype Number interface {\n    Float | Integer\n}\n```\n\n\u003ca name=\"Numeric\"\u003e\u003c/a\u003e\n## type [Numeric](\u003chttps://github.com/atomicgo/constraints/blob/main/numbers.go#L4-L6\u003e)\n\nNumeric is a constraint that matches any numeric type, including complex numbers.\n\n```go\ntype Numeric interface {\n    Number | Complex\n}\n```\n\n\u003ca name=\"Orderable\"\u003e\u003c/a\u003e\n## type [Orderable](\u003chttps://github.com/atomicgo/constraints/blob/main/comparison.go#L9-L11\u003e)\n\nOrderable is a constraint that matches any type that can be ordered with the \\\u003c, \\\u003c=, \\\u003e, and \\\u003e= operators.\n\n```go\ntype Orderable interface {\n    Integer | Float | ~string\n}\n```\n\n\u003ca name=\"Ordered\"\u003e\u003c/a\u003e\n## type [Ordered](\u003chttps://github.com/atomicgo/constraints/blob/main/numbers.go#L31-L33\u003e)\n\nOrdered is a constraint that matches any ordered type.\n\n```go\ntype Ordered interface {\n    Integer | Float | ~string\n}\n```\n\n\u003ca name=\"Signed\"\u003e\u003c/a\u003e\n## type [Signed](\u003chttps://github.com/atomicgo/constraints/blob/main/numbers.go#L36-L38\u003e)\n\nSigned is a constraint that matches any signed integer type.\n\n```go\ntype Signed interface {\n    ~int | ~int8 | ~int16 | ~int32 | ~int64\n}\n```\n\n\u003ca name=\"Unsigned\"\u003e\u003c/a\u003e\n## type [Unsigned](\u003chttps://github.com/atomicgo/constraints/blob/main/numbers.go#L41-L43\u003e)\n\nUnsigned is a constraint that matches any unsigned integer type.\n\n```go\ntype Unsigned interface {\n    ~uint | ~uint8 | ~uint16 | ~uint32 | ~uint64 | ~uintptr\n}\n```\n\nGenerated by [gomarkdoc](\u003chttps://github.com/princjef/gomarkdoc\u003e)\n\n\n\u003c!-- gomarkdoc:embed:end --\u003e\n\n---\n\n\u003e [AtomicGo.dev](https://atomicgo.dev) \u0026nbsp;\u0026middot;\u0026nbsp;\n\u003e with ❤️ by [@MarvinJWendt](https://github.com/MarvinJWendt) |\n\u003e [MarvinJWendt.com](https://marvinjwendt.com)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fatomicgo%2Fconstraints","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fatomicgo%2Fconstraints","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fatomicgo%2Fconstraints/lists"}