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

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.

Related

go get command stuck on Mac

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?

Go install command show 404 error when trying to install module from github

I developed a go module and pushed it to github, when I am trying to install it with the go install command its showing
go: downloading github.com/hvuhsg/lokidbServer v0.0.0-20220825205442-250079f3d6e9
go: github.com/hvuhsg/lokidbServer/cmd/lokidb.go#latest: github.com/hvuhsg/lokidbServer#v0.0.0-20220825205442-250079f3d6e9: verifying module: github.com/hvuhsg/lokidbServer#v0.0.0-20220825205442-250079f3d6e9: reading https://sum.golang.org/lookup/github.com/hvuhsg/lokidb!server#v0.0.0-20220825205442-250079f3d6e9: 404 Not Found
server response:
not found: github.com/hvuhsg/lokidbServer#v0.0.0-20220825205442-250079f3d6e9: invalid version: git ls-remote -q origin in /tmp/gopath/pkg/mod/cache/vcs/023bef7fbf7701c1dd80019746ac35a6d71aa94fa9b3961e0dadef371238a56e: exit status 128:
fatal: could not read Username for 'https://github.com': terminal prompts disabled
Confirm the import path was entered correctly.
If this is a private repository, see https://golang.org/doc/faq#git_https for additional information.
P.S: the repo is public
The full command is
go install github.com/hvuhsg/lokidbServer/cmd/lokidb.go#latest
You can install it like this:
go install github.com/hvuhsg/lokidbServer/cmd#latest
If the repo is yours, I would recommend adding a folder lokidb to the cmd folder, and put the main package inside of it.
Check this repo as an example:
go install github.com/fraugster/parquet-go/cmd/csv2parquet#latest
Another option is to add a file to the root of the directory, like its done here (in this case, the package inside go.mod is defined as github.com/vektra/mockery/v2):
go install github.com/vektra/mockery/v2#latest

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=

Can't install go modules

I'm trying to follow a tutorial on how to create a Go microservice but I keep getting this errors whenever I run go mod tidy.
$ go mod tidy
go: finding module for package github.com/velotiotech/watermark-service/internal
go: finding module for package github.com/lithammer/shortuuid/v3
go: finding module for package github.com/go-kit/kit/log
go: downloading github.com/go-kit/kit v0.12.0
go: downloading github.com/lithammer/shortuuid/v3 v3.0.7
go: downloading github.com/velotiotech/watermark-service v0.0.0-20200604060255-debbccd8157b
github.com/chococascante/focus-archery-api/pkg imports
github.com/go-kit/kit/log: github.com/go-kit/kit#v0.12.0: verifying module: github.com/go-kit/kit#v0.12.0: initializing sumdb.Client: reading tree note: malformed note
note:
github.com/chococascante/focus-archery-api/pkg imports
github.com/lithammer/shortuuid/v3: github.com/lithammer/shortuuid/v3#v3.0.7: verifying module: github.com/lithammer/shortuuid/v3#v3.0.7: initializing sumdb.Client: reading tree note: malformed note
note:
github.com/chococascante/focus-archery-api/pkg imports
github.com/velotiotech/watermark-service/internal: github.com/velotiotech/watermark-service#v0.0.0-20200604060255-debbccd8157b: verifying module: github.com/velotiotech/watermark-service#v0.0.0-20200604060255-debbccd8157b: initializing sumdb.Client: reading tree note: malformed note
note:
Try disable the integrity check. Or try to change sum.golang.org to proxy.golang.org.
go env -w GOSUMDB=off

Resources