hide alternatives and similar packages
Based on the "Data Structures" category.
Alternatively, view hide alternatives based on common mentions on social networks and blogs.
-
golang-set
A simple, battle-tested and generic set type for the Go language. Trusted by Docker, 1Password, Ethereum and Hashicorp. -
hyperloglog
HyperLogLog with lots of sugar (Sparse, LogLog-Beta bias correction and TailCut space reduction) brought to you by Axiom -
ttlcache
DISCONTINUED. An in-memory cache with item expiration and generics [Moved to: https://github.com/jellydator/ttlcache] -
Bloomfilter
DISCONTINUED. Face-meltingly fast, thread-safe, marshalable, unionable, probability- and optimal-size-calculating Bloom filter in go -
hilbert
DISCONTINUED. Go package for mapping values to and from space-filling curves, such as Hilbert and Peano curves. -
cuckoo-filter
Cuckoo Filter go implement, better than Bloom Filter, configurable and space optimized 布谷鸟过滤器的Go实现,优于布隆过滤器,可以定制化过滤器参数,并进行了空间优化 -
go-rquad
:pushpin: State of the art point location and neighbour finding algorithms for region quadtrees, in Go -
nan
Zero allocation Nullable structures in one library with handy conversion functions, marshallers and unmarshallers
SaaSHub - Software Alternatives and Reviews
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.