Gogs构建失败,显示”没有可构建的Go源文件”。

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

Gogs build fails with "no buildable Go source files"

问题

我正在尝试按照这个指南从源代码安装gogs。

然而,当我进入gogs目录并运行"go build"时,我遇到了以下错误:"在[PATH-TO-GOGS]中没有可构建的Go源文件"。

然而,所有所需的文件似乎都在那里。

英文:

I was trying to install gogs from source following this guide.

However once I navigated to the gogs directory and hit "go build" i got the following error "no buildable Go source files in [PATH-TO-GOGS]"

However all required files seem to be there.

答案1

得分: 1

我会帮你翻译以下内容:

我将回答自己的问题,因为我已经找到答案:

cd 到 gogs 目录

nano gogs.go

找到第一行,对我来说是

// +build go1.5

这意味着你至少需要 go 1.5 版本来进行构建。现在查看你的 go 版本:

go --version

如果这个版本号较小,那就是你的构建无法启动的原因。
在我的情况下,Ubuntu 使用的是一个较旧的版本,位于

whereis go

我删除了旧的二进制文件夹(这可能是你不应该做的事情),然后重新安装了 go,这给了我正确的版本,构建工作正常。

英文:

I'll go ahead and answer my own question since I figured it out:

cd to gogs directory

nano gogs.go

Look at the first line for me it was

// +build go1.5

This means you will at least need go 1.5 to build. Now look at your go version:

go --version

If this number is smaller, this is the reason your build won't even start.
In my case ubuntu was using an older version located at

whereis go

I deleted the old binary folder (probably something you shouldn't do) and reinstalled go from scratch, which gave me the corret version and the build worked fine.

huangapple
  • 本文由 发表于 2016年12月4日 17:11:17
  • 转载请务必保留本文链接:https://go.coder-hub.com/40957087.html
匿名

发表评论

匿名网友

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

确定