VSCode/Go告诉我去获取一个属于子文件夹的包。

huangapple go评论81阅读模式
英文:

VSCode/Go telling me to go get a package belonging to a subfolder

问题

Go/VSCode一直告诉我从GitHub获取一个包,但实际上它是我拥有的子文件夹。

我已经将go.mod中的路径替换为私有文件夹路径:

replace (
github.com/brianmaksy/m-highscore v0.0.0 => ./
)

一直弹出的错误信息是:

cli\server\main.go:7:2: 没有必需的模块提供了github.com/brianmaksy/m-highscore/internal包;要添加它:
go get github.com/brianmaksy/m-highscore/internal

如果有人知道可能出错的原因,我将非常感激。提前谢谢。

英文:

Go/VSCode keeps telling me to go get a package from github, when it is a subfolder which I own.

VSCode/Go告诉我去获取一个属于子文件夹的包。

I have already replaced the route in my go.mod to be a private folder path:

replace (
	github.com/brianmaksy/m-highscore v0.0.0 => ./
)

The error message that keeps popping up is:

cli\server\main.go:7:2: no required module provides package github.com/brianmaksy/m-highscore/internal; to add it:
        go get github.com/brianmaksy/m-highscore/internal

If anyone has an idea of what might be wrong, I'd be very grateful. Thanks in advance.

答案1

得分: 1

我找到了解决方案。问题似乎是因为"internal"是一个空文件夹。当我将导入语句更改为:

internal "github.com/brianmaksy/m-highscore/internal/server"

问题就解决了。

我将保留这个问题,以防将来有人有同样的问题。

英文:

I have found the solution. The problem appears to be that "internal" was an empty folder". As soon as I changed the import to:

internal "github.com/brianmaksy/m-highscore/internal/server"

the problem was gone.

Keeping this question here in case it helps anyone in the future.

huangapple
  • 本文由 发表于 2022年1月2日 07:37:15
  • 转载请务必保留本文链接:https://go.coder-hub.com/70552662.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定