expression

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Aug 15, 2024 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Dirs         = "dirs"
	Outputs      = "outputs"
	Random       = "random"
	Params       = "params"
	Globals      = "globals"
	Configs      = "configs"
	Base64Decode = "base64-decode"
	TriggerLabel = "triggers"
	I18n         = "i18n"
)
View Source
const (
	TaskNotJumpOver  SignType = 1 // task 不跳过
	TaskJumpOver     SignType = 0 // task 跳过
	LeftPlaceholder           = "${{"
	RightPlaceholder          = "}}"

	OldLeftPlaceholder  = "${"
	OldRightPlaceholder = "}"
)

Variables

View Source
var MockString = []string{"string", "integer", "integer_length", "float", "boolean", "upper", "lower", "mobile", "digital_letters", "letters", "character", "timestamp",
	"timestamp_hour", "timestamp_after_hour", "timestamp_day", "timestamp_after_day", "timestamp_ms", "timestamp_ms_hour", "timestamp_ms_after_hour",
	"timestamp_ms_day", "timestamp_ms_after_day", "timestamp_ns", "timestamp_ns_hour", "timestamp_ns_after_hour", "timestamp_ns_day",
	"timestamp_ns_after_day", "date", "date_day", "datetime", "datetime_hour"}
View Source
var OldRe = regexp.MustCompile(`\${([^{}]+)}`)

匹配 ${{ xxx }}

Functions

func AppendPlaceholder

func AppendPlaceholder(condition string) string

func DecodeOutputKey

func DecodeOutputKey(express string) (string, bool)

func EvalResultToString

func EvalResultToString(result interface{}) (string, error)

func GenAutotestConfigParams

func GenAutotestConfigParams(key string) string

func GenConfigParams

func GenConfigParams(key string) string

func GenDirsRef

func GenDirsRef(alias string) string

func GenOldParamsRef

func GenOldParamsRef(param string) string

func GenOutputRef

func GenOutputRef(alias, outputName string) string

func GenParamsRef

func GenParamsRef(param string) string

func GenRandomRef

func GenRandomRef(key string) string

func MatchEval

func MatchEval(str string, placeholderParams map[string]string, matchType ...string) (string, error)

str 整段包含 ${{}} 的字符串 placeholderParams eval 方法的参数 matchType 匹配那些类型 该方法是将 str 进行正则获取全部匹配的表达式,然后根据匹配的表达式执行 eval 方法,最后将表达式替换成执行的值

func Quote

func Quote(s string) string

func ReplacePlaceholder

func ReplacePlaceholder(condition string) string

func ReplaceRandomParams

func ReplaceRandomParams(ori string) string

Types

type ErrorInfo

type ErrorInfo struct {
	Code string // SyntaxError, ExecError, ResultFalse
	Msg  string
}

type ExpressionExecSign

type ExpressionExecSign struct {
	Sign      SignType
	Msg       string
	Err       *ErrorInfo
	Condition string
}

func Execute

func Execute(condition string) (sign ExpressionExecSign)

type SignType

type SignType int

Jump to

Keyboard shortcuts

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