go version)?$ go version go 1.12
yes
go env)?go env Output
$ go env
set GOARCH=amd64
set GOBIN=
set GOCACHE=C:UsersathreyaAppDataLocalgo-build
set GOEXE=.exe
set GOFLAGS=
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GOOS=windows
set GOPATH=C:Usersathreyago
set GOPROXY=
set GORACE=
set GOROOT=C:Go
set GOTMPDIR=
set GOTOOLDIR=C:Gopkgtoolwindows_amd64
set GCCGO=gccgo
set CC=gcc
set CXX=g++
set CGO_ENABLED=1
set GOMOD=C:tmpscratchpadhellogo.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:UsersathreyaAppDataLocalTempgo-build974406930=/tmp/go-build -gno-record-gcc-switches
Tried to setup go modules using the link https://github.com/golang/go/wiki/Modules
Tried the QuickStart guide to start using modules
Build successfully and run the program
`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
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
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.
@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.
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.
@leighmcculloch, go1.12 is several patches behind at this point. Can you still reproduce the problem with go1.12.4?
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.)
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
@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.
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.
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.
Most helpful comment
go buildis equivalent togo 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.