Skip to content

Latest commit

 

History

History
42 lines (33 loc) · 1.09 KB

File metadata and controls

42 lines (33 loc) · 1.09 KB

GoLang Bloom Filter

codecov CircleCI

Simple bloom filter implementation for the GoLang programming language

Installing

go get github.com/scottjr632/go-bloom-filter

Importing

import "github.com/scottjr632/go-bloom-filter"

Creating a new optimal filter

estimatedNumberOfItems, maxFailureRate := 3000, 0.01
bf := bloomfilter.NewFromEstimate(estimatedNumberOfItems, maxFailureRate)

Creating a new filter

sizeOfFilter, numHashFns := 128, 3
bf := bloomfilter.New(sizeOfFilter, numHashFns)

Handling values

Adding a value to the filter

valueToAdd := 'https://maliciousurl.xyz'
bf.Add(valueToAdd)

Checking if a value has been set

valueToCheck := 'https://maliciousurl.xyz'
bf.Check(valueToCheck) // -> true

bf.Check('value that has not been set') // -> false