Unrecognized import path while fetching go package gin - go

Unrecognized import path while fetching go package gin. How do I resolve this issue
go get github.com/gin-gonic/gin
package gopkg.in/go-playground/validator.v8: unrecognized import path "gopkg.in/go-playground/validator.v8" (https fetch: Get https://gopkg.in/go-playground/validator.v8?go-get=1: dial tcp: i/o timeout)
package gopkg.in/yaml.v2: unrecognized import path "gopkg.in/yaml.v2" (https fetch: Get https://gopkg.in/yaml.v2?go-get=1: dial tcp: i/o timeout)

According to issue #51 - which has a similar error - indicates that this is a problem with your network. Try again later or use some proxy, as suggested on the GitHub page, such as:
Goproxy
Lantern
Also, make sure you can go get other packages. It might be a package only problem or a 'global' one. In this case try the proxies above

I just tried the command, and it works find.
Is your GOPATH correctly set? see the documentation for more info.

Related

go get returns unrecognized import path

I have a go program which imports a custom module hosted internally
import (
"fmt"
"log"
...
"gitlab.org.myteam.com/teamrepo/project1"
)
When I do go build I get following errors:
main.go:15:2: no required module provides package gitlab.org.myteam.com/teamrepo/project1; to add it:
go get gitlab.org.myteam.com/teamrepo/project1
As directed when I do go get I get following errors:
go: downloading gitlab.org.myteam.com/teamrepo/project1 v1.0.1
go: gitlab.org.myteam.com/teamrepo/project1#v1.0.1: verifying module: gitlab.org.myteam.com/teamrepo/project1#v1.0.1: reading https://sum.golang.org/lookup/gitlab.org.myteam.com/teamrepo/project1#v1.0.1: 404 Not Found
server response: not found: gitlab.org.myteam.com/teamrepo/project1#v1.0.1: unrecognized import path "gitlab.org.myteam.com/teamrepo/project1": https fetch: Get "https://gitlab.org.myteam.com/teamrepo/project1?go-get=1": dial tcp 10.xx.xx.xxx:443: connect: connection refused

I am not sure what I am doing wrong here. git clone on this repository works fine, so it is accessible.
Further, two things that I find confusing in the errors are:

Why go is trying to read the path reading https://sum.golang.org/lookup/gitlab.org.myteam.com/teamrepo/project1#v1.0.1: 404 Not Found

And, how it decided to fetch version v1.0.1 as I haven’t explicitly specified this version anywhere.
go version go1.19.4 darwin/amd64

Problem when installing the cover package for golang

I have some code.
But when
I try run cover test and have response:
'go get -u github.com/gregoryv/uncover/...
go test -coverprofile /tmp/c.out
uncover /tmp/c.out'
I try install cover package:
go get code.google.com/p/go.tools/cmd/cover
but get error
package code.google.com/p/go.tools/cmd/cover: unrecognized import path "code.google.com/p/go.tools/cmd/cover" (parse https://code.google.com/p/go.tools/cmd/cover?go-get=1: no go-import meta tags (meta tag github.com/golang/go did not match import path code.google.com/p/go.tools/cmd/cover))
System: Ubuntu 18.04
The correct path is:
go get golang.org/x/tools/cmd/cover

Vendoring problem from Opencensus Libraries for Golang

I'm having problem while vendoring my go-project. Tried with both glide and go-dep - getting same problem.
$ go get -u go.opencensus.io gives the following error:
package go.opencensus.io/opencensus-go: unrecognized import path "go.opencensus.io/opencensus-go" (https fetch: Get https://go.opencensus.io/opencensus-go?go-get=1: dial tcp <some-ip>: i/o timeout)
Github link of this package - https://github.com/census-instrumentation/opencensus-go
Tried setting a proxy to shell
export http_proxy=http://104.248.231.49:8080/
export https_proxy=http://104.248.231.49:8080/
And then it worked.

"go get google.golang.org/grpc" failing: unrecognized import path

So I am trying to install my Go app's dependencies on my Raspberry 3/Raspbian system with "go get" and running into the following when trying to install gRPC for Go:
[pi#raspberrypi-1 camera-service] 17:32:28 % go get google.golang.org/grpc
package google.golang.org/grpc: unrecognized import path "google.golang.org/grpc" (https fetch: Get https://google.golang.org/grpc?go-get=1: dial tcp: lookup google.golang.org on 192.168.1.1:53: read udp 192.168.1.64:33524->192.168.1.1:53: i/o timeout)
Meanwhile I am able to install other (non-google.golang.org) dependencies (for example go get github.com/asaskevich/EventBus) just fine.
To me this looks a DNS problem -- 192.168.1.1 is my router, 192.168.1.64 is my RPi. However I can resolve the address just fine:
[pi#raspberrypi-1 camera-service] 17:32:52 % host google.golang.org
google.golang.org is an alias for golang.org.
golang.org has address 216.58.209.145
golang.org has IPv6 address 2a00:1450:400f:804::2011
golang.org mail is handled by 1 aspmx.l.google.com.
golang.org mail is handled by 2 alt2.aspmx.l.google.com.
golang.org mail is handled by 2 alt1.aspmx.l.google.com.
golang.org mail is handled by 2 alt3.aspmx.l.google.com.
This is weird. Also I have installed the same packages on another system np.
My environment is
- Go 1.8.3, installed from prebuilt ARM6 binary
- export GOROOT="/usr/local/go"
- export GOPATH="/home/pi/go"
This may be because you are using the built in DNS resolver in Go, rather than delegating to the system name resolver. When you built gRPC, did you set CGO_ENABLED=1 ? You can check by setting GODEBUG=netdns=cgo when getting gRPC:
$ GODEBUG=netdns=cgo go get google.golang.org/grpc

Why doesn't "go get gopkg.in/..." work while "go get github.com/..." OK?

I try to use go get gopkg.in/fatih/pool.v2 to install pool according to Readme.md, but can't success:
C:\Users\xiaona\Documents\GitHub> go get -v gopkg.in/fatih/pool.v2
Fetching https://gopkg.in/fatih/pool.v2?go-get=1
https fetch failed.
Fetching http://gopkg.in/fatih/pool.v2?go-get=1
import "gopkg.in/fatih/pool.v2": http/https fetch: Get http://gopkg.in/fatih/poo
l.v2?go-get=1: dial tcp 107.178.216.236:80: ConnectEx tcp: A connection attempt
failed because the connected party did not properly respond after a period of ti
me, or established connection failed because connected host has failed to respon
d.
package gopkg.in/fatih/pool.v2: unrecognized import path "gopkg.in/fatih/pool.v2
"
While access 107.178.216.236:80 is OK in web browser.
I try to use go get github.com/fatih/pool, and it also works OK.
Could anyone give some clues on this issue?
BTW: I use windows powershell and git version is 1.9.5.
The root cause has been found: Because my computer use a web proxy, so I need to set proxy in environment variable:
C:\Users\xiaona>set https_proxy=https://web-proxy.corp.hp.com:8080/
C:\Users\xiaona>set http_proxy=https://web-proxy.corp.hp.com:8080/
C:\Users\xiaona>go get -v gopkg.in/fatih/pool.v2
Fetching https://gopkg.in/fatih/pool.v2?go-get=1
Parsing meta tags from https://gopkg.in/fatih/pool.v2?go-get=1 (status code 200)
get "gopkg.in/fatih/pool.v2": found meta tag main.metaImport{Prefix:"gopkg.in/fa
tih/pool.v2", VCS:"git", RepoRoot:"https://gopkg.in/fatih/pool.v2"} at https://g
opkg.in/fatih/pool.v2?go-get=1
gopkg.in/fatih/pool.v2 (download)
gopkg.in/fatih/pool.v2
Then, all is OK!

Resources