Upgrade versions of vendored libs
This commit is contained in:
49
vendor/github.com/cockroachdb/redact/markers_print.go
generated
vendored
49
vendor/github.com/cockroachdb/redact/markers_print.go
generated
vendored
@@ -17,7 +17,7 @@ package redact
|
||||
import (
|
||||
"io"
|
||||
|
||||
internalFmt "github.com/cockroachdb/redact/internal"
|
||||
"github.com/cockroachdb/redact/internal/rfmt"
|
||||
)
|
||||
|
||||
// Sprint prints out the arguments and encloses unsafe bits
|
||||
@@ -27,13 +27,7 @@ import (
|
||||
// If a RedactableString or RedactableBytes argument is passed,
|
||||
// it is reproduced as-is without escaping.
|
||||
func Sprint(args ...interface{}) RedactableString {
|
||||
p := internalFmt.NewInternalPrinter()
|
||||
internalFmt.SetHook(p, printArgFn)
|
||||
internalFmt.DoPrint(p, args)
|
||||
redactLastWrites(p)
|
||||
s := RedactableString(internalFmt.Buf(p))
|
||||
internalFmt.Free(p)
|
||||
return s
|
||||
return rfmt.Sprint(args...)
|
||||
}
|
||||
|
||||
// Sprintf formats the arguments and encloses unsafe bits
|
||||
@@ -44,13 +38,7 @@ func Sprint(args ...interface{}) RedactableString {
|
||||
// is responsible to ensure that the markers are not present
|
||||
// in the format string.
|
||||
func Sprintf(format string, args ...interface{}) RedactableString {
|
||||
p := internalFmt.NewInternalPrinter()
|
||||
internalFmt.SetHook(p, printArgFn)
|
||||
internalFmt.DoPrintf(p, format, args)
|
||||
redactLastWrites(p)
|
||||
s := RedactableString(internalFmt.Buf(p))
|
||||
internalFmt.Free(p)
|
||||
return s
|
||||
return rfmt.Sprintf(format, args...)
|
||||
}
|
||||
|
||||
// HelperForErrorf is a helper to implement a redaction-aware
|
||||
@@ -63,24 +51,13 @@ func Sprintf(format string, args ...interface{}) RedactableString {
|
||||
// Note: This function only works if an error redaction function
|
||||
// has been injected with RegisterRedactErrorFn().
|
||||
func HelperForErrorf(format string, args ...interface{}) (RedactableString, error) {
|
||||
p := internalFmt.NewInternalPrinter()
|
||||
internalFmt.SetCollectError(p)
|
||||
internalFmt.SetHook(p, printArgFn)
|
||||
internalFmt.DoPrintf(p, format, args)
|
||||
redactLastWrites(p)
|
||||
s := RedactableString(internalFmt.Buf(p))
|
||||
e := internalFmt.WrappedError(p)
|
||||
internalFmt.Free(p)
|
||||
if m, ok := e.(*makeError); ok {
|
||||
e = m.err
|
||||
}
|
||||
return s, e
|
||||
return rfmt.HelperForErrorf(format, args...)
|
||||
}
|
||||
|
||||
// Sprintfn produces a RedactableString using the provided
|
||||
// SafeFormat-alike function.
|
||||
func Sprintfn(printer func(w SafePrinter)) RedactableString {
|
||||
return Sprint(printerfn{printer})
|
||||
return rfmt.Sprintfn(printer)
|
||||
}
|
||||
|
||||
// StringWithoutMarkers formats the provided SafeFormatter and strips
|
||||
@@ -100,23 +77,11 @@ func StringWithoutMarkers(f SafeFormatter) string {
|
||||
// Fprint is like Sprint but outputs the redactable
|
||||
// string to the provided Writer.
|
||||
func Fprint(w io.Writer, args ...interface{}) (n int, err error) {
|
||||
p := internalFmt.NewInternalPrinter()
|
||||
internalFmt.SetHook(p, printArgFn)
|
||||
internalFmt.DoPrint(p, args)
|
||||
redactLastWrites(p)
|
||||
n, err = w.Write(internalFmt.Buf(p))
|
||||
internalFmt.Free(p)
|
||||
return
|
||||
return rfmt.Fprint(w, args...)
|
||||
}
|
||||
|
||||
// Fprintf is like Sprintf but outputs the redactable string to the
|
||||
// provided Writer.
|
||||
func Fprintf(w io.Writer, format string, args ...interface{}) (n int, err error) {
|
||||
p := internalFmt.NewInternalPrinter()
|
||||
internalFmt.SetHook(p, printArgFn)
|
||||
internalFmt.DoPrintf(p, format, args)
|
||||
redactLastWrites(p)
|
||||
n, err = w.Write(internalFmt.Buf(p))
|
||||
internalFmt.Free(p)
|
||||
return
|
||||
return rfmt.Fprintf(w, format, args...)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user