Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

go-kivik import order causes initialisation failure #372

Closed
ostenbom opened this issue Apr 29, 2019 · 11 comments
Closed

go-kivik import order causes initialisation failure #372

ostenbom opened this issue Apr 29, 2019 · 11 comments
Labels

Comments

@ostenbom
Copy link

Bug Report Checklist (remove this template if submitting a feature request)

  1. Which version of Kivik are you using?
    1.8.1

  2. Which version of Go are you using?
    go version go1.12.4 linux/amd64

  3. What did you do? (Include your code if possible)

package main

import (
  "fmt"

  _ "github.com/go-kivik/couchdb" // The CouchDB driver
  "github.com/go-kivik/kivik"
)

func main() {
  client, err := kivik.New(context.Background(), "couch", host)
  if err != nil {
    panic(fmt.Sprintf("problems: %s", err))
  }
}

  1. What did you expect to see?
    Nothing

  2. What did you see instead?
    Problems: unknown driver "couch" (forgotten import?)

My linter forces alphabetic package ordering, putting go-kivik/couchdb at the top. If I use flimzy/kivik, the ordering changes (flimzy < go-kivik). And the problem disappears.

Initially I thought using init() in go-kivik might do the trick, since golang forces imported packages initialisation functions to run before its own init().

Looking at go-kivik/couchdb I realise that it imports flimzy/kivik instead of go-kivik/kivik - perhaps this is why the initialisation isn't working the way it should.

What an odd quirk of having dev/stable in separate repositories!

@flimzy
Copy link
Member

flimzy commented May 4, 2019

For the 1.x series of kivik, you must use github.com/flimzy/kivik. For the newer (unstable) version, which will become 2.x, use github.com/go-kivik/kivik.

@flimzy
Copy link
Member

flimzy commented May 9, 2019

I've updated the documentation to hopefully be a bit more clear. Please let me know if further clarification or problems persist, and I'll do my best to address them.

@flimzy flimzy closed this as completed May 9, 2019
@ToJen
Copy link

ToJen commented May 13, 2019

When should we switch to use go-kivik/kivik?

@flimzy
Copy link
Member

flimzy commented May 14, 2019

go-kivik/kivik should be fully functional at the moment. But the API is likely (in fact, certain parts are certain) to change, before I tag it with a 2.0 version, so future upgrades could require you to change your client code in unexpected ways.

I hope to have the API stabilized within a month or two, but it largely depends on how much free time I have over the summer.

@ToJen
Copy link

ToJen commented May 16, 2019

Okay, no pressure, just asking because when I import github.com/go-kivik/kivik, GoLand says this:

'github.com/go-kivik/kivik' imports package that expects import "github.com/flimzy/kivik".

Then it says that I replace it with flimzy/kivik.

@flimzy
Copy link
Member

flimzy commented May 16, 2019

That means you've somehow downloaded version 1.x, using the 2.x import path. How did you download kivik? With go get? Or are you using a vendoring tool? And if so, which one?

@flimzy flimzy reopened this May 16, 2019
@ToJen
Copy link

ToJen commented May 16, 2019

Tried both go get github.com/go-kivik/kivik and go get -u github.com/go-kivik/kivik

@flimzy
Copy link
Member

flimzy commented May 17, 2019

That should fetch the development version, which should not give you the error above. I suggest deleting kivik:

rm -rf $GOPATH/src/github.com/go-kivik

Then re-installing it. Please let me know if that helps.

@ToJen
Copy link

ToJen commented May 17, 2019

It's still the same but is it ok to use flimzy/kivik?

@ToJen
Copy link

ToJen commented May 17, 2019

Here's some test code in a gist.

@flimzy
Copy link
Member

flimzy commented May 20, 2019

Yes, it's okay to use flimzy/kivik, and it's required if you want the stable branch.

@flimzy flimzy closed this as completed May 22, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants