Gustavo Niemeyer 7 лет назад
Родитель
Сommit
e8e5527513
3 измененных файлов с 10 добавлено и 10 удалено
  1. 1 1
      encode.go
  2. 2 2
      encode_test.go
  3. 7 7
      yaml.go

+ 1 - 1
encode.go

@@ -192,7 +192,7 @@ func (e *encoder) structv(tag string, in reflect.Value) {
 				sort.Sort(keys)
 				for _, k := range keys {
 					if _, found := sinfo.FieldsMap[k.String()]; found {
-						panic(fmt.Sprintf("Can't have key %q in inlined map; conflicts with struct field", k.String()))
+						panic(fmt.Sprintf("cannot have key %q in inlined map: conflicts with struct field", k.String()))
 					}
 					e.marshal("", k)
 					e.flow = false

+ 2 - 2
encode_test.go

@@ -420,13 +420,13 @@ var marshalErrorTests = []struct {
 		B       int
 		inlineB ",inline"
 	}{1, inlineB{2, inlineC{3}}},
-	panic: `Duplicated key 'b' in struct struct \{ B int; .*`,
+	panic: `duplicated key 'b' in struct struct \{ B int; .*`,
 }, {
 	value: &struct {
 		A int
 		B map[string]int ",inline"
 	}{1, map[string]int{"a": 2}},
-	panic: `Can't have key "a" in inlined map; conflicts with struct field`,
+	panic: `cannot have key "a" in inlined map: conflicts with struct field`,
 }}
 
 func (s *S) TestMarshalErrors(c *C) {

+ 7 - 7
yaml.go

@@ -352,7 +352,7 @@ func getStructInfo(st reflect.Type) (*structInfo, error) {
 				case "inline":
 					inline = true
 				default:
-					return nil, errors.New(fmt.Sprintf("Unsupported flag %q in tag %q of type %s", flag, tag, st))
+					return nil, errors.New(fmt.Sprintf("unsupported flag %q in tag %q of type %s", flag, tag, st))
 				}
 			}
 			tag = fields[0]
@@ -362,10 +362,10 @@ func getStructInfo(st reflect.Type) (*structInfo, error) {
 			switch field.Type.Kind() {
 			case reflect.Map:
 				if inlineMap >= 0 {
-					return nil, errors.New("Multiple ,inline maps in struct " + st.String())
+					return nil, errors.New("multiple ,inline maps in struct " + st.String())
 				}
 				if field.Type.Key() != reflect.TypeOf("") {
-					return nil, errors.New("Option ,inline needs a map with string keys in struct " + st.String())
+					return nil, errors.New("option ,inline needs a map with string keys in struct " + st.String())
 				}
 				inlineMap = info.Num
 			case reflect.Struct:
@@ -375,7 +375,7 @@ func getStructInfo(st reflect.Type) (*structInfo, error) {
 				}
 				for _, finfo := range sinfo.FieldsList {
 					if _, found := fieldsMap[finfo.Key]; found {
-						msg := "Duplicated key '" + finfo.Key + "' in struct " + st.String()
+						msg := "duplicated key '" + finfo.Key + "' in struct " + st.String()
 						return nil, errors.New(msg)
 					}
 					if finfo.Inline == nil {
@@ -388,8 +388,8 @@ func getStructInfo(st reflect.Type) (*structInfo, error) {
 					fieldsList = append(fieldsList, finfo)
 				}
 			default:
-				//return nil, errors.New("Option ,inline needs a struct value or map field")
-				return nil, errors.New("Option ,inline needs a struct value field")
+				//return nil, errors.New("option ,inline needs a struct value or map field")
+				return nil, errors.New("option ,inline needs a struct value field")
 			}
 			continue
 		}
@@ -401,7 +401,7 @@ func getStructInfo(st reflect.Type) (*structInfo, error) {
 		}
 
 		if _, found = fieldsMap[info.Key]; found {
-			msg := "Duplicated key '" + info.Key + "' in struct " + st.String()
+			msg := "duplicated key '" + info.Key + "' in struct " + st.String()
 			return nil, errors.New(msg)
 		}