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

doc/tutorial/call-module-code: recap the directory structure from the previous step? #41573

Closed
bcetienne opened this issue Sep 23, 2020 · 11 comments
Labels
Documentation FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone

Comments

@bcetienne
Copy link

bcetienne commented Sep 23, 2020

What version of Go are you using (go version)?

$ go version go1.15.2 darwin/amd64

Does this issue reproduce with the latest release?

Yes

What operating system and processor architecture are you using (go env)?

go env Output
$ go env
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/etienne/Library/Caches/go-build"
GOENV="/Users/etienne/Library/Application Support/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOINSECURE=""
GOMODCACHE="/Users/etienne/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="darwin"
GOPATH="/Users/etienne/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/local/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/darwin_amd64"
GCCGO="gccgo"
AR="ar"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD="/Users/etienne/Desktop/greetings/hello/go.mod"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/sb/6q_vnpy53xn95mr4kj7h9lvc0000gq/T/go-build921607341=/tmp/go-build -gno-record-gcc-switches -fno-common"

What did you do?

I followed the guidelines for learning Go on the official website.
I first did this part which is not a problem (https://golang.org/doc/tutorial/create-module) but in the second part (https://golang.org/doc/tutorial/call-module-code), the build command from the hello directory doesn't work.

I tried again just copying and pasting the provided code but nothing changes.

Here is my go.mod file in the hello directory.

module hello

go 1.15

replace example.com/greetings => ../greetings

Here is my structure

image

What did you expect to see?

$ go build
go: found example.com/greetings in example.com/greetings v0.0.0-00010101000000-000000000000


What did you see instead?

$ go build
hello.go:6:2: example.com/greetings@v0.0.0-00010101000000-000000000000: replacement directory ../greetings does not exist

@seankhliao
Copy link
Member

going up from hello ../ you're in the greetings directory, then you try to go down a level into a directory that does not exist greetings

see https://github.com/golang/go/wiki/Questions for the appropriate places to ask questions

@bcmills bcmills changed the title Go (v.1.15.2) build - Replacement directory does not exist doc/tutorial/call-module-code: recap the directory structure from the previous step? Sep 23, 2020
@bcmills bcmills added Documentation NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. labels Sep 23, 2020
@bcmills
Copy link
Contributor

bcmills commented Sep 23, 2020

The go command is working as designed here, but that tutorial is fairly new — perhaps it could be adjusted to make this sort of mistake less likely.

(CC @stevetraut)

@bcmills bcmills added this to the Unreleased milestone Sep 23, 2020
@stevetraut stevetraut self-assigned this Sep 23, 2020
@stevetraut
Copy link

Thanks, folks. I'll take a look.

@stevetraut
Copy link

Hm. Step one in https://golang.org/doc/tutorial/call-module-code has the following, which is intended to cd up from where you were in the preceding topic (greetings) and create a hello directory at the same level as greetings. Maybe that first step needs to reestablish context from the preceding topic.

cd ..
mkdir hello
cd hello

@bcetienne
Copy link
Author

Hi everyone, thank you for taking the time to read my concern.
For more precision, I really followed the tutorial step by step and I executed the build command from the greetings/hello directory (the return I put in my original message), seeing that it didn't work I also tried (out of curiosity) from the root folder but as I imagined it didn't work any more.

I don't know if this helps you any more...

@SaltyCoco
Copy link

This is an old issue however I had the same issue so here is what I found to be the answer.

You need to make a parent directory for both greetings and hello, like so;

image

I made a GreetingsProject folder and then had a hello folder and a greetings folder. The "require" from the mod file in the file was auto generated by the command. If you look at the replace you can see they are going up one directory to find a folder named greetings.

@stevetraut
Copy link

stevetraut commented Feb 16, 2021

So this statement from https://golang.org/doc/tutorial/call-module-code doesn't make it clear that you might be in the greetings folder?

"For example, if your current directory in the command prompt is the greetings directory, you could use the following commands:"

Could you suggest wording that might make it clear?

@hjctop1
Copy link

hjctop1 commented Feb 18, 2021

@stevetraut
hi, for go 1.16, i tried "https://golang.google.cn/doc/tutorial/call-module-code", got same error
under hello dir, use "go mod tidy", then "go build"
this works for me, hope it works for you

@stevetraut
Copy link

@hjctop1 @bcetienne See if the changes in this CL address your issues. They're due to be published before too long.

https://go-review.googlesource.com/c/website/+/297531/7/_content/doc/tutorial/call-module-code.html

@Nyamador
Copy link

Nyamador commented Mar 5, 2021

I'm using go 1.16 on linux . Running go get example.com/greetings with the replace directive (example.com/greetings => ../greetings) added in my go.mod file automatically added the require directive ( require example.com/greetings v0.0.0-00010101000000-000000000000 ). I hope this helps 😄

@stevetraut
Copy link

Fixed with a diagram here: https://golang.org/doc/tutorial/call-module-code

@golang golang locked and limited conversation to collaborators Mar 9, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Documentation FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Projects
None yet
Development

No branches or pull requests

8 participants