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

Open
athreya92 opened this Issue Apr 12, 2019 · 4 comments

Comments

Projects
None yet
4 participants
@athreya92
Copy link

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 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 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 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 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.