Luís Soares
Luís Soares

Reputation: 6222

Go Modules - how to reference a branch in GitHub

I'm using Coreos OIDC library and would like to know how to reference (in go.mod file) a branch, since they don't develop under master but use v2 instead.

I tried github.com/coreos/go-oidc@v2 but I get:

go: github.com/coreos/go-oidc@[email protected]+incompatible: invalid github.com/ import path "github.com/coreos/go-oidc@v2"
go: error loading module requirements

Upvotes: 4

Views: 7613

Answers (1)

bcmills
bcmills

Reputation: 5197

The phrase import path in the error message suggests that somewhere in your code you have written something like:

import "github.com/coreos/go-oidc@v2"

But the import path of a Go package does not include its version: only the entries in the go.mod and go.sum files do.

So instead you should write:

import "github.com/coreos/go-oidc"

and update your go.mod and go.sum files by running

go get -d github.com/coreos/go-oidc@v2

That should result in an entry in your go.mod file like:

require github.com/coreos/go-oidc v2.0.0+incompatible

Upvotes: 2

Related Questions