hi all,
When using a `go get` in a project (module) that has a `go work` configured, I'm getting errors "cannot find module providing package ...", for the packages that are located on `go work use ...` locations. Meaning, `go get` seems to ignore (?) `
go.work` file.
Likely this is deliberate and I'm missing some point, but ... for my use case, I would love to have `go get` ignore the packages that are imported from directories in `
go.work`, and just "get" the other ones.
Is there a way to have that ? (I couldn't find any flag in `go get`). Or any other ideas ?
many thanks!
Jan
ps.: Here how to reproduce the issue:
Director "~/work/a/"
$ cat > main.go
package main
import (
"fmt"
"
github.com/joe/b"
)
func main() {
fmt.Printf("Hello from joe/a!\n")
b.Message()
}
$ go work init ; go work use . ~/work/b
In directory "~/work/b":
$ cat > b.go
package b
import "fmt"
func Message() {
fmt.Printf("Hello from joe/b!\n")
}
Back to directory "~/work/a":
$ go run .
Hello from joe/a!
Hello from joe/b!
$ go get
A bit more context, in case it matters: I don't need to `go get` to get anything for the packages in `
go.work`, but I (think) need it to get any potential missing other packages. I run `go get` (without specifying the packages) each time before executing a Jupyter notebook cell (in GoNB a jupyter notebook kernel), because I don't know ahead of time which new packages need to be fetched.
Also curiously, if I use a `replace` directive in `go.mod` then `go get` works fine, it seems to ignore the replaced package. In my example:
But a `replace` directive in `
go.work` doesn't seem parsed by `go get`: