Skip to content

x/website: tutorial create a module, cannot find package "example.com/greetings" #42871

@reevelau

Description

@reevelau

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

$ go version
go version go1.15.5 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/test/Library/Caches/go-build"
GOENV="/Users/test/Library/Application Support/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOINSECURE=""
GOMODCACHE="/Users/test/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="darwin"
GOPATH="/Users/test/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/local/opt/go/libexec"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/opt/go/libexec/pkg/tool/darwin_amd64"
GCCGO="gccgo"
AR="ar"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD=""
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/tl/cxz4mjv55xl2rdcq1rb8jp280000gn/T/go-build149309703=/tmp/go-build -gno-record-gcc-switches -fno-common"

What did you do?

I am trying to follow the tutorial to create and reference it in hello.go. The source code of hello.go can be found in the next page, call-module-code.

But when I execute go run hello.go the process failed with error message. To workaround the issue, I need to delete example.com/ before greetings. I double checked the context of the tutorial, there isn't a hint of creating directory structure example.com/greetings but greetings. I don't know whether it was working in the older version of go.

May be creating the structure like this, before creating the go.mod, would smooth the experience of the tutorial

mkdir -p example.com/greetings
cd example.com/greetings

What did you expect to see?

Hi, Gladys. Welcome!

What did you see instead?

hello.go:6:2: cannot find package "example.com/greetings" in any of:
	/usr/local/opt/go/libexec/src/example.com/greetings (from $GOROOT)
	/Users/test/go/src/example.com/greetings (from $GOPATH)

Metadata

Metadata

Assignees

No one assigned

    Labels

    FrozenDueToAgeWaitingForInfoIssue is not actionable because of missing required information, which needs to be provided.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions