return false
}
for _, c := range s {
- if c != '$' && c != '-' && c != '_' && !unicode.IsLetter(c) && !unicode.IsDigit(c) {
- return false
+ switch c {
+ case '$', '-', '_', '/', '%':
+ // Acceptable
+ default:
+ if !unicode.IsLetter(c) && !unicode.IsDigit(c) {
+ return false
+ }
}
}
return true
V string `json:"色は匂へど"`
}
+type percentSlashTag struct {
+ V string `json:"text/html%"` // http://golang.org/issue/2718
+}
+
type emptyTag struct {
W string
}
{misnamedTag{"Animal Kingdom"}, "Animal Kingdom", "X"},
{badFormatTag{"Orfevre"}, "Orfevre", "Y"},
{badCodeTag{"Reliable Man"}, "Reliable Man", "Z"},
+ {percentSlashTag{"brut"}, "brut", "text/html%"},
}
func TestStructTagObjectKey(t *testing.T) {
t.Fatalf("Unexpected value: %#q, want %v", s, tt.value)
}
default:
- t.Fatalf("Unexpected key: %#q", i)
+ t.Fatalf("Unexpected key: %#q, from %#q", i, b)
}
}
}