Documentation
¶
Index ¶
- Constants
- Variables
- func AddImportForcely(root *dst.File, paths ...string) *dst.GenDecl
- func AddStructField(decl dst.Decl, name string, typ string)
- func AddressOf(expr dst.Expr) *dst.UnaryExpr
- func ArrayType(elem dst.Expr) *dst.ArrayType
- func Assert(cond bool, format string, args ...interface{})
- func AssertGoBuild(args []string)
- func AssignStmt(lhs, rhs dst.Expr) *dst.AssignStmt
- func Block(stmt dst.Stmt) *dst.BlockStmt
- func BlockStmts(stmts ...dst.Stmt) *dst.BlockStmt
- func BoolFalse() *dst.BasicLit
- func BoolTrue() *dst.BasicLit
- func CallTo(name string, args []dst.Expr) *dst.CallExpr
- func CopyDir(src string, dst string) error
- func CopyFile(src, dst string) error
- func DeferStmt(call *dst.CallExpr) *dst.DeferStmt
- func DefineStmts(lhs, rhs []dst.Expr) *dst.AssignStmt
- func DereferenceOf(expr dst.Expr) dst.Expr
- func EmptyStmt() *dst.EmptyStmt
- func ExprStmt(expr dst.Expr) *dst.ExprStmt
- func Exprs(exprs ...dst.Expr) []dst.Expr
- func FindFuncDecl(root *dst.File, name string) *dst.FuncDecl
- func FindImport(root *dst.File, path string) *dst.ImportSpec
- func GetInstrumentLogPath(name string) string
- func GetLogPath(name string) string
- func GetLoggerPath() string
- func GetPreprocessLogPath(name string) string
- func GetTempBuildDir() string
- func GetTempBuildDirWith(name string) string
- func GetToolName() (string, error)
- func GetVarNameOfFunc(fn string) string
- func GuaranteeInInstrument()
- func GuaranteeInPreprocess()
- func HasGoBuildComment(text string) bool
- func HasReceiver(fn *dst.FuncDecl) bool
- func Ident(name string) *dst.Ident
- func IfNotNilStmt(cond dst.Expr, body, elseBody *dst.BlockStmt) *dst.IfStmt
- func IfStmt(init dst.Stmt, cond dst.Expr, body, elseBody *dst.BlockStmt) *dst.IfStmt
- func InInstrument() bool
- func InPreprocess() bool
- func IndexExpr(x dst.Expr, index dst.Expr) *dst.IndexExpr
- func IntLit(value int) *dst.BasicLit
- func InterfaceType() *dst.InterfaceType
- func IsCompileCommand(line string) bool
- func IsEllipsis(typ dst.Expr) bool
- func IsGoFile(path string) bool
- func IsGoModFile(path string) bool
- func IsGoSumFile(path string) bool
- func IsGoTestFile(path string) bool
- func IsInterfaceType(typ dst.Expr) bool
- func IsModPath(path string) bool
- func IsStringLit(expr dst.Expr, val string) bool
- func IsUnix() bool
- func IsUnusedIdent(ident *dst.Ident) bool
- func IsWindows() bool
- func Jsonify(v interface{}) string
- func ListFiles(dir string) ([]string, error)
- func Log(format string, args ...interface{})
- func LogFatal(format string, args ...interface{})
- func MakeUnusedIdent(ident *dst.Ident) *dst.Ident
- func MatchFuncDecl(decl dst.Decl, function string, receiverType string) bool
- func MatchStructDecl(decl dst.Decl, structType string) bool
- func NewField(name string, typ dst.Expr) *dst.Field
- func NewVarDecl(name string, paramTypes *dst.FieldList) *dst.GenDecl
- func ParenExpr(x dst.Expr) *dst.ParenExpr
- func ParseAstFromFile(filePath string) (*dst.File, error)
- func ParseAstFromFileFast(filePath string) (*dst.File, error)
- func ParseAstFromFileOnlyPackage(filePath string) (*dst.File, error)
- func PathExists(path string) bool
- func PathNotExists(path string) bool
- func PhaseTimer(name string) func()
- func RandomString(n int) string
- func ReadFile(filePath string) (string, error)
- func RemoveGoBuildComment(text string) string
- func RemoveImport(root *dst.File, path string) *dst.ImportSpec
- func RenamePackage(source, newPkgName string) string
- func ReturnStmt(results []dst.Expr) *dst.ReturnStmt
- func RunCmd(args ...string) error
- func SelectorExpr(x dst.Expr, sel string) *dst.SelectorExpr
- func SetLogger(w *os.File)
- func SetRunPhase(phase RunPhase)
- func ShouldNotReachHere()
- func ShouldNotReachHereT(msg string)
- func SplitCmds(input string) []string
- func Stmts(stmts ...dst.Stmt) []dst.Stmt
- func StringLit(value string) *dst.BasicLit
- func SwitchCase(list []dst.Expr, stmts []dst.Stmt) *dst.CaseClause
- func TypeAssertExpr(x dst.Expr, typ dst.Expr) *dst.TypeAssertExpr
- func Unimplemented()
- func UnimplementedT(msg string)
- func WriteAstToFile(astRoot *dst.File, filePath string) (string, error)
- func WriteFile(filePath string, content string) (string, error)
- type AstParser
- type RunPhase
Constants ¶
View Source
const ( IdentNil = "nil" IdentTrue = "true" IdentFalse = "false" IdentIgnore = "_" )
View Source
const ( GoBuildIgnoreComment = "//go:build ignore" GoModFile = "go.mod" GoSumFile = "go.sum" GoWorkSumFile = "go.work.sum" DebugLogFile = "debug.log" TempBuildDir = ".otel-build" )
View Source
const ( BuildPattern = "-p" BuildGoVer = "-goversion" BuildPgoProfile = "-pgoprofile" BuildModeVendor = "-mod=vendor" BuildModeMod = "-mod=mod" BuildWork = "-work" )
View Source
const ( PInvalid = "invalid" PPreprocess = "preprocess" PInstrument = "instrument" )
Variables ¶
View Source
var Guarantee = Assert // More meaningful name:)
Functions ¶
func AddImportForcely ¶ added in v0.8.0
func AssertGoBuild ¶ added in v0.8.0
func AssertGoBuild(args []string)
func AssignStmt ¶ added in v0.8.0
func AssignStmt(lhs, rhs dst.Expr) *dst.AssignStmt
func DefineStmts ¶ added in v0.8.0
func DefineStmts(lhs, rhs []dst.Expr) *dst.AssignStmt
func FindImport ¶ added in v0.8.0
func FindImport(root *dst.File, path string) *dst.ImportSpec
func GetInstrumentLogPath ¶ added in v0.8.0
func GetLogPath ¶ added in v0.8.0
func GetLoggerPath ¶ added in v0.8.0
func GetLoggerPath() string
func GetPreprocessLogPath ¶ added in v0.8.0
func GetTempBuildDir ¶ added in v0.8.0
func GetTempBuildDir() string
func GetTempBuildDirWith ¶ added in v0.8.0
func GetToolName ¶ added in v0.5.0
func GetVarNameOfFunc ¶ added in v0.8.0
func GuaranteeInInstrument ¶ added in v0.5.0
func GuaranteeInInstrument()
func GuaranteeInPreprocess ¶ added in v0.5.0
func GuaranteeInPreprocess()
func HasGoBuildComment ¶ added in v0.8.0
func HasReceiver ¶ added in v0.8.0
func IfNotNilStmt ¶ added in v0.8.0
func InInstrument ¶ added in v0.5.0
func InInstrument() bool
func InPreprocess ¶ added in v0.5.0
func InPreprocess() bool
func InterfaceType ¶ added in v0.8.0
func InterfaceType() *dst.InterfaceType
func IsCompileCommand ¶ added in v0.8.0
func IsEllipsis ¶ added in v0.8.0
func IsGoModFile ¶ added in v0.8.0
func IsGoSumFile ¶ added in v0.8.0
func IsGoTestFile ¶ added in v0.8.0
func IsInterfaceType ¶ added in v0.8.0
func IsUnusedIdent ¶ added in v0.8.0
func MatchFuncDecl ¶ added in v0.8.0
func NewVarDecl ¶ added in v0.8.0
func ParseAstFromFile ¶ added in v0.8.0
ParseAstFromFile parses the AST from complete source file.
func ParseAstFromFileFast ¶ added in v0.8.0
func ParseAstFromFileOnlyPackage ¶ added in v0.8.0
func PathExists ¶
func PathNotExists ¶ added in v0.8.0
func PhaseTimer ¶ added in v0.4.0
func PhaseTimer(name string) func()
func RandomString ¶
RandomString generates a globally unique random string of length n
func RemoveGoBuildComment ¶ added in v0.8.0
func RemoveImport ¶ added in v0.8.0
func RemoveImport(root *dst.File, path string) *dst.ImportSpec
func RenamePackage ¶ added in v0.8.0
func ReturnStmt ¶ added in v0.8.0
func ReturnStmt(results []dst.Expr) *dst.ReturnStmt
func SelectorExpr ¶ added in v0.8.0
func SelectorExpr(x dst.Expr, sel string) *dst.SelectorExpr
func SetRunPhase ¶ added in v0.5.0
func SetRunPhase(phase RunPhase)
func ShouldNotReachHere ¶
func ShouldNotReachHere()
func ShouldNotReachHereT ¶
func ShouldNotReachHereT(msg string)
func SplitCmds ¶ added in v0.8.0
SplitCmds splits the command line by space, but keep the quoted part as a whole. For example, "a b" c will be split into ["a b", "c"].
func SwitchCase ¶ added in v0.8.0
func TypeAssertExpr ¶ added in v0.8.0
func Unimplemented ¶
func Unimplemented()
func UnimplementedT ¶
func UnimplementedT(msg string)
func WriteAstToFile ¶ added in v0.8.0
WriteAstToFile writes the AST to source file.
Types ¶
type AstParser ¶ added in v0.9.0
type AstParser struct {
// contains filtered or unexported fields
}
func NewAstParser ¶ added in v0.9.0
func NewAstParser() *AstParser
func (*AstParser) FindPosition ¶ added in v0.9.0
func (*AstParser) ParseSnippet ¶ added in v0.9.0
ParseSnippet parses the AST from incomplete source code snippet.
Click to show internal directories.
Click to hide internal directories.