go get command stuck on Mac - go

I'm trying to install some libraries in golang. But it always stuck when I run go get [package]. The error varies. One of them is like this:
➜ alif git:(master) ✗ go get "github.com/go-playground/validator/v10"
go: downloading github.com/go-playground/validator/v10 v10.11.2
go: downloading github.com/go-playground/validator v9.31.0+incompatible
go: github.com/go-playground/validator/v10#v10.11.2: read "https:/proxy.golang.org/#v/v10.11.2.zip": read tcp 192.164.0.2:58505->34.101.4.81:443: read: connection reset by peer
Sometimes it is a connection refused or timeout.
➜ alif git:(master) ✗ go get "github.com/go-playground/validator/v10"
go: downloading github.com/go-playground/validator/v10 v10.11.2
go: downloading github.com/go-playground/validator v9.31.0+incompatible
go: golang.org/x/crypto#v0.5.0: verifying go.mod: golang.org/x/crypto#v0.5.0/go.mod: Get "https://sum.golang.org/lookup/golang.org/x/crypto#v0.5.0": net/http: TLS handshake timeout
My internet work just fine. And in fact previously like 2 days ago, I have no problem downloading go dependencies.
My go version is go1.19, I tried to upgrade it to go1.20 but the problem still occurs. And I'm using macOS M1. What can I do?

Related

VSCode: gopls: failed to install [read "https:/proxy.golang.org/#v/v0.1.0.zip": stream error: stream ID 9; NO_ERROR; received from peer]

While opening my Go project in VSCode or using the Go: install/update tools command I am getting the following error:
1 tools failed to install.
gopls: failed to install gopls(golang.org/x/tools/gopls#latest): Error: Command failed: /usr/local/bin/go install -v golang.org/x/tools/gopls#latest
go: downloading golang.org/x/sys v0.1.0
../../pkg/mod/golang.org/x/tools#v0.2.1-0.20221101170700-b5bc717366b2/go/packages/external.go:15:2: golang.org/x/sys#v0.1.0: read "https:/proxy.golang.org/#v/v0.1.0.zip": stream error: stream ID 9; NO_ERROR; received from peer
GOPATH is set properly (other tools were installed successfully).
Versions:
VSCode: 1.73.1
Golang: 1.19.3.
Found a workaround:
I simply updated the GOPROXY environment variable:
export GOPROXY="direct"
It started working after that.
Maybe some network issue within my company proxy was causing this in the first place.

i am unable to install subzy tool in my linux it shows error

I tried to install this subzy tool from GitHub but it shows this kind of error and I can't install it I have faced the same problem with other programs written in (GO language).
I can clone the programs written in python but I am unable to clone the programs written in go language once I clone I don't know how to install them
****➜ ~ go install -v github.com/lukasikic/subzy#latest
go: finding a module f**or package github.com/mitchellh/go-homedir
go: finding module for package github.com/logrusorgru/aurora
go: found github.com/logrusorgru/aurora in github.com/logrusorgru/aurora v2.0.3+incompatible
go: found github.com/mitchellh/go-homedir in github.com/mitchellh/go-homedir v1.1.0
➜ ~ go get -u -v github.com/lukasikic/subzy
go get: installing executables with 'go get' in module mode is deprecated.
Use 'go install pkg#version' instead.
For more information, see https://golang.org/doc/go-get-install-deprecation
or run 'go help get' or 'go help install'.
➜ ~**
Welcome to the community,
Check the closed repo, whether it has go.mod and go.sum files
Check the version of the go (go mod is enforced in recent version meaning)
Check and learn about go mod and how to use (https://go.dev/blog/using-go-modules)

go verify module failed (how does go sumsdb work?)

I encountered this error on go build:
go: github.com/frankban/quicktest#v1.14.2: verifying module: github.com/frankban/quicktest#v1.14.2: Get "https://sum.golang.org/lookup/github.com/frankban/quicktest#v1.14.2": Not Found
My question is, why the frankban/quicktest is not found in sum db? as a matter of fact this is not the only package that caused this error, last time I try to compile the same project (about an hour ago), the error was on golang.org/x/xerrors.
Further more, could anyone explain (or point out some documents/articles/blogs) on how the go module system's "sums db" work. It is very frustrating if anyone encounter such error as there seems nothing you can do to fix it?
Full log:
$ go get -u
go: downloading github.com/tealeg/xlsx v1.0.5
go: downloading github.com/shabbyrobe/xmlwriter v0.0.0-20220218224045-defe0ad214f6
go: downloading github.com/frankban/quicktest v1.14.2
go: downloading golang.org/x/text v0.3.3
go: downloading github.com/google/btree v1.0.1
go: downloading github.com/kr/pretty v0.3.0
go: downloading golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543
go: downloading github.com/kr/text v0.2.0
go: github.com/frankban/quicktest#v1.14.2: verifying module: github.com/frankban/quicktest#v1.14.2: Get "https://sum.golang.org/lookup/github.com/frankban/quicktest#v1.14.2": Not Found
go: github.com/google/btree#v1.0.1: verifying module: github.com/google/btree#v1.0.1: Get "https://sum.golang.org/lookup/github.com/google/btree#v1.0.1": Not Found
go: github.com/kr/pretty#v0.3.0: verifying module: github.com/kr/pretty#v0.3.0: Get "https://sum.golang.org/lookup/github.com/kr/pretty#v0.3.0": Not Found
go: github.com/kr/text#v0.2.0: verifying module: github.com/kr/text#v0.2.0: Get "https://sum.golang.org/lookup/github.com/kr/text#v0.2.0": Not Found
go: github.com/shabbyrobe/xmlwriter#v0.0.0-20220218224045-defe0ad214f6: verifying module: github.com/shabbyrobe/xmlwriter#v0.0.0-20220218224045-defe0ad214f6: Get "https://sum.golang.org/lookup/github.com/shabbyrobe/xmlwriter#v0.0.0-20220218224045-defe0ad214f6": Not Found
The sum.golang.org server needs some time to update the hash sum. Try again now. Everything works correctly for me:
$ GO111MODULE=on go get github.com/shabbyrobe/xmlwriter#v0.0.0-20220218224045-defe0ad214f6
go: downloading github.com/shabbyrobe/xmlwriter v0.0.0-20220218224045-defe0ad214f6
go: downloading golang.org/x/text v0.3.2
$ curl https://sum.golang.org/lookup/github.com/shabbyrobe/xmlwriter#v0.0.0-20220218224045-defe0ad214f6
9249991
github.com/shabbyrobe/xmlwriter v0.0.0-20220218224045-defe0ad214f6 h1:ri617veNyNwEMXywzcLmU//YIVSFdJvdk39lNsFB/Ro=
github.com/shabbyrobe/xmlwriter v0.0.0-20220218224045-defe0ad214f6/go.mod h1:tKYSeHyJGYz7eoZMlzrRDQSfdYPYt0UduMr8b97Mmaw=
go.sum database tree
9690070
OufFSNsOUYeDJ2VPyrxBAe7/d47lQYkE03JZL2ltaI8=
— sum.golang.org Az3grkvrWUkW3Rvnl5QL72oZpiY5ifJhab3/evZCb0hmRkEtGRE/tCMyFDXftZWFi2SF71EuHAxJMTgLd1laHabOzAE=

How to fix certificate error in go language " x509: certificate signed by unknown authority"

I am using this command to import library go mod tidy
but I am getting this error:
go: downloading github.com/mattn/go-sqlite3 v1.9.0
go: downloading github.com/go-sql-driver/mysql v1.4.0
go: downloading golang.org/x/exp v0.0.0-20191002040644-a1355ae1e2c3
go: downloading gonum.org/v1/netlib v0.0.0-20190313105609-8cb42192e0e0
ki/distance imports
gonum.org/v1/gonum/mat tested by
gonum.org/v1/gonum/mat.test imports
golang.org/x/exp/rand: golang.org/x/exp#v0.0.0-20191002040644-a1355ae1e2c3: Get https://proxy.golang.org/golang.org/x/exp/#v/v0.0.0-20191002040644-a1355ae1e2c3.zip: x509: certificate signed by unknown authority
ki/distance imports
gonum.org/v1/gonum/mat tested by
gonum.org/v1/gonum/mat.test imports
gonum.org/v1/netlib/blas/netlib: gonum.org/v1/netlib#v0.0.0-20190313105609-8cb42192e0e0: Get https://proxy.golang.org/gonum.org/v1/netlib/#v/v0.0.0-20190313105609-8cb42192e0e0.zip: x509: certificate signed by unknown authority
My go.mod look like this :
module ki
go 1.13
require (
github.com/gorilla/handlers v1.5.1
github.com/gorilla/mux v1.8.0
github.com/lib/pq v1.10.2
gonum.org/v1/gonum v0.9.1
)
However I have tried to update my ca-certificates also by using sudo apt-get update && sudo apt-get install ca-certificates && sudo update-ca-certificates but the error remains same. I have also tried to downgrade my go version from 1.16 to 1.13 but the error still appears. The same program is working fine on my colleague machine but only my machine is facing this error. I have also tried to add -insecure switch to go mod tidy -insecure but it did not work.
I have also tried downloading the libraries manually by using the go get --insecure gonum.org/v1/gonum/mat (with and without insecure switch) and getting similar error.
go get gonum.org/v1/gonum/mat: module gonum.org/v1/gonum/mat: Get https://proxy.golang.org/gonum.org/v1/gonum/mat/#v/list: x509: certificate signed by unknown authority
I have noticed that all the certificates error are linked to #v/list if that can be of any help.

Golang Revel freezes when download gopkg.in/fsnotify.v1

I'm using CentOS7; tried downloading the golang 1.5.1 binary and also yum install golang, and run into the same problem installed revel. Go works fine; when I do go version it displays the proper version.
When I type go get -v github.com/revel/revel, a few packages download just fine.... until it gets to fsnotify. Then I get this output:
Fetching https://gopkg.in/fsnotify.v1?go-get=1
Parsing meta tags from https://gopkg.in/fsnotify.v1?go-get=1 (status code 200)
get "gopkg.in/fsnotify.v1": found meta tag main.metaImport{Prefix:"gopkg.in/fsnotify.v1", VCS:"git", RepoRoot:"https://gopkg.in/fsnotify.v1"} at https://gopkg.in/fsnotify.v1?go-get=1
gopkg.in/fsnotify.v1 (download)
And it just freezes. No matter what I try, it doesn't download anything into src/gopkg.in/fsnotify. Files in src/github.com and src/golang.org are pulled just fine. I already made sure I'm able to curl into http://gopkg.in and https://gopkg.in, so it doesn't look like an SSLv3 issue.
Any ideas?
Upgrade Git so that it is greater than 1.7.1 (latest CentOS base version). Try rpmforge first; if that doesn't work, compile from source: https://git-scm.com/book/en/v2/Getting-Started-Installing-Git#Installing-from-Source
I'm on Git 2.6.2 and it's working fine now: go get -v github.com/revel/revel (-v for verbose mode)

Resources