diff --git a/config/configopaque/opaque.go b/config/configopaque/opaque.go index c79d053f6b7..b1712a212f7 100644 --- a/config/configopaque/opaque.go +++ b/config/configopaque/opaque.go @@ -4,7 +4,6 @@ package configopaque // import "go.opentelemetry.io/collector/config/configopaque" import ( - "encoding" "fmt" ) @@ -14,31 +13,23 @@ type String string const maskedString = "[REDACTED]" -var _ encoding.TextMarshaler = String("") - // MarshalText marshals the string as `[REDACTED]`. func (s String) MarshalText() ([]byte, error) { return []byte(maskedString), nil } -var _ fmt.Stringer = String("") - // String formats the string as `[REDACTED]`. // This is used for the %s and %q verbs. func (s String) String() string { return maskedString } -var _ fmt.GoStringer = String("") - // GoString formats the string as `[REDACTED]`. // This is used for the %#v verb. func (s String) GoString() string { return fmt.Sprintf("%#v", maskedString) } -var _ encoding.BinaryMarshaler = String("") - // MarshalBinary marshals the string `[REDACTED]` as []byte. func (s String) MarshalBinary() (text []byte, err error) { return []byte(maskedString), nil diff --git a/config/configopaque/opaque_test.go b/config/configopaque/opaque_test.go index a3d0346771c..24af499b8fb 100644 --- a/config/configopaque/opaque_test.go +++ b/config/configopaque/opaque_test.go @@ -4,6 +4,7 @@ package configopaque // import "go.opentelemetry.io/collector/config/configopaque" import ( + "encoding" "encoding/json" "fmt" "testing" @@ -13,6 +14,14 @@ import ( "gopkg.in/yaml.v3" ) +var _ encoding.TextMarshaler = String("") + +var _ fmt.Stringer = String("") + +var _ fmt.GoStringer = String("") + +var _ encoding.BinaryMarshaler = String("") + func TestStringMarshalText(t *testing.T) { examples := []String{"opaque", "s", "veryveryveryveryveryveryveryveryveryverylong"} for _, example := range examples {