github.com/searKing/golang/go@v1.2.117/encoding/internal/tag/userDefinedTagFunc.go (about) 1 // Copyright 2020 The searKing Author. All rights reserved. 2 // Use of this source code is governed by a BSD-style 3 // license that can be found in the LICENSE file. 4 5 package tag 6 7 import "reflect" 8 9 // Convert v 10 func userDefinedTagFunc(e *tagState, v reflect.Value, _ tagOpts) (isUserDefined bool) { 11 isUserDefined = true 12 if v.Kind() == reflect.Ptr && v.IsNil() { 13 return 14 } 15 m, ok := v.Interface().(Tagger) 16 if !ok { 17 return 18 } 19 err := m.TagDefault() 20 if err != nil { 21 e.error(&TaggerError{v.Type(), err}) 22 } 23 return 24 } 25 26 // Convert &v 27 func addrUserDefinedTagFunc(e *tagState, v reflect.Value, _ tagOpts) (isUserDefined bool) { 28 isUserDefined = true 29 va := v.Addr() 30 if va.IsNil() { 31 return 32 } 33 m := va.Interface().(Tagger) 34 err := m.TagDefault() 35 36 if err != nil { 37 e.error(&TaggerError{v.Type(), err}) 38 } 39 return 40 }