Type "RedactInfoLogType" has both value and pointer receivers
147}
148
149// UnmarshalTOML implements the `toml.Unmarshaler` interface to ensure the compatibility.
150func (t *RedactInfoLogType) UnmarshalTOML(data any) error {151 switch v := data.(type) {
152 case bool:
153 if v {
Type "RedactInfoLogType" has both value and pointer receivers
121const invalidRedactInfoLogTypeErrMsg = `the "redact-info-log" value is invalid; it should be either false, true, or "MARK"`
122
123// UnmarshalJSON implements the `json.Marshaler` interface to ensure the compatibility.
124func (t *RedactInfoLogType) UnmarshalJSON(data []byte) error {125 var s string
126 if err := json.Unmarshal(data, &s); err == nil {
127 switch strings.ToUpper(s) {
Type "RedactInfoLogType" has both value and pointer receivers
107)
108
109// MarshalJSON implements the `json.Marshaler` interface to ensure the compatibility.
110func (t RedactInfoLogType) MarshalJSON() ([]byte, error) {111 switch t {
112 case RedactInfoLogON:
113 return json.Marshal(true)
Description
(Go's FAQ)[https://go.dev/doc/faq#methodsonvaluesorpointers] recommends that method receivers should be consistent. If some of the methods of the type must have pointer receivers, the rest should too, so the method set is consistent regardless of how the type is used. This is because value and pointer receivers have different method sets.
Bad practice
package main
type foo struct {
a int
}
func (f foo) a() {}
func (f *foo) b() {
f.a = 10
}
Recommended
package main
type foo struct {
a int
}
func (f *foo) a() {}
func (f *foo) b() {
f.a = 10
}