소스 검색

Invoke String/Error methods on addressable vals.

If a type implements a Stringer or error interface with a pointer receiver
and the value being formatted is addressable, the interface should be
invoked even when the DisablePointerMethods option is set.
DisablePointerMethods is only intended to prevent the potentially unsafe
action of stepping around type-safety restriction to invoke a Stringer or
error interface with a pointer to an unaddressable value.
Dave Collins 13 년 전
부모
커밋
6024e0c79e
1개의 변경된 파일3개의 추가작업 그리고 0개의 파일을 삭제
  1. 3 0
      spew/common.go

+ 3 - 0
spew/common.go

@@ -140,6 +140,9 @@ func handleMethods(cs *ConfigState, w io.Writer, v reflect.Value) (handled bool)
 		}
 		}
 		viface = v.Addr().Interface()
 		viface = v.Addr().Interface()
 	} else {
 	} else {
+		if v.CanAddr() {
+			v = v.Addr()
+		}
 		viface = v.Interface()
 		viface = v.Interface()
 	}
 	}