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

cmd/go: Problem using go modules #31435

Closed
athreya92 opened this issue Apr 12, 2019 · 10 comments
Closed

cmd/go: Problem using go modules #31435

athreya92 opened this issue Apr 12, 2019 · 10 comments

Comments

@athreya92
Copy link

@athreya92 athreya92 commented Apr 12, 2019

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

$ go version
go 1.12

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
set GOARCH=amd64
set GOBIN=
set GOCACHE=C:\Users\athreya\AppData\Local\go-build
set GOEXE=.exe
set GOFLAGS=
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GOOS=windows
set GOPATH=C:\Users\athreya\go
set GOPROXY=
set GORACE=
set GOROOT=C:\Go
set GOTMPDIR=
set GOTOOLDIR=C:\Go\pkg\tool\windows_amd64
set GCCGO=gccgo
set CC=gcc
set CXX=g++
set CGO_ENABLED=1
set GOMOD=C:\tmp\scratchpad\hello\go.mod
set CGO_CFLAGS=-g -O2
set CGO_CPPFLAGS=
set CGO_CXXFLAGS=-g -O2
set CGO_FFLAGS=-g -O2
set CGO_LDFLAGS=-g -O2
set PKG_CONFIG=pkg-config
set GOGCCFLAGS=-m64 -mthreads -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=C:\Users\athreya\AppData\Local\Temp\go-build974406930=/tmp/go-build -gno-record-gcc-switches

What did you do?

Tried to setup go modules using the link https://github.com/golang/go/wiki/Modules
Tried the QuickStart guide to start using modules

What did you expect to see?

Build successfully and run the program

What did you see instead?

`go build

can't load package: package github.com/you/hello: unknown import path "github.com/you/hello": cannot find module providing package github.com/you/hello`

Please help

@rvolykh

This comment has been minimized.

Copy link

@rvolykh rvolykh commented Apr 12, 2019

Hello, did you execute go mod init github.com/you/hello?

Can you please show content of go.mod file?

And if your project is under GOPATH, please try GO111MODULE=on go build

@athreya92

This comment has been minimized.

Copy link
Author

@athreya92 athreya92 commented Apr 12, 2019

I tried it outside the GOPATH.
Well now I change the go version to v1.11.9 and go modules are working fine. I'm not sure what caused the error in v1.12.3.

@bcmills

This comment has been minimized.

Copy link
Member

@bcmills bcmills commented Apr 12, 2019

@athreya92, there is not enough information here to diagnose the problem. For example, we don't know what is importing github.com/you/hello or why we should expect that import to succeed.

Please provide a self-contained code example with a specific sequence of commands that we can run to reproduce the problem with 1.12.3.

@bcmills bcmills changed the title Problem using go modules cmd/go: Problem using go modules Apr 12, 2019
@leighmcculloch

This comment has been minimized.

Copy link
Contributor

@leighmcculloch leighmcculloch commented Apr 17, 2019

I am experiencing the same issue, but it is intermittent.

$ go version
go version go1.12 linux/amd64
$ git clone https://github.com/braintree-go/braintree-go
...
$ go build
braintree.go:4:2: unknown import path "bytes": cannot find module providing package bytes
response.go:4:2: unknown import path "compress/gzip": cannot find module providing package compress/gzip
add_on_gateway.go:3:8: unknown import path "context": cannot find module providing package context
hmac.go:4:2: unknown import path "crypto/hmac": cannot find module providing package crypto/hmac
hmac.go:5:2: unknown import path "crypto/sha1": cannot find module providing package crypto/sha1
braintree.go:6:2: unknown import path "crypto/tls": cannot find module providing package crypto/tls
credentials_api_key.go:3:8: unknown import path "encoding/base64": cannot find module providing package encoding/base64
account_updater_daily_report.go:3:8: unknown import path "encoding/xml": cannot find module providing package encoding/xml
braintree.go:8:2: unknown import path "errors": cannot find module providing package errors
braintree.go:9:2: unknown import path "fmt": cannot find module providing package fmt
customfields/custom_fields.go:5:2: unknown import path "io": cannot find module providing package io
response.go:7:2: unknown import path "io/ioutil": cannot find module providing package io/ioutil
braintree.go:10:2: unknown import path "log": cannot find module providing package log
braintree.go:11:2: unknown import path "net": cannot find module providing package net
braintree.go:12:2: unknown import path "net/http": cannot find module providing package net/http
credit_card_gateway.go:7:2: unknown import path "net/url": cannot find module providing package net/url
decimal.go:5:2: unknown import path "strconv": cannot find module providing package strconv
customfields/custom_fields.go:6:2: unknown import path "strings": cannot find module providing package strings
webhook_testing_gateway.go:13:2: unknown import path "text/template": cannot find module providing package text/template
date/date.go:5:2: unknown import path "time": cannot find module providing package time
errors.go:8:2: unknown import path "unicode": cannot find module providing package unicode
$ cat go.mod
module github.com/braintree-go/braintree-go

go 1.12

I retried go build several times, and it worked on the third attempt.

@bcmills

This comment has been minimized.

Copy link
Member

@bcmills bcmills commented May 6, 2019

@leighmcculloch, go1.12 is several patches behind at this point. Can you still reproduce the problem with go1.12.4?

@gopherbot

This comment has been minimized.

Copy link

@gopherbot gopherbot commented Jun 6, 2019

Timed out in state WaitingForInfo. Closing.

(I am just a bot, though. Please speak up if this is a mistake or you have the requested information.)

@gopherbot gopherbot closed this Jun 6, 2019
@arhyth

This comment has been minimized.

Copy link

@arhyth arhyth commented Sep 19, 2019

having this problem also.
@ go version go1.12.6 linux/amd64

can't load package: package bitbucket.org/xXXx/scheduled-tasks: unknown import path "bitbucket.org/xXXx/scheduled-tasks": cannot find module providing package bitbucket.org/xXXx/scheduled-tasks

there are nil, nada, zero imports of bitbucket.org/xXXx/scheduled-tasks anywhere

and this is in go.mod, so that's covered

module bitbucket.org/xXXx/scheduled-tasks

go 1.12

aside from the main package which is inside /cmd dir, all the packages are inside /pkg dir under the module dir

@bcmills

This comment has been minimized.

Copy link
Member

@bcmills bcmills commented Sep 19, 2019

@arhyth, the diagnostics for missing imports have been improved substantially in Go 1.13. Please try your build with 1.13, and if it still seems incorrect please open a new issue with steps to reproduce.

@arhyth

This comment has been minimized.

Copy link

@arhyth arhyth commented Sep 19, 2019

upgraded to 1.13.
i run

> go build

now i only have this error

build .: cannot find module for path .

i'm not sure whether to open an issue or there's some small thing that i am just missing, as i'm fairly new to Go.

@bcmills

This comment has been minimized.

Copy link
Member

@bcmills bcmills commented Sep 19, 2019

go build is equivalent to go build ., which will fail if there are no Go source files (or no non-test source files) in the current directory.

If you want to build all of the packages within the module, use go build ./... instead.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
6 participants
You can’t perform that action at this time.