Documentation ¶
Index ¶
Constants ¶
const ( Start = '‹' StartS = string(Start) StartLen = len(StartS) End = '›' EndS = string(End) EndLen = len(EndS) EscapeMark = '?' EscapeMarkS = string(EscapeMark) RedactedS = StartS + "×" + EndS )
Internal constants.
Variables ¶
var ( StartBytes = []byte(StartS) EndBytes = []byte(EndS) EscapeMarkBytes = []byte(EscapeMarkS) RedactedBytes = []byte(RedactedS) ReStripSensitive = regexp.MustCompile(StartS + "[^" + StartS + EndS + "]*" + EndS) ReStripMarkers = regexp.MustCompile("[" + StartS + EndS + "]") )
Internal variables.
Functions ¶
func EscapeMarkers ¶
EscapeMarkers escapes the special delimiters from the provided byte slice.
func RedactedMarker ¶
func RedactedMarker() []byte
RedactedMarker returns the special string used by Redact.
func StartMarker ¶
func StartMarker() []byte
StartMarker returns the start delimiter for an unsafe string.
Types ¶
type RedactableBytes ¶
type RedactableBytes []byte
RedactableBytes is like RedactableString but is a byte slice.
Instances of RedactableBytes should not be constructed directly; instead use the facilities from print.go (Sprint, Sprintf) or the methods below.
func (RedactableBytes) Redact ¶
func (s RedactableBytes) Redact() RedactableBytes
Redact replaces all occurrences of unsafe substrings by the “Redacted” marker, ‹×›.
func (RedactableBytes) SafeFormat ¶
func (s RedactableBytes) SafeFormat(sp i.SafePrinter, _ rune)
SafeFormat formats the redactable safely.
func (RedactableBytes) StripMarkers ¶
func (s RedactableBytes) StripMarkers() []byte
StripMarkers removes the redaction markers from the RedactableBytes. This returns an unsafe string where all safe and unsafe bits are mixed together.
func (RedactableBytes) ToString ¶
func (s RedactableBytes) ToString() RedactableString
ToString converts the byte slice to a string.
type RedactableString ¶
type RedactableString string
RedactableString is a string that contains a mix of safe and unsafe bits of data, but where it is known that unsafe bits are enclosed by redaction markers ‹ and ›, and occurrences of the markers inside the original data items have been escaped.
Instances of RedactableString should not be constructed directly; instead use the facilities from print.go (Sprint, Sprintf) or the methods below.
func (RedactableString) Redact ¶
func (s RedactableString) Redact() RedactableString
Redact replaces all occurrences of unsafe substrings by the “Redacted” marker, ‹×›. The result string is still safe.
func (RedactableString) SafeFormat ¶
func (s RedactableString) SafeFormat(sp i.SafePrinter, _ rune)
SafeFormat formats the redactable safely.
func (RedactableString) StripMarkers ¶
func (s RedactableString) StripMarkers() string
StripMarkers removes the redaction markers from the RedactableString. This returns an unsafe string where all safe and unsafe bits are mixed together.
func (RedactableString) ToBytes ¶
func (s RedactableString) ToBytes() RedactableBytes
ToBytes converts the string to a byte slice.