You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
"missing package for %q; using %q as failpoint path\n",
pkgAbsDir,
pkg)
} else {
fppath=pkgDir[1:]
}
code.NewBinding(pkg, fppath, fps).Write(out)
out.Close()
With the go mod support after go1.11, source files can be outside of GOPATH. So when I run gofail, I can see the error: "missing package for %q; using %q as failpoint path".
I can think of several ways to get the package import path more accurately:
Search parent directories for the go.mod file which contains the import path of the module.
Use cmd.Exec to call go list to get the import path.
Use reflect in generated foo.fail.go to determine import path.
I personally think that the third method is better as it relies less on the executing environment. It can be done by generating such code:
type __fp_foo struct{}
var __fp_fooBar *runtime.Failpoint = runtime.NewFailpoint(reflect.TypeOf(__fp_foo{}).PkgPath(), "fooBar")
The text was updated successfully, but these errors were encountered:
Now the package path is calculated based on the relative relationship between GOPATH and the directory where the file is located:
gofail/gofail.go
Lines 130 to 150 in 51ce9a7
With the go mod support after go1.11, source files can be outside of GOPATH. So when I run gofail, I can see the error: "missing package for %q; using %q as failpoint path".
I can think of several ways to get the package import path more accurately:
go.mod
file which contains the import path of the module.cmd.Exec
to callgo list
to get the import path.foo.fail.go
to determine import path.I personally think that the third method is better as it relies less on the executing environment. It can be done by generating such code:
The text was updated successfully, but these errors were encountered: