hide alternatives and similar packages
Based on the "Data Structures" category.
Alternatively, view hide alternatives based on common mentions on social networks and blogs.
-
gods
GoDS (Go Data Structures) - Sets, Lists, Stacks, Maps, Trees, Queues, and much more -
go-datastructures
A collection of useful, performant, and threadsafe Go datastructures. -
golang-set
A simple, battle-tested and generic set type for the Go language. Trusted by Docker, 1Password, Ethereum and Hashicorp. -
gocache
☔️ A complete Go cache library that brings you multiple ways of managing your caches -
boomfilters
Probabilistic data structures for processing continuous, unbounded streams. -
gostl
Data structure and algorithm library for go, designed to provide functions similar to C++ STL -
hyperloglog
HyperLogLog with lots of sugar (Sparse, LogLog-Beta bias correction and TailCut space reduction) brought to you by Axiom -
trie
Data structure and relevant algorithms for extremely fast prefix/fuzzy string searching. -
go-geoindex
Go native library for fast point tracking and K-Nearest queries -
ttlcache
An in-memory cache with item expiration and generics [Moved to: https://github.com/jellydator/ttlcache] -
hilbert
Go package for mapping values to and from space-filling curves, such as Hilbert and Peano curves. -
Bloomfilter
Face-meltingly fast, thread-safe, marshalable, unionable, probability- and optimal-size-calculating Bloom filter in go -
go-adaptive-radix-tree
Adaptive Radix Trees implemented in Go -
goconcurrentqueue
Go concurrent-safe, goroutine-safe, thread-safe queue -
cuckoo-filter
Cuckoo Filter go implement, better than Bloom Filter, configurable and space optimized 布谷鸟过滤器的Go实现,优于布隆过滤器,可以定制化过滤器参数,并进行了空间优化 -
ring
Package ring provides a high performance and thread safe Go implementation of a bloom filter. -
go-rquad
:pushpin: State of the art point location and neighbour finding algorithms for region quadtrees, in Go -
set
A simple Set data structure implementation in Go (Golang) using LinkedHashMap. -
nan
Zero allocation Nullable structures in one library with handy conversion functions, marshallers and unmarshallers -
goset
Set is a useful collection but there is no built-in implementation in Go lang.
Learn any GitHub repo in 59 seconds
Do you think we are missing an alternative of hide or a related project?
README
Hide IDs
Hide is a simple package to provide an ID type that is marshalled to/from a hash string.
This prevents sending technical IDs to clients and converts them on the API layer.
Hide uses hashids as its default hash function.
But you can provide your own by implementing the Hash
interface and configure it using hide.UseHash
.
Read our full article on Medium.
Installation
go get github.com/emvi/hide
Example
Consider the following struct:
type User struct {
Id int64 `json:"id"`
Username string `json:"username"`
}
When marshalling this struct to JSON, the ID will be represented by a number:
{
"id": 123,
"username": "foobar"
}
In this case you expose the technical user ID to your clients. By changing the type of the ID, you get a better result:
type User struct {
Id hide.ID `json:"id"`
Username string `json:"username"`
}
Notice that the int64
ID got replaced by the hide.ID
, which internally is represented as an int64
as well, but implements the marshal interface.
This allows you to cast between them and use hide.ID
as a replacement. The resulting JSON changes to the following:
{
"id": "beJarVNaQM",
"username": "foobar"
}
If you send the new ID (which is a string now) back to the server and unmarshal it into the hide.ID
type, you'll get the original technical ID back.
It's also worth mentioning that a value of 0 is translated to null
when an ID is marshalled to JSON or stored in database.
Contribute
[See CONTRIBUTING.md](CONTRIBUTING.md)
License
MIT
*Note that all licence references and agreements mentioned in the hide README section above
are relevant to that project's source code only.