英文:
Go mod tidy find module but it's not getting to go.sum
问题
我有一个 Revel 项目,但每次运行 go mod tidy 时,它似乎能找到模块,但没有将找到的模块放入 go.sum 文件中。
这是我的 go env:
GOENV = C:\Users\mycomp\AppData\Roaming\go\env
GOMOD = C:\Program Files\Go\src\myproject\go.mod
GOPATH = C:\Users\micha\go
go version
go version go1.18.3 windows/amd64
revel version
Revel 执行:显示 Revel 框架和 Go 版本
Revel Framework:Unknown (1.1.0 remote master branch)
Revel Cmd:1.1.2 (1.1.2 remote master branch)
Revel Modules:Unknown (1.1.0 remote master branch)
go mod tidy
go: 找到 package github.com/PaesslerAG/jsonpath 的模块
go: 找到 package github.com/tdewolff/test 的模块
go: 找到 package github.com/PaesslerAG/gval 的模块
go: 在 github.com/tdewolff/test 中找到 v1.0.7 版本
go: 在 github.com/PaesslerAG/gval 中找到 v1.2.0 版本
go: 在 github.com/PaesslerAG/jsonpath 中找到 v0.1.1 版本
go mod init myproject
看起来工作正常,因为它创建了 go.mod
文件,但奇怪的是它只创建了这一行,通常它会创建很多我需要的模块:
module myproject
go 1.18
然后当我输入 go mod tidy
时,它创建了一个空的 go.sum
文件。我错过了什么?
英文:
i have a Revel project and i can't start it because everytime i run go mod tidy, it looks like finding module but it's not putting the found module in go.sum
here's my go env
GOENV = C:\Users\mycomp\AppData\Roaming\go\env
GOMOD = C:\Program Files\Go\src\myproject\go.mod
GOPATH = C:\Users\micha\go
go version
go version go1.18.3 windows/amd64
revel version
Revel executing: displays the Revel Framework and Go version
Revel Framework : Unknown (1.1.0 remote master branch)
Revel Cmd : 1.1.2 (1.1.2 remote master branch)
Revel Modules : Unknown (1.1.0 remote master branch)
go mod tidy
go: finding module for package github.com/PaesslerAG/jsonpath
go: finding module for package github.com/tdewolff/test
go: finding module for package github.com/PaesslerAG/gval
go: found github.com/tdewolff/test in github.com/tdewolff/test v1.0.7
go: found github.com/PaesslerAG/gval in github.com/PaesslerAG/gval v1.2.0
go: found github.com/PaesslerAG/jsonpath in github.com/PaesslerAG/jsonpath v0.1.1
go mod init myproject
seem working because it create go.mod
but it's just odd because it only creates this line, usually it creates a lot of modules i need
module myproject
go 1.18
then when i type go mod tidy
, it creates empty go.sum
. What do i miss ?
答案1
得分: -1
由于问题过于复杂无法在线重现,我开始调试并重新安装我的Go环境。在解决程序无法运行的错误期间,我尝试了几个可能有用的方法:
- 在Go 1.15或1.17之后,我的Go项目无法正常运行,所以我将它放在
C:\Program Files\Go\src\<project_name>
目录下。 - 我遇到的问题在于
GOPATH
(通常在C:\Users\<comp_name>\go
目录下)没有src
文件夹,这导致它可以找到已下载的模块,但无法将其放入我的项目的go.mod
文件中。
因此,最后我重新安装了所有的Go和Revel。以下是如何彻底删除所有相关的Go文件:
- 删除
C:\Program Files\Go\
目录下的Go
文件夹。 - 删除
C:\Users\<comp_name>\go
目录下的go
文件夹。 - 查看所有隐藏文件,并删除
C:\Users\<comp_name>\AppData\Local
目录下的go-build
文件夹。 - 查看所有隐藏文件,并删除
C:\Users\micha\AppData\Roaming
目录下的任何go
文件夹(如果有的话)。
英文:
Cause the problem is too complex to reproduce online, i started to debug and reinstall my Go from scractch, between solving a bug where my program can't run i tried several things that might be useful
- after Go 1.15 or 1.17 , my Go project can't run properly, so i put it in
C:\Program Files\Go\src\<project_name>
- The problem that i have is in
GOPATH
(usually inC:\Users\<comp_name>\go
) don't havesrc
folder, that makes it found downloaded module but can't seem to put it ingo.mod
inside my project
So in the end i reinstall all my Go and Revel. Here's how to delete all your associated Go to really really delete all your files
- Delete
Go
Folder inC:\Program Files\Go\
- Delete
go
folder inC:\Users\<comp_name>\go
- View all hidden files and delete folder
go-build
inC:\Users\<comp_name>\AppData\Local
- View all hidden files and delete folder
go
if any inC:\Users\micha\AppData\Roaming
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论