Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type HasFieldOrder ¶
type HasFieldOrder struct {
// OrderedList ordered slice with the field names in the struct that are expected to be in order.
OrderedList []string
}
HasFieldOrder is a Fact attached to structs listing the field instantiation order.
func NewHasFieldOrder ¶
func NewHasFieldOrder(ol []string) *HasFieldOrder
func (HasFieldOrder) AFact ¶
func (h HasFieldOrder) AFact()
func (HasFieldOrder) FieldOrder ¶
func (h HasFieldOrder) FieldOrder() []string
FieldOrder returns a defensive copy of the expected field order.
func (HasFieldOrder) String ¶
func (h HasFieldOrder) String() string
type StructDecl ¶
type StructDecl struct {
// contains filtered or unexported fields
}
StructDecl represents a struct declaration.
func NewStructDecl ¶
func NewStructDecl(ts *ast.TypeSpec, doc *ast.CommentGroup) (StructDecl, bool)
NewStructDecl creates a new StructDecl. It needs to have a directive: //go:structinit.
func (*StructDecl) FieldOrder ¶
func (s *StructDecl) FieldOrder() []string
type StructInit ¶
type StructInit struct {
// contains filtered or unexported fields
}
StructInit represents a struct initialization. It has to be a composite literal in which the fields follow this pattern: - key: *ast.Ident - value: *ast.BasicLit | *ast.CompositeLit | *ast.Ident | *ast.CallExpr (when there is only one call expression) any other combination is not supported.
func NewStructInit ¶
func NewStructInit(cl *ast.CompositeLit, pass *analysis.Pass) (StructInit, bool)
NewStructInit returns a StructInit if the given composite literal is a struct initialization.