Versions in this module Expand all Collapse all v0 v0.1.0 Aug 13, 2026 Changes in this version + const MaxFileSize + var ErrTooLarge = errors.New("Go source is too large") + func ReadAll(reader io.Reader) ([]byte, error) + func ReadFile(path string) ([]byte, error) + func ValidateEquivalent(before, after *File) error + func ValidateFragmentEquivalent(before, after *Fragment) error + func ValidateSize(size int64) error + type Comment struct + ID CommentID + Range Range + Raw string + type CommentID uint32 + type Digest [sha256.Size]byte + type Directive struct + Kind DirectiveKind + Range Range + Raw string + type DirectiveKind uint8 + const DirectiveBuildConstraint + const DirectiveCgoPreamble + const DirectiveCompiler + const DirectiveExternalSuppression + const DirectiveGenerated + const DirectiveGoEmbed + const DirectiveGoGenerate + const DirectiveGoxSuppression + const DirectiveLine + type File struct + func Load(path string, input []byte) (*File, error) + func (f *File) Bytes() []byte + func (f *File) CanFormat() bool + func (f *File) Comments() []Comment + func (f *File) Digest() Digest + func (f *File) Directives() []Directive + func (f *File) Metadata() Metadata + func (f *File) Path() string + func (f *File) PhysicalOffset(position token.Pos) (int, bool) + func (f *File) Pieces() []Piece + func (f *File) Position(offset int) (Position, bool) + func (f *File) PreviousSignificantToken(position token.Pos) (Token, bool) + func (f *File) RawToken(position token.Pos) (string, bool) + func (f *File) ReadSyntax(read func(*ast.File) error) error + func (f *File) ReadSyntaxView(read func(*token.FileSet, *ast.File) error) error + func (f *File) Slice(sourceRange Range) (string, bool) + func (f *File) TokenRangeAtOffset(offset int) (Range, bool) + func (f *File) Tokens() []Token + func (f *File) Trivia() []Trivia + type Fragment struct + func LoadFragment(path string, kind FragmentKind, input []byte) (*Fragment, error) + func (f *Fragment) Bytes() []byte + func (f *Fragment) CanFormat() bool + func (f *Fragment) Comments() []Comment + func (f *Fragment) Digest() Digest + func (f *Fragment) Directives() []Directive + func (f *Fragment) Kind() FragmentKind + func (f *Fragment) Metadata() Metadata + func (f *Fragment) Path() string + func (f *Fragment) PhysicalOffset(position token.Pos) (int, bool) + func (f *Fragment) Pieces() []Piece + func (f *Fragment) RawToken(position token.Pos) (string, bool) + func (f *Fragment) ReadSyntax(read func(FragmentSyntax) error) error + func (f *Fragment) Slice(sourceRange Range) (string, bool) + func (f *Fragment) Tokens() []Token + func (f *Fragment) Trivia() []Trivia + type FragmentError struct + Column int + Line int + Message string + Offset int + Path string + func (e *FragmentError) Error() string + type FragmentKind uint8 + const FragmentDeclaration + const FragmentExpression + const FragmentStatement + type FragmentSyntax struct + Declarations []ast.Decl + Expression ast.Expr + Statements []ast.Stmt + type Metadata struct + FinalNewline bool + Generated bool + HasBOM bool + Newlines NewlineStyle + type NewlineStyle uint8 + const NewlineCRLF + const NewlineLF + const NewlineMixed + const NewlineNone + type Piece struct + Kind PieceKind + Range Range + Raw []byte + type PieceKind uint8 + const PieceToken + const PieceTrivia + type Position struct + Column int + Line int + Offset int + type Range struct + End int + Start int + type SemicolonKind uint8 + const SemicolonExplicit + const SemicolonInserted + const SemicolonNone + type Token struct + Kind token.Token + Range Range + Raw string + Semicolon SemicolonKind + type Trivia struct + Kind TriviaKind + Range Range + Raw string + type TriviaKind uint8 + const TriviaBOM + const TriviaWhitespace