-
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
doc/install: update “Test your installation” step to be agnostic to module mode #37042
Comments
This is happening because you have the environment variable @bcmills @jayconrod We need a better error message here, or different behavior. |
@ianlancetaylor, do you have a specific suggestion? |
The issue as originally reported seems like a documentation problem: How to Write Go Code has been updated to include the necessary Probably we should suggest testing the installation using |
Heh, the “workspace” link in that section is broken too. (It uses a |
I did not notice I know that the default value is Previously, when I installed another version of Go, I set Is it possible that the values from the previous installation are cached? |
@bcmills Think about what this is like for someone who knows nothing. Maybe people have to learn the basics of modules, but they can only do that if we help them. For a beginner to Go, "cannot find main module" means nothing. Better might be something like cannot determine module because no go.mod file found; see "go help modules" and, at least until module mode is the default, (running in module mode because environment variable GO111MODULE=on) And then "go help modules" (if that is indeed the right link) could use some cleanup as it is written from the perspective of someone who understands GOPATH. |
@tkl4230 Yes, if you used You can also set the environment variable for just one session using your shell, typically
|
@ianlancetaylor |
Change https://golang.org/cl/217840 mentions this issue: |
Change https://golang.org/cl/217877 mentions this issue: |
…ke it module-agnostic In CL 199417, we updated “How to Write Go Code” to give a basic introduction to modules and to include module-mode commands. However, most new users will end up reading “Getting Started” (doc/install.html) before “How to Write Go Code”, and we forgot to update the handful of commands there for module mode. Before this change, the “Test your installation” section also covered quite a few operations beoyond merely testing the installation: it included setting up a GOPATH, building a binary, and installing and cleaning binaries. Those are valuable operations to learn, but they arguably belong in “How to Write Go Code”, not “Test your installation” — and having all that extra detail in the install instructions may well discourage folks from further essential reading. Rather than updating all of those operations here, I've removed them. A companion CL will update “How to Write Go Code” to ensure that it mentions GOPATH (as the location of the module cache and the default install location for binaries) and 'go clean -i'. Updates #37042 Change-Id: I157f21ccbe3896575fa1115dc821abf6c71ed15e Reviewed-on: https://go-review.googlesource.com/c/go/+/217840 Run-TryBot: Bryan C. Mills <bcmills@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org> Reviewed-by: Tyler Bui-Palsulich <tbp@google.com>
I think that even Similarly, We certainly do need to clean up |
Can we at least have the error message point people to "go help modules" (if that is the best place)? I don't really agree that "no go.mod file" is nearly as mysterious; at least it tells you exactly what is missing, and gives you a starting point for progress. |
The error text already ends with: |
Oh, right, sorry. |
Plus some additional minor cleanup: - Set PATH using a command that does not depend on GOBIN or GOPATH being set. - Remove unusual whitespace from example output. - Add Go 1.14 'go install' output to help clarify what happens when we need to download a module. Updates golang/go#37042 Change-Id: I1bfb4ba38ccefa2b95be309dd465e3523895c1b6 Reviewed-on: https://go-review.googlesource.com/c/website/+/217877 Run-TryBot: Bryan C. Mills <bcmills@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Jay Conrod <jayconrod@google.com>
Change https://golang.org/cl/218217 mentions this issue: |
I forgot to escape them in CL 217877, and the TryBots don't currently catch template errors in HTML docs. Updates golang/go#37042 Updates golang/go#37072 Change-Id: Ia7b82a9c9b85914f224c04050bfbe3747d5a3acc Reviewed-on: https://go-review.googlesource.com/c/website/+/218217 Run-TryBot: Bryan C. Mills <bcmills@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
This should now be fixed in http://tip.golang.org/doc/install: the “Test your installation” instructions are now module-agnostic (and more concise), and the descriptions of |
What version of Go are you using (
go version
)?What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
I tried to create a go environment and proceeded according to the tutorial.
https://golang.org/doc/install?download=go1.13.7.darwin-amd64.pkg
Do you need
go mod init
beforego build
??or execute
go build hello.go
.The text was updated successfully, but these errors were encountered: