https://github.com/scottjr632/go-bloom-filter
Simple bloom filter implementation for the GoLang programming language
https://github.com/scottjr632/go-bloom-filter
bloom bloom-filter bloomfilter bloomfilter-go filter golang
Last synced: 3 months ago
JSON representation
Simple bloom filter implementation for the GoLang programming language
- Host: GitHub
- URL: https://github.com/scottjr632/go-bloom-filter
- Owner: scottjr632
- License: mit
- Created: 2020-01-04T19:24:37.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2020-07-01T19:24:42.000Z (almost 6 years ago)
- Last Synced: 2024-06-20T10:09:21.634Z (almost 2 years ago)
- Topics: bloom, bloom-filter, bloomfilter, bloomfilter-go, filter, golang
- Language: Go
- Size: 22.5 KB
- Stars: 0
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# GoLang Bloom Filter
[](https://codecov.io/gh/scottjr632/go-bloom-filter) [](https://circleci.com/gh/scottjr632/go-bloom-filter)
Simple bloom filter implementation for the GoLang programming language
## Installing
```bash
go get github.com/scottjr632/go-bloom-filter
```
### Importing
```go
import "github.com/scottjr632/go-bloom-filter"
```
## Creating a new optimal filter
```go
estimatedNumberOfItems, maxFailureRate := 3000, 0.01
bf := bloomfilter.NewFromEstimate(estimatedNumberOfItems, maxFailureRate)
```
### Creating a new filter
```go
sizeOfFilter, numHashFns := 128, 3
bf := bloomfilter.New(sizeOfFilter, numHashFns)
```
## Handling values
#### Adding a value to the filter
```go
valueToAdd := 'https://maliciousurl.xyz'
bf.Add(valueToAdd)
```
#### Checking if a value has been set
```go
valueToCheck := 'https://maliciousurl.xyz'
bf.Check(valueToCheck) // -> true
bf.Check('value that has not been set') // -> false
```