"no buildable Go source files"
Given this directory structure:
a $ tree
.
├── a.go
└── b
├── b.go
└── c
└── c.go
2 directories, 3 files
a $ cat a.go
package main
import (
"a/b"
"a/b/c"
)
func main() {
b.B()
c.C()
}
a $ cat b/b.go
package b
func B() {
println("B")
}
a $ cat b/c/c.go
package c
func C() {
_ = "breakpoint"
println("C")
}
Running godebug without -instrument gives a helpful warning:
a $ godebug run a.go
godebug run: Ignoring breakpoint at a/b/c/c.go:4 because package "c" has not been flagged for instrumentation. See 'godebug help run'.
B
C
But the -instrument flag does not work as expected:
$ godebug run -instrument a/b/c a.go
/var/folders/4l/d1lsmz5d4972rfkg1gvv8hmc0000gn/T/godebug895759339/a.go:4:2: no buildable Go source files in /var/folders/4l/d1lsmz5d4972rfkg1gvv8hmc0000gn/T/godebug895759339/src/a/b
The problem happens because, in the above example, a/b/c is instrumented but a/b is not. godebug should be fixed to make this work, but in the meantime you can also instrument the parent packages as a workaround:
a $ godebug run -instrument a/b/c,a/b a.go
B
-> _ = "breakpoint"
(godebug) c
C
Hit the same problem when trying to build (with the new UX) package github.com/FiloSottile/BERserk/BERserker which imports github.com/FiloSottile/BERserk.
I have been having this same issue. We have multiple Go apps and we have structured the mains like:
|--- ./appOne/
|--- appOne.go
|--- ./appTwo/
|--- appTwo.go
then the sub packages exist in:
|--- ./lib/
|--- appOne/packageOne/
|--- packageOne.go
|--- appOne/packageTwo/
|--- packageTwo.go
|--- appTwo/packageOne/
|--- packageOne.go
Same here, really struggling when trying to instrument packages with this otherwise great tool.
Have the same issue