ceu get go does not load its own interfaces when a go vendor directory is present and CUE is not in the dependencies.
The error is in initInterfaces() (https://github.com/cuelang/cue/blob/master/cmd/cue/cmd/get_go.go#L287)
packages.Load does not return an error, but there are errors in p[0].Errors
We should be checking for these errors where this function is used.
repro:
mkdir intstr && cd intstr
go mod init foo.bar/intstr
cue mod init foo.bar/intstr
cat << EOF > repro.go
package intstr
import (
"k8s.io/apimachinery/pkg/util/intstr"
)
_ = intstr.IntOrString
EOF
go mod vendor
cue get go k8s.io/apimachinery/pkg/util/intstr
possible resolutions:
- check for the errors and return better messages
- modify the Config passed to packages.Load
- embed and load the
toTop and toText interfaces
(1) I'd generally prefer to have a solution that does not require the user to have Cue as a dependency. This seems like unpleasant DX, essentially telling them they need to have an artificial dependency via overly complex instructions.
(2) could be an easy solution. However, I'm leery of modifying the Config so that Cue code is fetched automatically. This might make some SecOps people unhappy / break in corp intranets.
(3) Config has an Overlay we could use to embed these files as strings. This seems like the best way to go.
We will also want to catch the errors in the other locations and provide an error message there.
What do others think?