pre-hashed strings for fast comparison
- Go 100%
| .forgejo/workflows | ||
| .releaserc.json | ||
| atom.go | ||
| atom_test.go | ||
| bits.go | ||
| errors.go | ||
| go.mod | ||
| go.sum | ||
| LICENSE.md | ||
| namespaceatom.go | ||
| README.md | ||
| registry.go | ||
⚛️ Atom
This package represents a simple concept with many names- a pre-hashed string
for faster comparisons. In functional programming languages, particularly Lisps,
these are often referred to as "atoms", and even have special syntax in the form
:foo, where foo is the string to hash at compile time. Some languages also
refer to this concept as "symbols" or "quarks".
Examples
myAtom := atom.New("foo")
fmt.Println(myAtom) // prints "foo"
mySecondAtom := atom.New("bar")
fmt.Println(mySecondAtom) // prints "bar"
myThirdAtom := atom.New("foo")
fmt.Println(myThirdAtom) // prints "foo"
fmt.Println(myAtom == myThirdAtom) // prints "true"
Stability
The bit layout of atoms created by this package is currently unstable and may change in future versions, until v1.0.0 is released, at which point the layout will be frozen and only backwards-compatible changes will be allowed.