resources: Replace golang 1.6 specific code with newer 1.7 version

We now require at least 1.8 so we might as well fix this up.
This commit is contained in:
James Shubin
2017-11-23 10:57:11 -05:00
parent 5e9a085e39
commit 879ff838ae

View File

@@ -96,10 +96,8 @@ func StructTagToFieldName(res Res) (map[string]string, error) {
for i := 0; i < st.NumField(); i++ { for i := 0; i < st.NumField(); i++ {
field := st.Field(i) field := st.Field(i)
name := field.Name name := field.Name
// TODO: golang 1.7+
// if !ok, then nothing is found // if !ok, then nothing is found
//if alias, ok := field.Tag.Lookup(StructTag); ok { // golang 1.7+ if alias, ok := field.Tag.Lookup(StructTag); ok { // golang 1.7+
if alias := field.Tag.Get(StructTag); alias != "" { // golang 1.6
if val, exists := result[alias]; exists { if val, exists := result[alias]; exists {
return nil, fmt.Errorf("field `%s` uses the same key `%s` as field `%s`", name, alias, val) return nil, fmt.Errorf("field `%s` uses the same key `%s` as field `%s`", name, alias, val)
} }