--- print.go.orig 2020-08-26 14:49:30.396184000 +0200 +++ print.go 2020-08-26 14:50:29.330829000 +0200 @@ -1,3 +1,6 @@ +// Code generated from print.go.orig. DO NOT EDIT +// GENERATED FILE DO NOT EDIT +// // Copyright 2009 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. @@ -5,12 +8,16 @@ package fmt import ( - "internal/fmtsort" + // CUSTOM: needed to avoid a type mismatch on Formatter. + origFmt "fmt" "io" "os" "reflect" "sync" "unicode/utf8" + + // CUSTOM: our own import since we can't use internal from go stdlib. + "github.com/cockroachdb/redact/internal/fmtsort" ) // Strings for use with buffer.WriteString. @@ -51,7 +58,8 @@ // The implementation of Format may call Sprint(f) or Fprint(f) etc. // to generate its output. type Formatter interface { - Format(f State, c rune) + // CUSTOM: refer to the original type, not the one defined here. + Format(f origFmt.State, c rune) } // Stringer is implemented by any value that has a String method, @@ -105,6 +113,10 @@ type pp struct { buf buffer + // CUSTOM: hook fn for the redact package. + printArgSubstituteFn func(p *pp, a interface{}, verb rune) (newState int) + substituteState int + // arg holds the current item, as an interface{}. arg interface{} @@ -635,7 +647,8 @@ return false } -func (p *pp) printArg(arg interface{}, verb rune) { +// CUSTOM: printArg() renamed to printArgOrig(). +func (p *pp) printArgOrig(arg interface{}, verb rune) { p.arg = arg p.value = reflect.Value{}