Go mod tidy发现了模块,但没有添加到go.sum文件中。

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

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环境。在解决程序无法运行的错误期间,我尝试了几个可能有用的方法:

  1. 在Go 1.15或1.17之后,我的Go项目无法正常运行,所以我将它放在C:\Program Files\Go\src\<project_name>目录下。
  2. 我遇到的问题在于GOPATH(通常在C:\Users\<comp_name>\go目录下)没有src文件夹,这导致它可以找到已下载的模块,但无法将其放入我的项目的go.mod文件中。

因此,最后我重新安装了所有的Go和Revel。以下是如何彻底删除所有相关的Go文件:

  1. 删除C:\Program Files\Go\目录下的Go文件夹。
  2. 删除C:\Users\<comp_name>\go目录下的go文件夹。
  3. 查看所有隐藏文件,并删除C:\Users\<comp_name>\AppData\Local目录下的go-build文件夹。
  4. 查看所有隐藏文件,并删除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

  1. after Go 1.15 or 1.17 , my Go project can't run properly, so i put it in C:\Program Files\Go\src\&lt;project_name&gt;
  2. The problem that i have is in GOPATH (usually in C:\Users\&lt;comp_name&gt;\go) don't have src folder, that makes it found downloaded module but can't seem to put it in go.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

  1. Delete Go Folder in C:\Program Files\Go\
  2. Delete go folder in C:\Users\&lt;comp_name&gt;\go
  3. View all hidden files and delete folder go-build in C:\Users\&lt;comp_name&gt;\AppData\Local
  4. View all hidden files and delete folder go if any in C:\Users\micha\AppData\Roaming

huangapple
  • 本文由 发表于 2022年9月2日 16:38:13
  • 转载请务必保留本文链接:https://go.coder-hub.com/73579904.html
匿名

发表评论

匿名网友

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

确定