Skip to content

go-phileas

go-phileas is a Go library for de-identifying and redacting PII (Personally Identifiable Information), PHI (Protected Health Information), and other sensitive data from text. It is a Go port of the Phileas Java library.

go-phileas uses policies — defined in Go structs or JSON — to specify which types of sensitive information to detect and how to handle each type when found.

Features

  • Detects 18+ types of sensitive information out of the box
  • Flexible filter strategies: redact, mask, static replace, and more
  • Policy-based configuration via Go structs or JSON
  • Returns both the filtered text and a list of identified spans with positions
  • Per-filter and global ignore lists and ignore patterns

Quick Start

Install

go get github.com/philterd/go-phileas

Filter text using a Go policy

package main

import (
    "fmt"
    "github.com/philterd/go-phileas/pkg/policy"
    "github.com/philterd/go-phileas/pkg/services"
)

func main() {
    pol := &policy.Policy{
        Name: "quickstart",
        Identifiers: policy.Identifiers{
            SSN: &policy.SSNFilter{
                SSNFilterStrategies: []policy.FilterStrategy{
                    {Strategy: policy.StrategyRedact, RedactionFormat: "{{{REDACTED-%t}}}"},
                },
            },
            EmailAddress: &policy.EmailAddressFilter{},
        },
    }

    svc, err := services.NewFilterService(pol)
    if err != nil {
        panic(err)
    }
    result, err := svc.Filter(pol, "my-context", "My SSN is 123-45-6789 and email is john@example.com.")
    if err != nil {
        panic(err)
    }

    fmt.Println(result.FilteredText)
    // Output: My SSN is {{{REDACTED-ssn}}} and email is {{{REDACTED-email-address}}}.
}

Filter text using a JSON policy

package main

import (
    "fmt"
    "github.com/philterd/go-phileas/pkg/services"
)

func main() {
    policyJSON := `{
        "identifiers": {
            "ssn": {
                "ssnFilterStrategies": [{"strategy": "REDACT", "redactionFormat": "{{{REDACTED-%t}}}"}]
            },
            "emailAddress": {}
        }
    }`

    result, err := services.FilterJSON(policyJSON, "my-context", "My SSN is 123-45-6789 and email is john@example.com.")
    if err != nil {
        panic(err)
    }

    fmt.Println(result.FilteredText)
    // Output: My SSN is {{{REDACTED-ssn}}} and email is {{{REDACTED-email-address}}}.
}

Next Steps

  • Installation — full installation and setup instructions
  • Policies — how to define and use policies
  • Filter Strategies — how to control what happens to detected information
  • Identifiers — all supported sensitive information types
  • Context Service — referential integrity across filter calls
  • CLI — redact text from the command line using the phileas binary
  • API Reference — complete Go API documentation
  • Examples — real-world usage examples