godebug icon indicating copy to clipboard operation
godebug copied to clipboard

"no buildable Go source files"

Open jeremyschlatter opened this issue 10 years ago • 5 comments

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

jeremyschlatter avatar May 08 '15 19:05 jeremyschlatter

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

jeremyschlatter avatar May 08 '15 19:05 jeremyschlatter

Hit the same problem when trying to build (with the new UX) package github.com/FiloSottile/BERserk/BERserker which imports github.com/FiloSottile/BERserk.

FiloSottile avatar May 17 '15 22:05 FiloSottile

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

TechnotronicOz avatar Jun 18 '15 14:06 TechnotronicOz

Same here, really struggling when trying to instrument packages with this otherwise great tool.

otoolep avatar Jul 17 '15 22:07 otoolep

Have the same issue

willfaught avatar Aug 15 '15 09:08 willfaught