mirror of
https://github.com/hanzoai/telemetry.git
synced 2026-10-30 20:01:49 +00:00
**Description:** Move implementation checks to test files. Reduces dependencies of the configopaque package.
37 lines
956 B
Go
37 lines
956 B
Go
// Copyright The OpenTelemetry Authors
|
|
// SPDX-License-Identifier: Apache-2.0
|
|
|
|
package configopaque // import "go.opentelemetry.io/collector/config/configopaque"
|
|
|
|
import (
|
|
"fmt"
|
|
)
|
|
|
|
// String alias that is marshaled and printed in an opaque way.
|
|
// To recover the original value, cast it to a string.
|
|
type String string
|
|
|
|
const maskedString = "[REDACTED]"
|
|
|
|
// MarshalText marshals the string as `[REDACTED]`.
|
|
func (s String) MarshalText() ([]byte, error) {
|
|
return []byte(maskedString), nil
|
|
}
|
|
|
|
// String formats the string as `[REDACTED]`.
|
|
// This is used for the %s and %q verbs.
|
|
func (s String) String() string {
|
|
return maskedString
|
|
}
|
|
|
|
// GoString formats the string as `[REDACTED]`.
|
|
// This is used for the %#v verb.
|
|
func (s String) GoString() string {
|
|
return fmt.Sprintf("%#v", maskedString)
|
|
}
|
|
|
|
// MarshalBinary marshals the string `[REDACTED]` as []byte.
|
|
func (s String) MarshalBinary() (text []byte, err error) {
|
|
return []byte(maskedString), nil
|
|
}
|