Installation¶
Requirements¶
- Go 1.21 or later
Installing the module¶
Use go get to add go-phileas to your module:
This adds the dependency to your go.mod and fetches the source.
Importing packages¶
The library is organised into the following packages:
| Package | Purpose |
|---|---|
github.com/philterd/go-phileas/pkg/services |
FilterService and the FilterJSON helper — the main entry points |
github.com/philterd/go-phileas/pkg/policy |
Policy and identifier types, strategy constants |
github.com/philterd/go-phileas/pkg/model |
FilterResult, Span, and FilterType types |
A typical import block looks like:
import (
"github.com/philterd/go-phileas/pkg/policy"
"github.com/philterd/go-phileas/pkg/services"
)
Verifying the installation¶
Create a small program to confirm everything is working:
package main
import (
"fmt"
"github.com/philterd/go-phileas/pkg/policy"
"github.com/philterd/go-phileas/pkg/services"
)
func main() {
pol := &policy.Policy{
Name: "test",
Identifiers: policy.Identifiers{
EmailAddress: &policy.EmailAddressFilter{},
},
}
svc := services.NewFilterService(pol)
result, err := svc.Filter(pol, "ctx", "Contact us at hello@example.com.")
if err != nil {
panic(err)
}
fmt.Println(result.FilteredText)
// Output: Contact us at {{{REDACTED-email-address}}}.
}
Run it with:
Building and testing the library itself¶
If you are contributing to go-phileas, clone the repository and run: