util

package
v0.0.0-...-e33f817 Latest Latest
Warning

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

Go to latest
Published: Feb 26, 2025 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

util is a package that contains common utility functions used across the application. This is a convenient place to put any function that interacts with the `types` or `ast` packages from the Go standard library. This package is also a good place to put any functions that are used in multiple places, and especially in multiple packages. This package should be kept as small as possible, and should not contain any functions that are specific to a single package. All exported functions must be documented in a way that is compatible with `godoc`.

Index

Constants

View Source
const (
	ErrorType = "error"
)

Variables

This section is empty.

Functions

func AssertExpressionEqual

func AssertExpressionEqual(a dst.Expr, b dst.Expr) bool

AssertExpressionEqual compares two dst.Expr and returns true if they are equal by recursively comparing their fields and values.

func DebugPrint

func DebugPrint(node dst.Node) string

DebugPrint returns a string representation of the given node. This is useful for debugging purposes, and will pretty print the structure of a node in human readable form.

Do Not Use: This function is only for debugging purposes.

func FunctionName

func FunctionName(call *dst.CallExpr) string

FunctionName returns the name of the function being invoked in a call expression

func IsBenchmark

func IsBenchmark(pkg *decorator.Package, decl *dst.FuncDecl) bool

func IsError

func IsError(t types.Type) bool

IsError returns true if the type is an error type

func IsGenerated

func IsGenerated(decorator *decorator.Decorator, file *dst.File) bool

func IsTestPackage

func IsTestPackage(pkg *decorator.Package) bool

func IsUnderlyingType

func IsUnderlyingType(underlyingType types.Type, name string) bool

func IsUnitTest

func IsUnitTest(pkg *decorator.Package, decl *dst.FuncDecl) bool

func PackagePath

func PackagePath(ident *dst.Ident, pkg *decorator.Package) string

PackagePath returns the package path of the ident according to go types info

func Position

func Position(node dst.Node, pkg *decorator.Package) *token.Position

Position returns the position of the node in the file

func PrintNode

func PrintNode(pkg *decorator.Package, node dst.Node) string

PrintNode returns a string representation of the node as go code.

Warning: `gofmt` is applied to the output.

func TypeOf

func TypeOf(expr dst.Expr, pkg *decorator.Package) types.Type

TypeOf returns the types.Type of the ident according to go types info

func WriteExpr

func WriteExpr(expr dst.Expr, pkg *decorator.Package) string

WriteExpr returns a shortened string representation of the expression as go code.

Warning: This may not be equivilent to how it appears in the source code!

Types

This section is empty.

Jump to

Keyboard shortcuts

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