Multi-Field Secrets
Store complex credentials with JSON format enabled:
kr := keyring.New(keyring.Config{
ServiceName: "myapp",
JSONFormat: true,
})
kr.Set(ctx, "database/prod", &vault.Secret{
Value: "super-secret-password",
Fields: map[string]string{
"username": "db_admin",
"host": "db.example.com",
"port": "5432",
},
})
secret, _ := kr.Get(ctx, "database/prod")
fmt.Printf("Host: %s, User: %s", secret.Fields["host"], secret.Fields["username"])