github.com/shogo82148/std@v1.22.1-0.20240327122250-4e474527810c/cmd/compile/internal/types2/struct.go (about) 1 // Copyright 2021 The Go Authors. 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 types2 6 7 // A Struct represents a struct type. 8 type Struct struct { 9 fields []*Var 10 tags []string 11 } 12 13 // NewStruct returns a new struct with the given fields and corresponding field tags. 14 // If a field with index i has a tag, tags[i] must be that tag, but len(tags) may be 15 // only as long as required to hold the tag with the largest index i. Consequently, 16 // if no field has a tag, tags may be nil. 17 func NewStruct(fields []*Var, tags []string) *Struct 18 19 // NumFields returns the number of fields in the struct (including blank and embedded fields). 20 func (s *Struct) NumFields() int 21 22 // Field returns the i'th field for 0 <= i < NumFields(). 23 func (s *Struct) Field(i int) *Var 24 25 // Tag returns the i'th field tag for 0 <= i < NumFields(). 26 func (s *Struct) Tag(i int) string 27 28 func (s *Struct) Underlying() Type 29 func (s *Struct) String() string