Open sh1yu opened 5 years ago
+1. I wrote something like:
fmt.Println("Testing failpoint")
err := failpoint.Enable("TestFailpoint", "return(1)")
if err != nil {
panic(err)
}
failpoint.Inject("TestFailpoint", func(val failpoint.Value) {
fmt.Println("enter TestFailpoint")
fmt.Println("Print 002")
})
fmt.Println("Print 001")
The closure in Inject func never run. I also tried to enable failpoint via env GO_FAILPOINT, but didn't work either.
When i run failpoint.Enable, then i run Eval, it worked. But seems it failed on replace marker func.
You should execute failpoint-ctl enable
in your workspace. Reference: https://github.com/pingcap/tidb/blob/190990b352b4939c75a60722573ab3f29baa9351/Makefile#L27
You should execute
failpoint-ctl enable
in your workspace. Reference: https://github.com/pingcap/tidb/blob/190990b352b4939c75a60722573ab3f29baa9351/Makefile#L27
I do make
and get a failpoint-ctl:
GO111MODULE=on CGO_ENABLED=0 GO111MODULE=on go build -ldflags '-X "github.com/pingcap/failpoint/failpoint-ctl/version.releaseVersion=bf45ab2" -X "github.com/pingcap/failpoint/failpoint-ctl/version.buildTS=2019-05-06 12:56:14" -X "github.com/pingcap/failpoint/failpoint-ctl/version.gitHash=bf45ab20bfc48d624b61944a4820768c16d7db99" -X "github.com/pingcap/failpoint/failpoint-ctl/version.gitBranch=master" -X "github.com/pingcap/failpoint/failpoint-ctl/version.goVersion=go version go1.11.5 darwin/amd64"' -o bin/failpoint-ctl failpoint-ctl/main.go
go: finding github.com/nicksnyder/go-i18n v1.10.0
go: finding github.com/go-playground/overalls v0.0.0-20180201144345-22ec1a223b7c
go: finding github.com/google/shlex v0.0.0-20181106134648-c34317bd91bf
go: finding github.com/pelletier/go-toml v1.3.0
go: finding github.com/pingcap/check v0.0.0-20190102082844-67f458068fc8
go: finding github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf
go: finding github.com/yookoala/realpath v1.0.0
go: finding gopkg.in/alecthomas/kingpin.v3-unstable v3.0.0-20180810215634-df19058c872c
go: finding gopkg.in/alecthomas/gometalinter.v2 v2.0.12
go: finding github.com/davecgh/go-spew v1.1.1
go: finding github.com/BurntSushi/toml v0.3.1
go: finding gopkg.in/yaml.v2 v2.2.2
go: finding gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405
failpoint-ctl build successfully :-) !
then when i try to use the ctl, i get this:
ru:~user$ failpoint-ctl enable
Rewrite error /Users/ru/.Trash/authExample.go:1:1: expected 'package', found 'var'
is there anything i do wrong this time? many thanks!
Your file /Users/ru/.Trash/authExample.go
does not start with package **
, which means that is not a valid Golang source file.
Your file
/Users/ru/.Trash/authExample.go
does not start withpackage **
, which means that is not a valid Golang source file.
sorry, my mistake, i didn't add the path. Thanks for you help!
Can we add this information into the README file?
@sdojjy Sure,file a PR is welcome
I cannot have any idea that how to use failpoint. I tried write demo like this:
There isn't have any output. How could I use it in the right way?