Documentation
¶
Index ¶
- Constants
- func AddImport(root *dst.File, path string)
- func AddImportForcely(root *dst.File, path string)
- func AddStructField(decl dst.Decl, name string, typ string)
- func AddressOf(expr dst.Expr) *dst.UnaryExpr
- func ArrayType(elem dst.Expr) *dst.ArrayType
- 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 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 ExtractVersion(path string) string
- func FindFuncDecl(root *dst.File, name string) *dst.FuncDecl
- func FindImport(root *dst.File, path string) *dst.ImportSpec
- func GetConfigureLogPath(name string) string
- func GetGoModDir() (string, error)
- func GetGoModPath() (string, error)
- func GetInstrumentLogPath(name string) string
- func GetLogPath(name string) string
- func GetPreprocessLogPath(name string) string
- func GetProjRootDir() (string, error)
- func GetTempBuildDir() string
- func GetTempBuildDirWith(name string) string
- func GetVarNameOfFunc(fn string) string
- func HasGoBuildComment(text string) bool
- func HasReceiver(fn *dst.FuncDecl) bool
- func HashStruct(st interface{}) (uint64, error)
- 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 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 IsExistGoMod() (bool, error)
- 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 IsUnusedIdent(ident *dst.Ident) bool
- func IsVendorBuild() bool
- func MakePublic(name string) string
- 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 MatchVersion(version string, ruleVersion string) (bool, error)
- 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 ParseAstFromSnippet(codeSnippnet string) ([]dst.Stmt, error)
- func ParseAstFromSource(source string) (*dst.File, 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 SelectorExpr(x dst.Expr, sel string) *dst.SelectorExpr
- 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 WriteAstToFile(astRoot *dst.File, filePath string) (string, error)
Constants ¶
const ( IdentNil = "nil" IdentTrue = "true" IdentFalse = "false" IdentIgnore = "_" )
const ( GoBuildIgnoreComment = "//go:build ignore" GoModFile = "go.mod" GoSumFile = "go.sum" GoWorkSumFile = "go.work.sum" DebugLogFile = "debug.log" TempBuildDir = ".otel-build" VendorDir = "vendor" BuildModeVendor = "-mod=vendor" BuildModeMod = "-mod=mod" BuildConfFile = "build_conf.json" )
Variables ¶
This section is empty.
Functions ¶
func AddImportForcely ¶
func AssertGoBuild ¶ added in v0.4.0
func AssertGoBuild(args []string)
func AssignStmt ¶
func AssignStmt(lhs, rhs dst.Expr) *dst.AssignStmt
func DefineStmts ¶
func DefineStmts(lhs, rhs []dst.Expr) *dst.AssignStmt
func ExtractVersion ¶ added in v0.0.2
func FindImport ¶ added in v0.5.0
func FindImport(root *dst.File, path string) *dst.ImportSpec
func GetConfigureLogPath ¶ added in v0.4.1
func GetGoModDir ¶ added in v0.3.0
GetGoModDir returns the directory of go.mod file.
func GetGoModPath ¶
GetGoModPath returns the absolute path of go.mod file, if any.
func GetInstrumentLogPath ¶
func GetLogPath ¶
func GetPreprocessLogPath ¶
func GetProjRootDir ¶ added in v0.4.0
GetProjRootDir returns the root directory of the project. It's an alias of GetGoModDir in the current implementation.
func GetTempBuildDir ¶ added in v0.4.0
func GetTempBuildDir() string
func GetTempBuildDirWith ¶ added in v0.4.1
func GetVarNameOfFunc ¶
func HasGoBuildComment ¶
func HasReceiver ¶
func HashStruct ¶
func InterfaceType ¶
func InterfaceType() *dst.InterfaceType
func IsCompileCommand ¶
func IsEllipsis ¶
func IsExistGoMod ¶
func IsGoModFile ¶ added in v0.4.0
func IsGoSumFile ¶ added in v0.4.0
func IsGoTestFile ¶ added in v0.4.0
func IsInterfaceType ¶
func IsUnusedIdent ¶
func IsVendorBuild ¶ added in v0.6.0
func IsVendorBuild() bool
func MakePublic ¶ added in v0.4.0
func MatchVersion ¶ added in v0.0.2
MatchVersion checks if the version string matches the version range in the rule. The version range is in format [start, end), where start is inclusive and end is exclusive. If the rule version string is empty, it always matches.
func ParseAstFromFile ¶
ParseAstFromFile parses the AST from complete source file.
func ParseAstFromFileFast ¶ added in v0.0.2
func ParseAstFromFileOnlyPackage ¶ added in v0.4.0
func ParseAstFromSnippet ¶
ParseAstFromSnippet parses the AST from incomplete source code snippet.
func ParseAstFromSource ¶
ParseAstFromSource parses the AST from complete source code.
func RemoveGoBuildComment ¶
func RemoveImport ¶ added in v0.4.0
func RemoveImport(root *dst.File, path string) *dst.ImportSpec
func RenamePackage ¶
func ReturnStmt ¶
func ReturnStmt(results []dst.Expr) *dst.ReturnStmt
func SelectorExpr ¶
func SelectorExpr(x dst.Expr, sel string) *dst.SelectorExpr
func SplitCmds ¶ added in v0.3.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 ¶
func TypeAssertExpr ¶
Types ¶
This section is empty.