1

I am trying to use pulsar from golang and i am trying to migrate my project from dep to go modules since some of the newer libraries prefer go modules.

When i tried to create a new project and run

dep ensure -add github.com/apache/pulsar/pulsar-client-go/pulsar@v2.4.1

it works perfect,I am getting 2.4.1 tag it loads the correct cgo library everything is great.

But in go modules when i try to do like

go.mod File:

module sample 
go 1.13 
require (   github.com/apache/pulsar/pulsar-client-go/pulsar v2.4.1 )

It fails with

require github.com/apache/pulsar/pulsar-client-go/pulsar: version "v2.4.1" invalid: unknown revision pulsar-client-go/pulsar/v2.4.1

1 Answers1

0

dep uses import paths. Modules use module paths, which are slightly different. To find the module path, you need to track down the go.mod file and look at the module name.

The module you're trying to use is github.com/apache/pulsar/pulsar-client-go, without the /pulsar suffix. There is no go.mod file at .../pulsar-client-go/pulsar/.

Once you have the proper module path in your go.mod file, you may then use the import path in your code.

package foo

import "github.com/apache/pulsar/pulsar-client-go/pulsar"

func Foo() {
    pulsar.Foo()
}
ryboe
  • 206