Skip to content

Instantly share code, notes, and snippets.

@dmmulroy
Created January 31, 2019 14:46
Show Gist options
  • Save dmmulroy/2e66eafae5ad80681ee708103bff8130 to your computer and use it in GitHub Desktop.
Save dmmulroy/2e66eafae5ad80681ee708103bff8130 to your computer and use it in GitHub Desktop.
Go postgres driver is being registered twice fix

I ran into this and figured out what was going on; for the sake of future google searchers here is what might be happing if you see this error.

I was in a project with vendored dependencies, so 2 version of lib/pq existed: one in my project's vendor/ directory and another in $GOPATH/src/github.com/lib/pq. Normally this wouldn't be an issue, since the project should use the vendored one. But I failed to vendor a third dependency (in this case mattest/migrate), so it was getting built out of my GOPATH, and that imports lib/pq so used the GOPATH version of lib/pq for that. So two lib/pq packages would get built, both have their init() called... boom

@dmmulroy
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment