Source File
fields.go
Belonging Package
github.com/ghodss/yaml
package yaml
import (
)
if .Kind() == reflect.Interface && !.IsNil() {
:= .Elem()
if .Kind() == reflect.Ptr && !.IsNil() && (! || .Elem().Kind() == reflect.Ptr) {
=
continue
}
}
if .Kind() != reflect.Ptr {
break
}
if .Elem().Kind() != reflect.Ptr && && .CanSet() {
break
}
if .IsNil() {
if .CanSet() {
.Set(reflect.New(.Type().Elem()))
} else {
= reflect.New(.Type().Elem())
}
}
if .Type().NumMethod() > 0 {
if , := .Interface().(json.Unmarshaler); {
return , nil, reflect.Value{}
}
if , := .Interface().(encoding.TextUnmarshaler); {
return nil, , reflect.Value{}
}
}
= .Elem()
}
return nil, nil,
}
type byName []field
func ( byName) () int { return len() }
func ( byName) (, int) { [], [] = [], [] }
func ( byName) (, int) bool {
if [].name != [].name {
return [].name < [].name
}
if len([].index) != len([].index) {
return len([].index) < len([].index)
}
if [].tag != [].tag {
return [].tag
}
return byIndex().Less(, )
}
= .Elem()
}
:= [:0]
func ( reflect.Type) []field {
fieldCache.RLock()
:= fieldCache.m[]
fieldCache.RUnlock()
if != nil {
return
}
= typeFields()
if == nil {
= []field{}
}
fieldCache.Lock()
if fieldCache.m == nil {
fieldCache.m = map[reflect.Type][]field{}
}
fieldCache.m[] =
fieldCache.Unlock()
return
}
func ( string) bool {
if == "" {
return false
}
for , := range {
switch {
= true
}
}
if {
return equalFoldRight
}
if {
return asciiEqualFold
}
return simpleLetterEqualFold
}
, := utf8.DecodeRune()
switch {
case 's', 'S':
if != smallLongEss {
return false
}
case 'k', 'K':
if != kelvin {
return false
}
default:
return false
}
= [:]
}
if len() > 0 {
return false
}
return true
}
type tagOptions string
func ( string) (string, tagOptions) {
if := strings.Index(, ","); != -1 {
return [:], tagOptions([+1:])
}
return , tagOptions("")
}
![]() |
The pages are generated with Golds v0.3.2-preview. (GOOS=darwin GOARCH=amd64) Golds is a Go 101 project developed by Tapir Liu. PR and bug reports are welcome and can be submitted to the issue list. Please follow @Go100and1 (reachable from the left QR code) to get the latest news of Golds. |