github.com/goplus/reflectx@v1.2.2/structfield.go (about)

     1  //go:build !go1.19
     2  // +build !go1.19
     3  
     4  package reflectx
     5  
     6  // struct field
     7  type structField struct {
     8  	name        name    // name is always non-empty
     9  	typ         *rtype  // type of field
    10  	offsetEmbed uintptr // byte offset of field<<1 | isEmbedded
    11  }
    12  
    13  func (f *structField) offset() uintptr {
    14  	return f.offsetEmbed >> 1
    15  }
    16  
    17  func (f *structField) embedded() bool {
    18  	return f.offsetEmbed&1 != 0
    19  }
    20  
    21  func setEmbedded(f *structField) {
    22  	f.offsetEmbed |= 1
    23  }