mirror of https://github.com/golang/go.git
cmd/vet: check only for ASCII spaces (0x20) in struct tags
Change-Id: I6e9b5caeca842b6bf72afefb31f5140608b86d20 Reviewed-on: https://go-review.googlesource.com/58530 Run-TryBot: Francesc Campoy Flores <campoy@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Rob Pike <r@golang.org>
This commit is contained in:
parent
6d7db25e5c
commit
e258249c24
|
|
@ -13,7 +13,6 @@ import (
|
|||
"reflect"
|
||||
"strconv"
|
||||
"strings"
|
||||
"unicode"
|
||||
)
|
||||
|
||||
func init() {
|
||||
|
|
@ -195,7 +194,7 @@ func validateStructTag(tag string) error {
|
|||
value = value[comma+1:]
|
||||
}
|
||||
|
||||
if strings.IndexFunc(value, unicode.IsSpace) >= 0 {
|
||||
if strings.IndexByte(value, ' ') >= 0 {
|
||||
return errTagValueSpace
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -83,15 +83,14 @@ type DuplicateJSONFields struct {
|
|||
|
||||
type UnexpectedSpacetest struct {
|
||||
A int `json:"a,omitempty"`
|
||||
B int `json:"b, omitempty"` // ERROR "suspicious space found in struct tag value"
|
||||
C int `json:"c,omitempty\t"` // ERROR "suspicious space found in struct tag value"
|
||||
D int `json:"d ,omitempty"`
|
||||
E int `json:"e,omitempty, string"` // ERROR "suspicious space found in struct tag value"
|
||||
F int `xml:" f"` // ERROR "suspicious space found in struct tag value"
|
||||
G int `xml:"g "` // ERROR "suspicious space found in struct tag value"
|
||||
H int `xml:"h ,omitempty"` // ERROR "suspicious space found in struct tag value"
|
||||
I int `xml:" i"` // ERROR "suspicious space found in struct tag value"
|
||||
J int `xml:"j "` // ERROR "suspicious space found in struct tag value"
|
||||
K int `xml:"k ,omitempty"` // ERROR "suspicious space found in struct tag value"
|
||||
L int `foo:" doesn't care "`
|
||||
B int `json:"b, omitempty"` // ERROR "suspicious space found in struct tag value"
|
||||
C int `json:"d ,omitempty"`
|
||||
D int `json:"e,omitempty, string"` // ERROR "suspicious space found in struct tag value"
|
||||
E int `xml:" f"` // ERROR "suspicious space found in struct tag value"
|
||||
F int `xml:"g "` // ERROR "suspicious space found in struct tag value"
|
||||
G int `xml:"h ,omitempty"` // ERROR "suspicious space found in struct tag value"
|
||||
H int `xml:" i"` // ERROR "suspicious space found in struct tag value"
|
||||
I int `xml:"j "` // ERROR "suspicious space found in struct tag value"
|
||||
J int `xml:"k ,omitempty"` // ERROR "suspicious space found in struct tag value"
|
||||
K int `foo:" doesn't care "`
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue