go build: 在 /msfs2020-go-master 中没有 Go 文件

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

go build: no Go files in /msfs2020-go-master

问题

我正在尝试重新构建一个 golang 的 GitHub 仓库,以应用一些小的更改。

我要修改的 go 应用程序是这个:https://github.com/lian/msfs2020-go
请使用提供的 GitHub 链接来查看文件树。

我使用了 master 分支,并将其提取到 /user/Documents/msfs2020-go-master

如果我从 /user/Documents/msfs2020-go-master 目录下调用 go build,输出结果是:no Go files in /user/Documents/msfs2020-go-master

我尝试删除 go.mod 文件,并使用 go mod init github.com/lian/msfs2020-go 命令重新创建它,然后再运行 go mod tidy,但仍然显示 no Go files in /user/Documents/msfs2020-go-master

这是当前的 go.mod 文件内容:

module github.com/lian/msfs2020-go

go 1.16

require github.com/gorilla/websocket v1.4.2

这是 go.sum 文件内容:

github.com/gorilla/websocket v1.4.2 h1:+/TMaTYc4QFitKJxsQ7Yye35DkWvkdLcvGKqM+x0Ufc=
github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=

该 master 分支是使用 1.14 版本的 golang 构建的,而我正在使用 1.16 版本的 golang。
在开发级别的 "Hello World" 中,我所有的测试 go 应用程序/模块都可以正常运行/构建/安装。

我做错了什么?我很乐意接受任何建议,并提供额外的信息,如果需要的话。

英文:

Im trying to rebuild a golang github repository to apply some minor changes.

The go application Im trying to modify is the following https://github.com/lian/msfs2020-go
Please use the provided github link to inspect the file tree.

I used the master branch and extracted it to /user/Documents/msfs2020-go-master

If I call go build from /user/Documents/msfs2020-go-master the output equals: no Go files in /user/Documents/msfs2020-go-master

I tried deleting the go.mod and recreating it with go mod init github.com/lian/msfs2020-go followed with a go mod tidy
but still no Go files in /user/Documents/msfs2020-go-master

Here the current go.mod

module github.com/lian/msfs2020-go

go 1.16

require github.com/gorilla/websocket v1.4.2

And here the go.sum

github.com/gorilla/websocket v1.4.2 h1:+/TMaTYc4QFitKJxsQ7Yye35DkWvkdLcvGKqM+x0Ufc=
github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=

The master was build with 1.14 and Im using 1.16 golang.
All my test go applications/modules run/build/install fine at a "Hello World" developing level.

What did I do wrong? I gladly accept any input and will provide additional information's if requested.

答案1

得分: 3

命令go build会在当前工作目录中构建包。由于存储库的根目录下没有包,所以该命令会报错。

修复方法是构建包含该命令的包。以下任何一种方法都可以在存储库的根目录中使用:

go build ./vfrmap

或者

cd vrfrmap
go build

或者

go build github.com/lian/msfs2020-go/vfrmap

另请参阅文件build-vfrmap.sh

英文:

The command go build builds the package in the current working directory. The command reports an error because there is not a package at the root of the repository.

Fix by building the package containing the command. Any of the following will work from the root of the repository:

go build ./vfrmap

or

cd vrfrmap
go build

or

go build github.com/lian/msfs2020-go/vfrmap

See also the file build-vfrmap.sh.

huangapple
  • 本文由 发表于 2021年6月13日 08:47:45
  • 转载请务必保留本文链接:https://go.coder-hub.com/67954000.html
匿名

发表评论

匿名网友

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

确定