$78 GRAYBYTE WORDPRESS FILE MANAGER $68

SERVER : vnpttt-amd7f72-h1.vietnix.vn #1 SMP Fri May 24 12:42:50 UTC 2024
SERVER IP : 103.200.23.149 | ADMIN IP 216.73.216.22
OPTIONS : CRL = ON | WGT = ON | SDO = OFF | PKEX = OFF
DEACTIVATED : NONE

/lib/golang/src/reflect/

HOME
Current File : /lib/golang/src/reflect//visiblefields.go
// Copyright 2021 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

package reflect

// VisibleFields returns all the visible fields in t, which must be a
// struct type. A field is defined as visible if it's accessible
// directly with a FieldByName call. The returned fields include fields
// inside anonymous struct members and unexported fields. They follow
// the same order found in the struct, with anonymous fields followed
// immediately by their promoted fields.
//
// For each element e of the returned slice, the corresponding field
// can be retrieved from a value v of type t by calling v.FieldByIndex(e.Index).
func VisibleFields(t Type) []StructField {
	if t == nil {
		panic("reflect: VisibleFields(nil)")
	}
	if t.Kind() != Struct {
		panic("reflect.VisibleFields of non-struct type")
	}
	w := &visibleFieldsWalker{
		byName:   make(map[string]int),
		visiting: make(map[Type]bool),
		fields:   make([]StructField, 0, t.NumField()),
		index:    make([]int, 0, 2),
	}
	w.walk(t)
	// Remove all the fields that have been hidden.
	// Use an in-place removal that avoids copying in
	// the common case that there are no hidden fields.
	j := 0
	for i := range w.fields {
		f := &w.fields[i]
		if f.Name == "" {
			continue
		}
		if i != j {
			// A field has been removed. We need to shuffle
			// all the subsequent elements up.
			w.fields[j] = *f
		}
		j++
	}
	return w.fields[:j]
}

type visibleFieldsWalker struct {
	byName   map[string]int
	visiting map[Type]bool
	fields   []StructField
	index    []int
}

// walk walks all the fields in the struct type t, visiting
// fields in index preorder and appending them to w.fields
// (this maintains the required ordering).
// Fields that have been overridden have their
// Name field cleared.
func (w *visibleFieldsWalker) walk(t Type) {
	if w.visiting[t] {
		return
	}
	w.visiting[t] = true
	for i := 0; i < t.NumField(); i++ {
		f := t.Field(i)
		w.index = append(w.index, i)
		add := true
		if oldIndex, ok := w.byName[f.Name]; ok {
			old := &w.fields[oldIndex]
			if len(w.index) == len(old.Index) {
				// Fields with the same name at the same depth
				// cancel one another out. Set the field name
				// to empty to signify that has happened, and
				// there's no need to add this field.
				old.Name = ""
				add = false
			} else if len(w.index) < len(old.Index) {
				// The old field loses because it's deeper than the new one.
				old.Name = ""
			} else {
				// The old field wins because it's shallower than the new one.
				add = false
			}
		}
		if add {
			// Copy the index so that it's not overwritten
			// by the other appends.
			f.Index = append([]int(nil), w.index...)
			w.byName[f.Name] = len(w.fields)
			w.fields = append(w.fields, f)
		}
		if f.Anonymous {
			if f.Type.Kind() == Pointer {
				f.Type = f.Type.Elem()
			}
			if f.Type.Kind() == Struct {
				w.walk(f.Type)
			}
		}
		w.index = w.index[:len(w.index)-1]
	}
	delete(w.visiting, t)
}

Current_dir [ NOT WRITEABLE ] Document_root [ WRITEABLE ]


[ Back ]
NAME
SIZE
LAST TOUCH
USER
CAN-I?
FUNCTIONS
..
--
16 Dec 2025 9.30 PM
root / root
0755
internal
--
4 Dec 2025 6.06 PM
root / root
0755
abi.go
15.021 KB
4 Dec 2025 6.06 PM
root / root
0644
arena.go
0.561 KB
4 Dec 2025 6.06 PM
root / root
0644
asm_386.s
1.073 KB
4 Dec 2025 6.06 PM
root / root
0644
asm_amd64.s
2.764 KB
4 Dec 2025 6.06 PM
root / root
0644
asm_arm.s
1.129 KB
4 Dec 2025 6.06 PM
root / root
0644
asm_arm64.s
2.767 KB
4 Dec 2025 6.06 PM
root / root
0644
asm_loong64.s
2.708 KB
4 Dec 2025 6.06 PM
root / root
0644
asm_mips64x.s
1.163 KB
4 Dec 2025 6.06 PM
root / root
0644
asm_mipsx.s
1.155 KB
4 Dec 2025 6.06 PM
root / root
0644
asm_ppc64x.s
3.314 KB
4 Dec 2025 6.06 PM
root / root
0644
asm_riscv64.s
2.581 KB
4 Dec 2025 6.06 PM
root / root
0644
asm_s390x.s
1.101 KB
4 Dec 2025 6.06 PM
root / root
0644
asm_wasm.s
1.147 KB
4 Dec 2025 6.06 PM
root / root
0644
badlinkname.go
4.51 KB
4 Dec 2025 6.06 PM
root / root
0644
deepequal.go
7.42 KB
4 Dec 2025 6.06 PM
root / root
0644
float32reg_generic.go
0.665 KB
4 Dec 2025 6.06 PM
root / root
0644
float32reg_ppc64x.s
0.818 KB
4 Dec 2025 6.06 PM
root / root
0644
float32reg_riscv64.s
0.775 KB
4 Dec 2025 6.06 PM
root / root
0644
iter.go
4.24 KB
4 Dec 2025 6.06 PM
root / root
0644
makefunc.go
5.912 KB
4 Dec 2025 6.06 PM
root / root
0644
map_noswiss.go
13.461 KB
4 Dec 2025 6.06 PM
root / root
0644
map_swiss.go
12.515 KB
4 Dec 2025 6.06 PM
root / root
0644
stubs_ppc64x.go
0.285 KB
4 Dec 2025 6.06 PM
root / root
0644
stubs_riscv64.go
0.257 KB
4 Dec 2025 6.06 PM
root / root
0644
swapper.go
1.994 KB
4 Dec 2025 6.06 PM
root / root
0644
type.go
79.763 KB
4 Dec 2025 6.06 PM
root / root
0644
value.go
113.486 KB
4 Dec 2025 6.06 PM
root / root
0644
visiblefields.go
2.966 KB
4 Dec 2025 6.06 PM
root / root
0644

GRAYBYTE WORDPRESS FILE MANAGER @ 2026 CONTACT ME
Static GIF