今天研究了一下 goland 的 scratch file,发现真是一个很好用的功能,但遇到了一个依赖上的问题
scratch file 可以使用 module 的上下文( using context of module ),我选择了当前在开发的 module (采用 go mod ),就遇到了依赖的问题,但 ide 的补全等功能都可以正常使用
当go.mod中 module 名不是一个单词时(包含 . / _ 等符号时),编译运行 scratch file 就会找不到依赖
scratch_4.go:3:8: cannot find package "tttt-" in any of:
/usr/local/Cellar/go/1.14.2_1/libexec/src/tttt- (from $GOROOT)
/Users/creedowl/go/src/tttt- (from $GOPATH)
只有在 module 名是一个单词的时候才能正常编译运行,但使用项目的 github 地址等作为 module 名是很普遍的操作,也是官方支持的,所以是否有办法在 module 名不为单个单词时解决 scratch file 的依赖问题?
PS 我测试了项目在 go path 内外,都会有这个问题