Просмотр исходного кода

Use fmt.Errorf instead of errors.New (#481)

The %v verb in Errorf automatically calls the String method.
This is safer than manually calling reflect.Type.String since
the reflect.Type may be nil.
Joe Tsai 8 лет назад
Родитель
Сommit
572071ce41
1 измененных файлов с 1 добавлено и 1 удалено
  1. 1 1
      proto/extensions.go

+ 1 - 1
proto/extensions.go

@@ -218,7 +218,7 @@ func checkExtensionTypes(pb extendableProto, extension *ExtensionDesc) error {
 		pbi = ea.extendableProtoV1
 	}
 	if a, b := reflect.TypeOf(pbi), reflect.TypeOf(extension.ExtendedType); a != b {
-		return errors.New("proto: bad extended type; " + b.String() + " does not extend " + a.String())
+		return fmt.Errorf("proto: bad extended type; %v does not extend %v", b, a)
 	}
 	// Check the range.
 	if !isExtensionField(pb, extension.Field) {