Versions in this module Expand all Collapse all v1 v1.1.1 Apr 29, 2026 v1.0.0 Apr 29, 2026 Changes in this version + const Indent + const NewLine + const NilIndent + const WhiteSpace + func DuplicateStmtError(pos token.Position, msg string) error + func Fprint(w io.Writer, x interface{}, f FieldFilter) error + func NotNilFilter(_ string, v reflect.Value) bool + func Print(x interface{}) error + func SyntaxError(pos token.Position, format string, v ...interface{}) error + type AST struct + Filename string + Stmts []Stmt + func (a *AST) Format(w io.Writer) + func (a *AST) FormatForUnitTest(w io.Writer) + func (a *AST) Print() + type AnyDataType struct + Any *TokenNode + func (t *AnyDataType) CanEqual() bool + func (t *AnyDataType) CommentGroup() (head, leading CommentGroup) + func (t *AnyDataType) ContainsStruct() bool + func (t *AnyDataType) End() token.Position + func (t *AnyDataType) Format(prefix ...string) string + func (t *AnyDataType) HasHeadCommentGroup() bool + func (t *AnyDataType) HasLeadingCommentGroup() bool + func (t *AnyDataType) Pos() token.Position + func (t *AnyDataType) RawText() string + type ArrayDataType struct + DataType DataType + LBrack *TokenNode + Length *TokenNode + RBrack *TokenNode + func (t *ArrayDataType) CanEqual() bool + func (t *ArrayDataType) CommentGroup() (head, leading CommentGroup) + func (t *ArrayDataType) ContainsStruct() bool + func (t *ArrayDataType) End() token.Position + func (t *ArrayDataType) Format(prefix ...string) string + func (t *ArrayDataType) HasHeadCommentGroup() bool + func (t *ArrayDataType) HasLeadingCommentGroup() bool + func (t *ArrayDataType) Pos() token.Position + func (t *ArrayDataType) RawText() string + type AtDocGroupStmt struct + AtDoc *TokenNode + LParen *TokenNode + RParen *TokenNode + Values []*KVExpr + func (a *AtDocGroupStmt) CommentGroup() (head, leading CommentGroup) + func (a *AtDocGroupStmt) End() token.Position + func (a *AtDocGroupStmt) Format(prefix ...string) string + func (a *AtDocGroupStmt) HasHeadCommentGroup() bool + func (a *AtDocGroupStmt) HasLeadingCommentGroup() bool + func (a *AtDocGroupStmt) Pos() token.Position + type AtDocLiteralStmt struct + AtDoc *TokenNode + Value *TokenNode + func (a *AtDocLiteralStmt) CommentGroup() (head, leading CommentGroup) + func (a *AtDocLiteralStmt) End() token.Position + func (a *AtDocLiteralStmt) Format(prefix ...string) string + func (a *AtDocLiteralStmt) HasHeadCommentGroup() bool + func (a *AtDocLiteralStmt) HasLeadingCommentGroup() bool + func (a *AtDocLiteralStmt) Pos() token.Position + type AtDocStmt interface + type AtHandlerStmt struct + AtHandler *TokenNode + Name *TokenNode + func (a *AtHandlerStmt) CommentGroup() (head, leading CommentGroup) + func (a *AtHandlerStmt) End() token.Position + func (a *AtHandlerStmt) Format(prefix ...string) string + func (a *AtHandlerStmt) HasHeadCommentGroup() bool + func (a *AtHandlerStmt) HasLeadingCommentGroup() bool + func (a *AtHandlerStmt) Pos() token.Position + type AtServerStmt struct + AtServer *TokenNode + LParen *TokenNode + RParen *TokenNode + Values []*KVExpr + func (a *AtServerStmt) CommentGroup() (head, leading CommentGroup) + func (a *AtServerStmt) End() token.Position + func (a *AtServerStmt) Format(prefix ...string) string + func (a *AtServerStmt) HasHeadCommentGroup() bool + func (a *AtServerStmt) HasLeadingCommentGroup() bool + func (a *AtServerStmt) Pos() token.Position + type BaseDataType struct + Base *TokenNode + func (t *BaseDataType) CanEqual() bool + func (t *BaseDataType) CommentGroup() (head, leading CommentGroup) + func (t *BaseDataType) ContainsStruct() bool + func (t *BaseDataType) End() token.Position + func (t *BaseDataType) Format(prefix ...string) string + func (t *BaseDataType) HasHeadCommentGroup() bool + func (t *BaseDataType) HasLeadingCommentGroup() bool + func (t *BaseDataType) Pos() token.Position + func (t *BaseDataType) RawText() string + type BodyExpr struct + LBrack *TokenNode + RBrack *TokenNode + Star *TokenNode + Value *TokenNode + func (e *BodyExpr) CommentGroup() (head, leading CommentGroup) + func (e *BodyExpr) End() token.Position + func (e *BodyExpr) Format(...string) string + func (e *BodyExpr) HasHeadCommentGroup() bool + func (e *BodyExpr) HasLeadingCommentGroup() bool + func (e *BodyExpr) IsArrayType() bool + func (e *BodyExpr) Pos() token.Position + type BodyStmt struct + Body *BodyExpr + LParen *TokenNode + RParen *TokenNode + func (b *BodyStmt) CommentGroup() (head, leading CommentGroup) + func (b *BodyStmt) End() token.Position + func (b *BodyStmt) Format(...string) string + func (b *BodyStmt) HasHeadCommentGroup() bool + func (b *BodyStmt) HasLeadingCommentGroup() bool + func (b *BodyStmt) Pos() token.Position + type CommentGroup []*CommentStmt + func (cg CommentGroup) Join(sep string) string + func (cg CommentGroup) List() []string + func (cg CommentGroup) String() string + func (cg CommentGroup) Valid() bool + type CommentStmt struct + Comment token.Token + func (c *CommentStmt) CommentGroup() (head, leading CommentGroup) + func (c *CommentStmt) End() token.Position + func (c *CommentStmt) Format(prefix ...string) string + func (c *CommentStmt) HasHeadCommentGroup() bool + func (c *CommentStmt) HasLeadingCommentGroup() bool + func (c *CommentStmt) Pos() token.Position + type DataType interface + CanEqual func() bool + ContainsStruct func() bool + RawText func() string + type ElemExpr struct + DataType DataType + Name []*TokenNode + Tag *TokenNode + func (e *ElemExpr) CommentGroup() (head, leading CommentGroup) + func (e *ElemExpr) End() token.Position + func (e *ElemExpr) Format(prefix ...string) string + func (e *ElemExpr) HasHeadCommentGroup() bool + func (e *ElemExpr) HasLeadingCommentGroup() bool + func (e *ElemExpr) IsAnonymous() bool + func (e *ElemExpr) Pos() token.Position + type ElemExprList []*ElemExpr + type Expr interface + type FieldFilter func(name string, value reflect.Value) bool + type ImportGroupStmt struct + Import *TokenNode + LParen *TokenNode + RParen *TokenNode + Values []*TokenNode + func (i *ImportGroupStmt) CommentGroup() (head, leading CommentGroup) + func (i *ImportGroupStmt) End() token.Position + func (i *ImportGroupStmt) Format(prefix ...string) string + func (i *ImportGroupStmt) HasHeadCommentGroup() bool + func (i *ImportGroupStmt) HasLeadingCommentGroup() bool + func (i *ImportGroupStmt) Pos() token.Position + type ImportLiteralStmt struct + Import *TokenNode + Value *TokenNode + func (i *ImportLiteralStmt) CommentGroup() (head, leading CommentGroup) + func (i *ImportLiteralStmt) End() token.Position + func (i *ImportLiteralStmt) Format(prefix ...string) (result string) + func (i *ImportLiteralStmt) HasHeadCommentGroup() bool + func (i *ImportLiteralStmt) HasLeadingCommentGroup() bool + func (i *ImportLiteralStmt) Pos() token.Position + type ImportStmt interface + type InfoStmt struct + Info *TokenNode + LParen *TokenNode + RParen *TokenNode + Values []*KVExpr + func (i *InfoStmt) CommentGroup() (head, leading CommentGroup) + func (i *InfoStmt) End() token.Position + func (i *InfoStmt) Format(prefix ...string) string + func (i *InfoStmt) HasHeadCommentGroup() bool + func (i *InfoStmt) HasLeadingCommentGroup() bool + func (i *InfoStmt) Pos() token.Position + type InterfaceDataType struct + Interface *TokenNode + func (t *InterfaceDataType) CanEqual() bool + func (t *InterfaceDataType) CommentGroup() (head, leading CommentGroup) + func (t *InterfaceDataType) ContainsStruct() bool + func (t *InterfaceDataType) End() token.Position + func (t *InterfaceDataType) Format(prefix ...string) string + func (t *InterfaceDataType) HasHeadCommentGroup() bool + func (t *InterfaceDataType) HasLeadingCommentGroup() bool + func (t *InterfaceDataType) Pos() token.Position + func (t *InterfaceDataType) RawText() string + type KVExpr struct + Key *TokenNode + Value *TokenNode + func (i *KVExpr) CommentGroup() (head, leading CommentGroup) + func (i *KVExpr) End() token.Position + func (i *KVExpr) Format(prefix ...string) string + func (i *KVExpr) HasHeadCommentGroup() bool + func (i *KVExpr) HasLeadingCommentGroup() bool + func (i *KVExpr) Pos() token.Position + type MapDataType struct + Key DataType + LBrack *TokenNode + Map *TokenNode + RBrack *TokenNode + Value DataType + func (t *MapDataType) CanEqual() bool + func (t *MapDataType) CommentGroup() (head, leading CommentGroup) + func (t *MapDataType) ContainsStruct() bool + func (t *MapDataType) End() token.Position + func (t *MapDataType) Format(prefix ...string) string + func (t *MapDataType) HasHeadCommentGroup() bool + func (t *MapDataType) HasLeadingCommentGroup() bool + func (t *MapDataType) Pos() token.Position + func (t *MapDataType) RawText() string + type Node interface + CommentGroup func() (head, leading CommentGroup) + End func() token.Position + Format func(...string) string + HasHeadCommentGroup func() bool + HasLeadingCommentGroup func() bool + Pos func() token.Position + type Option func(o *option) + type PathExpr struct + Value *TokenNode + func (p *PathExpr) CommentGroup() (head, leading CommentGroup) + func (p *PathExpr) End() token.Position + func (p *PathExpr) Format(prefix ...string) string + func (p *PathExpr) HasHeadCommentGroup() bool + func (p *PathExpr) HasLeadingCommentGroup() bool + func (p *PathExpr) Pos() token.Position + type PointerDataType struct + DataType DataType + Star *TokenNode + func (t *PointerDataType) CanEqual() bool + func (t *PointerDataType) CommentGroup() (head, leading CommentGroup) + func (t *PointerDataType) ContainsStruct() bool + func (t *PointerDataType) End() token.Position + func (t *PointerDataType) Format(prefix ...string) string + func (t *PointerDataType) HasHeadCommentGroup() bool + func (t *PointerDataType) HasLeadingCommentGroup() bool + func (t *PointerDataType) Pos() token.Position + func (t *PointerDataType) RawText() string + type RouteStmt struct + Method *TokenNode + Path *PathExpr + Request *BodyStmt + Response *BodyStmt + Returns *TokenNode + func (r *RouteStmt) CommentGroup() (head, leading CommentGroup) + func (r *RouteStmt) End() token.Position + func (r *RouteStmt) Format(prefix ...string) string + func (r *RouteStmt) HasHeadCommentGroup() bool + func (r *RouteStmt) HasLeadingCommentGroup() bool + func (r *RouteStmt) Pos() token.Position + type ServiceItemStmt struct + AtDoc AtDocStmt + AtHandler *AtHandlerStmt + Route *RouteStmt + func (s *ServiceItemStmt) CommentGroup() (head, leading CommentGroup) + func (s *ServiceItemStmt) End() token.Position + func (s *ServiceItemStmt) Format(prefix ...string) string + func (s *ServiceItemStmt) HasHeadCommentGroup() bool + func (s *ServiceItemStmt) HasLeadingCommentGroup() bool + func (s *ServiceItemStmt) Pos() token.Position + type ServiceNameExpr struct + Name *TokenNode + func (s *ServiceNameExpr) CommentGroup() (head, leading CommentGroup) + func (s *ServiceNameExpr) End() token.Position + func (s *ServiceNameExpr) Format(...string) string + func (s *ServiceNameExpr) HasHeadCommentGroup() bool + func (s *ServiceNameExpr) HasLeadingCommentGroup() bool + func (s *ServiceNameExpr) Pos() token.Position + type ServiceStmt struct + AtServerStmt *AtServerStmt + LBrace *TokenNode + Name *ServiceNameExpr + RBrace *TokenNode + Routes []*ServiceItemStmt + Service *TokenNode + func (s *ServiceStmt) CommentGroup() (head, leading CommentGroup) + func (s *ServiceStmt) End() token.Position + func (s *ServiceStmt) Format(prefix ...string) string + func (s *ServiceStmt) HasHeadCommentGroup() bool + func (s *ServiceStmt) HasLeadingCommentGroup() bool + func (s *ServiceStmt) Pos() token.Position + type SliceDataType struct + DataType DataType + LBrack *TokenNode + RBrack *TokenNode + func (t *SliceDataType) CanEqual() bool + func (t *SliceDataType) CommentGroup() (head, leading CommentGroup) + func (t *SliceDataType) ContainsStruct() bool + func (t *SliceDataType) End() token.Position + func (t *SliceDataType) Format(prefix ...string) string + func (t *SliceDataType) HasHeadCommentGroup() bool + func (t *SliceDataType) HasLeadingCommentGroup() bool + func (t *SliceDataType) Pos() token.Position + func (t *SliceDataType) RawText() string + type Stmt interface + type StructDataType struct + Elements ElemExprList + LBrace *TokenNode + RBrace *TokenNode + func (t *StructDataType) CanEqual() bool + func (t *StructDataType) CommentGroup() (head, leading CommentGroup) + func (t *StructDataType) ContainsStruct() bool + func (t *StructDataType) End() token.Position + func (t *StructDataType) Format(prefix ...string) string + func (t *StructDataType) HasHeadCommentGroup() bool + func (t *StructDataType) HasLeadingCommentGroup() bool + func (t *StructDataType) Pos() token.Position + func (t *StructDataType) RawText() string + type SyntaxStmt struct + Assign *TokenNode + Syntax *TokenNode + Value *TokenNode + func (s *SyntaxStmt) CommentGroup() (head, leading CommentGroup) + func (s *SyntaxStmt) End() token.Position + func (s *SyntaxStmt) Format(prefix ...string) string + func (s *SyntaxStmt) HasHeadCommentGroup() bool + func (s *SyntaxStmt) HasLeadingCommentGroup() bool + func (s *SyntaxStmt) Pos() token.Position + type TokenNode struct + HeadCommentGroup CommentGroup + LeadingCommentGroup CommentGroup + Token token.Token + func NewTokenNode(tok token.Token) *TokenNode + func (t *TokenNode) CommentGroup() (head, leading CommentGroup) + func (t *TokenNode) End() token.Position + func (t *TokenNode) Equal(s string) bool + func (t *TokenNode) Format(prefix ...string) string + func (t *TokenNode) HasHeadCommentGroup() bool + func (t *TokenNode) HasLeadingCommentGroup() bool + func (t *TokenNode) IsEmptyString() bool + func (t *TokenNode) IsZeroString() bool + func (t *TokenNode) PeekFirstHeadComment() *CommentStmt + func (t *TokenNode) PeekFirstLeadingComment() *CommentStmt + func (t *TokenNode) Pos() token.Position + func (t *TokenNode) RawText() string + func (t *TokenNode) SetLeadingCommentGroup(cg CommentGroup) + type TypeExpr struct + Assign *TokenNode + DataType DataType + Name *TokenNode + func (e *TypeExpr) CommentGroup() (head, leading CommentGroup) + func (e *TypeExpr) End() token.Position + func (e *TypeExpr) Format(prefix ...string) string + func (e *TypeExpr) HasHeadCommentGroup() bool + func (e *TypeExpr) HasLeadingCommentGroup() bool + func (e *TypeExpr) Pos() token.Position + type TypeGroupStmt struct + ExprList []*TypeExpr + LParen *TokenNode + RParen *TokenNode + Type *TokenNode + func (t *TypeGroupStmt) CommentGroup() (head, leading CommentGroup) + func (t *TypeGroupStmt) End() token.Position + func (t *TypeGroupStmt) Format(prefix ...string) string + func (t *TypeGroupStmt) HasHeadCommentGroup() bool + func (t *TypeGroupStmt) HasLeadingCommentGroup() bool + func (t *TypeGroupStmt) Pos() token.Position + type TypeLiteralStmt struct + Expr *TypeExpr + Type *TokenNode + func (t *TypeLiteralStmt) CommentGroup() (head, leading CommentGroup) + func (t *TypeLiteralStmt) End() token.Position + func (t *TypeLiteralStmt) Format(prefix ...string) string + func (t *TypeLiteralStmt) HasHeadCommentGroup() bool + func (t *TypeLiteralStmt) HasLeadingCommentGroup() bool + func (t *TypeLiteralStmt) Pos() token.Position + type TypeStmt interface + type WriteMode int + const ModeAuto + const ModeExpectInSameLine + type Writer struct + func NewBufferWriter() *Writer + func NewWriter(writer io.Writer) *Writer + func (w *Writer) Flush() + func (w *Writer) NewLine() + func (w *Writer) String() string + func (w *Writer) Write(opts ...Option) + func (w *Writer) WriteText(text string)