Skip to content
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

x/pkgsite: Tutorial should tell you to start in $GOPATH #60035

Closed
GitMazzone opened this issue May 7, 2023 · 4 comments
Closed

x/pkgsite: Tutorial should tell you to start in $GOPATH #60035

GitMazzone opened this issue May 7, 2023 · 4 comments
Labels
FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. pkgsite
Milestone

Comments

@GitMazzone
Copy link

What is the URL of the page with the issue?

https://go.dev/doc/tutorial/create-module

Description

I'm brand new to Go and am following along with the tutorial.
The tutorial doesn't make any mention by this point (creating a module) of $GOPATH or $GOROOT, which I've learned is where these examples really need to live so that each module can resolve without needing to symlink to somewhere else on my system.
Without this information, and having created the tutorial code exactly as instructed, it leads to errors not being able to find modules where it looks by default, $GOPATH and $GOROOT.

This is the current tutorial instruction for where to create code:

It should tell us to create a user/go/src/example/hello dir, no? This way in the next steps we're able to create a src/greetings dir.

Have I overlooked something, or is this information that should be included in the documentation?
Seems fixable with a brief addition about where to create the tutorial work (and all future work, according to the opinions of some, though I'm not sure on common practices here). In the $GOPATH.

I'm happy to open a PR adding that to the docs if I am understanding this correctly.

@gopherbot gopherbot added this to the Unreleased milestone May 7, 2023
@dmitshur
Copy link
Contributor

dmitshur commented May 7, 2023

Thanks for the report.

Creating user/go/src/example/hello is a historic requirement that doesn't need to apply today, and the steps in the tutorial should work. If you're running into an error, there must be something going wrong.

What was the command you ran that failed and its full output?
What is the output of running go env in your terminal?

@dmitshur dmitshur added WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided. NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. labels May 7, 2023
@GitMazzone
Copy link
Author

GitMazzone commented May 8, 2023

@dmitshur The issue comes after creating two modules: /greetings and /hello.
I just realized it's because the containing folder needs to be the same name as the module prefix, even though the tutorial does this replace mapping of myPrefix/moduleName => ../greetings so I don't really understand why that would give an error.

The error was in my hello.go file where I import mm/greetings, which should be replaced with a local path, right?
image
Because I had both modules in a folder named golang-learning but I created the modules as mm/greetings and mm/hello.

Also worth noting that cmd+clicking that imported mm/greetings module tries opening a browser link instead of finding the replaced path, so something still seems incorrect here.

@GitMazzone
Copy link
Author

@dmitshur My go env output:

projects/golang/hello λ go env
GO111MODULE=""
GOARCH="arm64"
GOBIN=""
GOCACHE="/Users/michael/Library/Caches/go-build"
GOENV="/Users/michael/Library/Application Support/go/env"
GOEXE=""
GOEXPERIMENT=""
GOFLAGS=""
GOHOSTARCH="arm64"
GOHOSTOS="darwin"
GOINSECURE=""
GOMODCACHE="/Users/michael/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="darwin"
GOPATH="/Users/michael/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/local/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/darwin_arm64"
GOVCS=""
GOVERSION="go1.20.4"
GCCGO="gccgo"
AR="ar"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD="/Users/michael/Documents/projects/golang/mm/hello/go.mod"
GOWORK=""
CGO_CFLAGS="-O2 -g"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-O2 -g"
CGO_FFLAGS="-O2 -g"
CGO_LDFLAGS="-O2 -g"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -arch arm64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/kq/_xc6snws649dhg07dw17rtd80000gn/T/go-build3446977629=/tmp/go-build -gno-record-gcc-switches -fno-common"

@dmitshur dmitshur removed the WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided. label May 8, 2023
@seankhliao
Copy link
Member

The poor error message is because a dotless prefix considered reserved for the standard library, if you followed the tutorial and used example.com, you would have gotten a better message. #32819

Without seeing a full directory tree and the contents of your files, it's hard to say what's wrong, but I don't think this a problem of the tutorial.

Unlike many projects, the Go project does not use GitHub Issues for general discussion or asking questions. GitHub Issues are used for tracking bugs and proposals only.

For questions please refer to https://github.com/golang/go/wiki/Questions

@seankhliao seankhliao closed this as not planned Won't fix, can't repro, duplicate, stale May 8, 2023
@golang golang locked and limited conversation to collaborators May 7, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. pkgsite
Projects
None yet
Development

No branches or pull requests

4 participants