profile
viewpoint

Ask questionscmd/go: Problem using go modules

<!-- Please answer these questions before submitting your issue. Thanks! -->

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

<pre> $ go version go 1.12 </pre>

Does this issue reproduce with the latest release?

yes

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

<details><summary><code>go env</code> Output</summary><br><pre> $ 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 </pre></details>

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 <!-- If possible, provide a recipe for reproducing the error. A complete runnable program is good. A link on play.golang.org is best. -->

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

golang/go

Answer questions leighmcculloch

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.

useful!

Related questions

cmd/link: segmentation fault during mach-o linking hot 3
x/xerrors: fails to compile on tip hot 1
vendor/golang.org/x/xerrors/adaptor_go1_13.go:16:14: undefined: errors.Frame ... hot 1
cmd/go: `go clean <package>` downloads modules hot 1
cmd/cgo error: runtime: unknown pc 0x7fff5c805b86 hot 1
runtime: crash with "invalid pc-encoded table" hot 1
cmd/vet: potential false positive in the "suspect or" check hot 1
cmd/link: showing many ld warnings of "building for macOS, but linking in object file" hot 1
cmd/go: major version without preceding tag must be v0, not v1 - breaks build of github.com/go-check hot 1
runtime: macOS Sierra builders spinning hot 1
cmd/go: "unrecognized import path" for local packages after updating to go1.13 hot 1
cmd/go: "found, but does not contain package" error refers to replaced version instead of its replacement hot 1
cmd/go: 'go get repo@<commit>' succeeds when <commit> is the full hash of an unpublished commit hot 1
x/tools/gopls: format feature doesn't follow `goimports` hot 1
cmd/go: 'inconsistent vendoring' error when a user module is located within GOROOT/src hot 1
Github User Rank List