goparse

package
v0.0.0-...-cf2c34e Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 8, 2024 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package goparse is the help package of Go language ast tree.

Index

Constants

View Source
const (
	GOARCH    = "GOARCH"
	GOOS      = "GOOS"
	GOPATH    = "GOPATH"
	GOPACKAGE = "GOPACKAGE"
	GOFILE    = "GOFILE"
	GOLINE    = "GOLINE"

	GoGeneratePrefix = "//go:generate"
)

go generate tools environment value.

Variables

View Source
var (
	EnvGoArch    string
	EnvGoOS      string
	EnvGoPath    string
	EnvGoPackage string
	EnvGoFile    string
	EnvGoLine    int
)

go generate tools environment value.

View Source
var GoGenerateToolsCompatibilityLineCount int = 2

GoGenerateToolsCompatibilityLineCount use to modify compatibility line count

Functions

func Format

func Format(fset *token.FileSet, node interface{}) string

Format printer.Fprint wrap.

func ParseMulPackage

func ParseMulPackage(patterns []string, tags ...string) (pkgs []*packages.Package, err error)

ParsePackage parse specified packages.

Types

type Package

type Package struct {
	// contains filtered or unexported fields
}

func ParseGeneratePackage

func ParseGeneratePackage(tags ...string) (pkg *Package, err error)

ParseGeneratePackage by go generate env

func ParsePackage

func ParsePackage(patterns []string, tags ...string) (pkg *Package, err error)

ParsePackage parse specified packages.

func (*Package) ConstDeclValue

func (p *Package) ConstDeclValue(f func(decl *ast.GenDecl, vspec *ast.ValueSpec, cm ast.CommentMap) bool)

ConstDecl range const value

func (*Package) ConstDeclValueWithType

func (p *Package) ConstDeclValueWithType(t string, f func(decl *ast.GenDecl, vspec *ast.ValueSpec, cm ast.CommentMap) bool)

ConstDeclValueWithType range specified type const values

func (*Package) Fset

func (p *Package) Fset() *token.FileSet

Fset get fileset

func (*Package) FuncDecl

func (p *Package) FuncDecl(f func(decl *ast.FuncDecl, cm ast.CommentMap) bool)

FuncDecl range func declare

func (*Package) GenDecl

func (p *Package) GenDecl(f func(decl *ast.GenDecl, cm ast.CommentMap) bool)

GenDecl range all GenDecl

func (*Package) GetDefObj

func (p *Package) GetDefObj(name *ast.Ident) (obj types.Object, ok bool)

GetDefObj get define object

func (*Package) GetGenerateNode

func (p *Package) GetGenerateNode() (node ast.Node, cm ast.CommentMap, err error)

GetGenerateNode get go generate tools specified node

func (*Package) Package

func (p *Package) Package() *packages.Package

Package get original package

func (*Package) Position

func (p *Package) Position(pos token.Pos) token.Position

Position transport to Position

func (*Package) RangeFile

func (p *Package) RangeFile(f func(file *ast.File, fset *token.FileSet, cm ast.CommentMap) bool)

func (*Package) TypeDecl

func (p *Package) TypeDecl(f func(decl *ast.GenDecl, typ *ast.TypeSpec, cm ast.CommentMap) bool)

TypeDecl range type declare

func (*Package) TypeDeclWithName

func (p *Package) TypeDeclWithName(typ string, f func(decl *ast.GenDecl, typ *ast.TypeSpec, cm ast.CommentMap))

TypeDeclWithName run with specified type define

func (*Package) VarDecl

func (p *Package) VarDecl(f func(decl *ast.GenDecl, typ *ast.ValueSpec, cm ast.CommentMap) bool)

VarDecl range value define

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL