Go

go get github.com/agentfirstkit/agent-first-data/go
package main

import (
    "fmt"

    afdata "github.com/agentfirstkit/agent-first-data/go"
)

func main() {
    value := map[string]any{
        "code": "ok",
        "result": map[string]any{
            "api_key_secret": "sk-123",
            "latency_ms": 1280,
            "db_url": "postgres://user:p@ss@db/app?token_secret=abc",
        },
    }

    fmt.Println(afdata.OutputJson(value))
    fmt.Println(afdata.OutputPlain(value))
}

Useful names use Go casing: OutputJson, OutputYaml, OutputPlain, OutputJsonWithOptions, RedactedValue, RedactSecretsInPlace, RedactURLSecrets, ParseSize, NormalizeUTCOffset, IsValidRFC3339Date, IsValidRFC3339Time, CliParseOutput, CliOutput, BuildCliError, BuildCliVersion, CliHandleVersionOrContinue, ParseStreamRedirectArgs, and InstallStreamRedirectFromArgs.

Logging is available through the log/slog integration: InitJson, InitPlain, InitYaml, InitJsonWithOptions, WithSpan, and LoggerFromContext.

afdata.InitJsonWithOptions(afdata.RedactionOptions{
    SecretNames: []string{"authorization"},
})

Behavior Notes

Reference