-
Notifications
You must be signed in to change notification settings - Fork 17.9k
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 tidy has no effect on Windows #44458
Comments
please don't open multiple issues, we would've reopened the previous one keeping this one open, because it is necessary to run 17:25:20 ~/tmp3 0:00:00
» mkdir greetings && cd greetings
17:25:31 ~/tmp3/greetings 0:00:00
» go mod init example.com/greetings
go: creating new go.mod: module example.com/greetings
17:25:37 ~/tmp3/greetings 0:00:00
» cat << EOF > greetings.go
package greetings
import "fmt"
// Hello returns a greeting for the named person.
func Hello(name string) string {
// Return a greeting that embeds the name in a message.
message := fmt.Sprintf("Hi, %v. Welcome!", name)
return message
}
EOF
17:25:46 ~/tmp3/greetings 0:00:00
» cd ..
17:25:52 ~/tmp3 0:00:00
» mkdir hello && cd hello
17:25:58 ~/tmp3/hello 0:00:00
» cat << EOF > hello.go
package main
import (
"fmt"
"example.com/greetings"
)
func main() {
// Get a greeting message and print it.
message := greetings.Hello("Gladys")
fmt.Println(message)
}
EOF
17:26:04 ~/tmp3/hello 0:00:00
» go mod init hello
go: creating new go.mod: module hello
go: to add module requirements and sums:
go mod tidy
17:26:13 ~/tmp3/hello 0:00:00
» echo "replace example.com/greetings => ../greetings" >> go.mod
17:26:19 ~/tmp3/hello 0:00:00
» go mod tidy
go: found example.com/greetings in example.com/greetings v0.0.0-00010101000000-000000000000
17:26:24 ~/tmp3/hello 0:00:00
» go run .
Hi, Gladys. Welcome! |
This is "works on my machine" response type.
|
I'll repeat: "go mod tidy" doesn't have any effect for me. |
Actually I notice an effect - if I enter "require example.com/greetings v0.0.0-00010101000000-000000000000" manually to the go.mod and then run "go mod tidy" it deletes the line |
can you run |
|
@stevetraut @jayconrod @bcmills It looks to me, since go1.16, go build no longer edits go.mod file. In order to add the And, I noticed the tutorial asks users to manually edit go.mod file. Can we replace that part with FYI -
|
@ValleZ can we do this on slack, #modules channel on https://gopher.slack.com invite link |
Ah - @ValleZ I think Note "" around the replace statement in your log:
There shouldn't be |
I fixed it in external editor, see log. |
@ValleZ Is the log included in #44458 (comment) up-to-date? I still see the quoted replace statement.
|
Turns out it was caused by BOM: #35726 |
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Yes.
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
I followed steps from https://golang.google.cn/doc/tutorial/call-module-code
I created greetings folder with greetings.go file and run
go mod init example.com/greetings
what created go.mod with
then I created hello folder on the same level, hello.go
with
and go.mod with
then I run go build while in the hello folder and get error
hello.go:6:5: cannot find package
(I'm not sure how to run the code from hello folder in play.golang.org, but this mirrors the tutorial files)
https://play.golang.org/p/rtHtLMQHXUO
What did you expect to see?
The tutorial says I should see
go: found example.com/greetings in example.com/greetings v0.0.0-00010101000000-000000000000
What did you see instead?
hello.go:6:5: cannot find package
The previous issue was closed as duplicate of #44241 (comment)
but the problem is that modules do not work for me at all.
Running "go mod tidy" doesn't produce any effect or output, even replicating simple example from https://play.golang.org/p/rq4J90MxTKJ gives the same error on my local machine.
The text was updated successfully, but these errors were encountered: