Skip to content

Why the type of failpoint.Value can't be string #62

Description

@SmartMalphite

the definition in the source code about Value's type in "github.com/pingcap/failpoint/failpoint.go"

	// Value represents value that retrieved from failpoint terms.
	// It can be used as following types:
	// 1. val.(int)      // GO_FAILPOINTS="failpoint-name=return(1)"
	// 2. val.(string)   // GO_FAILPOINTS="failpoint-name=return('1')"
	// 3. val.(bool)     // GO_FAILPOINTS="failpoint-name=return(true)"
	Value interface{}

but in my code

failpoint.Inject("demoPanic", func(val failpoint.Value) {
		fmt.Println(val)
		fmt.Println(val.(string))
}

and start my progrom with cmd:
GO_FAILPOINTS="mypackagename/demoPanic=return('100')" ./beego-backend
An exception was thrown
[panic.go:522] Handler crashed with error interface conversion: failpoint.Value is bool, not string ···

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionFurther information is requested

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions