Constraints
๐ฆ Drop-in replacement for golang.org/x/exp/constraints with more predefined constraints
Install / Use
/learn @atomicgo/ConstraintsREADME
<p align="center"> <strong><a href="https://pkg.go.dev/atomicgo.dev/constraints#section-documentation" target="_blank">Documentation</a></strong> | <strong><a href="https://github.com/atomicgo/atomicgo/blob/main/CONTRIBUTING.md" target="_blank">Contributing</a></strong> | <strong><a href="https://github.com/atomicgo/atomicgo/blob/main/CODE_OF_CONDUCT.md" target="_blank">Code of Conduct</a></strong> </p>
<p align="center"> <img src="https://raw.githubusercontent.com/atomicgo/atomicgo/main/assets/header.png" alt="AtomicGo"> </p> <p align="center"> <table> <tbody> </tbody> </table> </p> <h3 align="center"><pre>go get atomicgo.dev/constraints</pre></h3> <p align="center"> <table> <tbody> </tbody> </table> </p> <!-- gomarkdoc:embed:start --> <!-- Code generated by gomarkdoc. DO NOT EDIT -->
constraints
import "atomicgo.dev/constraints"
Package constraints provides constraints for type parameters aka. generics in Go.
This is a more comprehensive drop-in replacement for golang.org/x/exp/constraints.
Index
- type Addable
- type Comparable
- type Complex
- type Float
- type Integer
- type Number
- type Numeric
- type Orderable
- type Ordered
- type Signed
- type Unsigned
<a name="Addable"></a>
type Addable
Addable is a constraint that matches any type that can be added with the + operator.
type Addable interface {
Number | ~string
}
<a name="Comparable"></a>
type Comparable
Comparable is a constraint that matches any type that can be compared with the == and != operators.
type Comparable interface {
comparable
}
<a name="Complex"></a>
type Complex
Complex is a constraint that matches any complex number type.
type Complex interface {
~complex64 | ~complex128
}
<a name="Float"></a>
type Float
Float is a constraint that matches any floating point number type.
type Float interface {
~float32 | ~float64
}
<a name="Integer"></a>
type Integer
Integer is a constraint that matches any integer type.
type Integer interface {
Signed | Unsigned
}
<a name="Number"></a>
type Number
Number 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.
type Number interface {
Float | Integer
}
<a name="Numeric"></a>
type Numeric
Numeric is a constraint that matches any numeric type, including complex numbers.
type Numeric interface {
Number | Complex
}
<a name="Orderable"></a>
type Orderable
Orderable is a constraint that matches any type that can be ordered with the <, <=, >, and >= operators.
type Orderable interface {
Integer | Float | ~string
}
<a name="Ordered"></a>
type Ordered
Ordered is a constraint that matches any ordered type.
type Ordered interface {
Integer | Float | ~string
}
<a name="Signed"></a>
type Signed
Signed is a constraint that matches any signed integer type.
type Signed interface {
~int | ~int8 | ~int16 | ~int32 | ~int64
}
<a name="Unsigned"></a>
type Unsigned
Unsigned is a constraint that matches any unsigned integer type.
type Unsigned interface {
~uint | ~uint8 | ~uint16 | ~uint32 | ~uint64 | ~uintptr
}
Generated by gomarkdoc
<!-- gomarkdoc:embed:end -->AtomicGo.dev ย ยทย with โค๏ธ by @MarvinJWendt | MarvinJWendt.com
Related Skills
node-connect
345.4kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
xurl
345.4kA CLI tool for making authenticated requests to the X (Twitter) API. Use this skill when you need to post tweets, reply, quote, search, read posts, manage followers, send DMs, upload media, or interact with any X API v2 endpoint.
frontend-design
104.6kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
345.4kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
