New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
cmd/go: -mod=mod no longer writes go.sum in 1.18 #51818
Comments
I can't reproduce this, and the output you've given doesn't look like it corresponds to |
Hey @seankhliao thanks for the prompt response! Based on your response, I dug deeper. Here's how to repro it.
main.go package main
import (
"fmt"
"app.com/web"
"github.com/hexops/valast"
)
func main() {
actual := web.Load()
fmt.Println(valast.String(actual))
} go.mod
web/web.go package web
func Load() *Web {
return &Web{}
}
type Web struct{} Then run
Okay, so I think I know what's happening. By changing the go.mod to use replace
And running
You can find where this error occurs in Not sure why, but I was able to fix this by adding an explicit go version to go.mod module app.com
+ go 1.18
require (
github.com/hexops/valast v1.4.1
) So the good news is that it seems like this continues to work as expected, but perhaps something changed or needs to be updated in Thanks again for the quick response! |
This was an intentional change as part of CL 339170. |
Just curious, does |
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Yep
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
I've been relying on
go run -mod=mod main.go
in test scripts to download any missing dependencies and create a go.sum file.For the following
go.mod
After upgrading and running
go run -mod=mod main.go
, I get the following:I read in the release notes that go.sum is no longer written automatically for certain
go mod <command>
, but I assumed it would have mentioned something about the-mod=mod
behavior changing.Interestingly, you get a less wrapped error when you just run
go run main.go
:I also downgraded to 1.17 to confirm that this change was introduced in 1.18.
What did you expect to see?
I expected
go run -mod=mod main.go
to continue to download any missing dependencies and create a go.sum since you're explicitly opting into updating go.mod:I also think that behavior would align with what the Module Reference says:
Otherwise, I'm not really sure what the use case of
-mod=mod
is anymore if it only does half of the job :)What did you see instead?
The text was updated successfully, but these errors were encountered: