Cannot find module providing package ed25519 in Go language - go

I'm new in Go language. I want to test some code in Go language some code in Go language by using this command go run main.go.
I have this error:
cannot find module providing package github.com/perlin-network/noise/crypto/ed25519
I tried to install it using:
go get github.com/perlin-network/noise/crypto/ed25519
I get this error:
go: finding github.com/perlin-network/noise/crypto/ed25519 latest
go: finding github.com/perlin-network/noise/crypto latest
go get github.com/perlin-network/noise/crypto/ed25519: no matching versions for query "latest"
I also have tried this:
go get -u github.com/perlin-network/noise
The error:
go: finding github.com/oasislabs/ed25519 latest
go: finding golang.org/x/lint latest
go: finding golang.org/x/xerrors latest
go: finding golang.org/x/crypto latest
go: github.com/oasislabs/ed25519#v0.0.0-20210505154701-76d8c688d86e: parsing go.mod: unexpected module path "github.com/oasisprotocol/ed25519"
go: finding golang.org/x/net latest
go get: error loading module requirements
Did I miss something?

This is currently mentioned in perlin-network/noise issue 287, since Aug. 2020, without any answer for now (Q2 2021).
An alternative would be to:
fork the repository perlin-network/noise
update the dependency in the fork me/noise
use go mod replace in your project, to switch repositories.
But all that suggests your own project uses go mod, so make sure to go init myproject first, in order to benefit from those dependencies management feature.
That way, no need to $GOPATH/src.

Related

Why golang will remove a necessary package when I go get some other package

When I execute go get [repo_b], go module outputs the following message and I found that go module removed two necessary package, which is required by the project and therefore causing a building failure.
Can anyone tell me what is happening?
go: downloading [repo_a] v1.1.7
go: downloading gorm.io/driver/sqlite v1.3.5
go: module github.com/golang/protobuf is deprecated: Use the "google.golang.org/protobuf" module instead.
go: added [repo_b] v0.5.11
go: removed [required_repo_a] v0.0.0-some_commit_hash
go: removed [required_repo_b] v0.0.0-some_commit_hash
I have gone through official go module docs https://go.dev/ref/mod#go-get and search for "remove".
The docs mention that in some case such as ambiguous import, go module will automatically remove the package but I believe they should not be the case...

cannot find package "google.golang.org/protobuf/cmd/protoc-gen-go"

The page Protocol Buffer Basics: Go says 2 things:
1) Download the package and follow instructions in README
2) Run go install google.golang.org/protobuf/cmd/protoc-gen-go
Following the Download Protocol Buffers points to the release page which has tar and zip files for lots of languages (C++, C#, ...) but not Go. The file protobuf-all-3.12.3.tar.gz has many languages, but not Go. The README says for Go, head off to Go support for Protocol Buffers which says that it has been superseded by module google.golang.org/protobuf. There aren't any installation instructions by the time I've got there, just more general stuff pointing to even more pages. So I tried step (2)
go install google.golang.org/protobuf/cmd/protoc-gen-go
and got
can't load package: package google.golang.org/protobuf/cmd/protoc-gen-go: cannot find package "google.golang.org/protobuf/cmd/protoc-gen-go" in any of ...
I have 9 tabs open on my browser pointing to various Golang Protocol Buffer pages, and I still haven't managed to get going. I've downloaded protoc and got it working ok for Java and Python, but installing Go has got me beat so far. Is there a page that tells me what to do, in a simple way? Once upon a time using the Github repository it was easy, but that was long ago...
Thanks, Jan
Running
go get -u google.golang.org/protobuf/cmd/protoc-gen-go
first before go install seems to have solved it.
Make sure you have a go.mod:
go mod init github.com/org/repo
Have you tried installing the binary with the below command:
go install github.com/golang/protobuf/protoc-gen-go
If you are looking for a specific version, try:
go install github.com/golang/protobuf/protoc-gen-go#v1.3
Note: Make sure you set the GOBIN before you run the above commands
Thanks
Download protoc binary for required OS: github.com => protobuf => releases
Add protoc to $PATH
Install protoc-gen-go to $GOBIN:
user ~ % go install github.com/golang/protobuf/protoc-gen-go
go: finding github.com/golang/protobuf/protoc-gen-go latest
go: downloading google.golang.org/protobuf v1.23.0
go: extracting google.golang.org/protobuf v1.23.0
go: finding google.golang.org/protobuf v1.23.0
Note: to specific version add #v + version
Note: Go Automatically install protoc-gen-go binary to $GOBIN, if $GOBIN did not set, it's equals $GOPATH/bin.
see this.
https://developers.google.com/protocol-buffers/docs/reference/go-generated
you need go version 1.16 or higher. check that.
As pointed out in #jeremyko's comment, you will need Go 1.16 or higher. I personally installed Go from the APT repository, which often has outdated packages. It installed 1.13, so I had problems with installing OpenSnitch.
You can download the latest version from here.

Module declared as X but was required as Y

I'm trying to use grafana/grafana/pkg/tsdb package in my module. I don't think this problem is specific to grafana but here it goes:
$ go get -u github.com/grafana/grafana/pkg/tsdb
go: finding github.com/inconshreveable/log15 latest
go: finding github.com/go-macaron/session latest
go: finding golang.org/x/oauth2 latest
go: finding github.com/teris-io/shortid latest
go: github.com/grafana/grafana/pkg/tsdb imports
github.com/go-xorm/core: github.com/go-xorm/core#v0.6.3: parsing go.mod:
module declares its path as: xorm.io/core
but was required as: github.com/go-xorm/core
It says that the package tsdb is importing xorm as github.com/go-xorm/core, but the module declares itself as xorm.io/core.
Looking at Grafana's go.mod file, it's using github.com/go-xorm/core and going to github.com/go-xorm/core, it says the project is now archived... and it's go.mod file indeed declared itself as xorm.io/core...
and suggestions on how I can resolve this issue?
edit: I also had luck just using a slightly older version:
go get github.com/grafana/grafana/pkg/tsdb#6.6.1
I tried a replace, which can work sometimes:
module foo
replace github.com/go-xorm/core => xorm.io/core v0.6.2
go 1.13
require (
...
but I get a type error.
Luckily it looks like there is a PR out to fix this issue: https://github.com/grafana/grafana/pull/22376

go get -u github.com/onsi/ginkgo/ginkgo starts throwing error all of a sudden

When I run go get -u github.com/onsi/ginkgo/ginkgo
till yesterday I had no issues. Specifically with fsnotify the output was like below
00:52:08 go: downloading gopkg.in/fsnotify.v1 v1.4.7
00:52:08 go: extracting gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7
00:52:08 go: extracting gopkg.in/fsnotify.v1 v1.4.7
Now I see this error while executing same command
11:50:39 go: gopkg.in/fsnotify.v1#v1.4.8: go.mod has non-....v1 module path "github.com/fsnotify/fsnotify" at revision v1.4.8
11:50:39 go get: error loading module requirements
What might have gone wrong here
Some module in the transitive dependencies of github.com/onsi/ginkgo/ginkgo added a requirement on some version of gopkg.in/fsnotify.v1, which resolves to the repository hosted at github.com/fsnotify/fsnotify.
However, the go.mod file in that repository declares its canonical import path to be github.com/fsnotify/fsnotify, not gopkg.in/fsnotify.v1.
If you are using Go 1.14, the rest of the error message (which seems to be truncated) should tell you exactly which dependency is using the non-canonical path. The long-term fix is to move that dependency over to the canonical path and upgrade your other dependencies such that gopkg.in/fsnotify.v1 is no longer required.

Why "undefined: StackGuardMultiplierDefault" error?

describe
When I clone GoAdminGroup/go-admin projectin github and run the project by the steps of README.MD file , I get this error
TEST-MBP:example TEST$ GO111MODULE=on go run main.go
go: downloading github.com/mattn/go-sqlite3 v1.11.0
go: extracting github.com/mattn/go-sqlite3 v1.11.0
go: finding github.com/mattn/go-sqlite3 v1.11.0
# runtime/internal/sys
/Users/TEST/go/src/runtime/internal/sys/stubs.go:16:30: undefined: StackGuardMultiplierDefault
Actually my /Users/TEST/go/src folder was cloned from https://github.com/golang/go/tree/release-branch.go1.13/src
Why StackGuardMultiplierDefault was undefined in /src/runtime/internal/sys/stubs.go
As per my understanding you cloned the Go source code from it's github and expecting it to work. It will not work.
You need to to follow Go guide Installing Go from source if you want to install it from the (github) source. Only cloning the repository is not enough, there are some required steps to be done after that.
Otherwise I suggest to install by using the available binary distributions installer.
Detailed explanation: the const StackGuardMultiplierDefault is not found because the file where the const declared does not exists (the zversion.go file). This particular file is only generated when àll.bash is executed (part of steps on installling Go from source).

Resources