Hi everyone,
I have a pretty weird error with Go modules that I can't explain - after some investigation I feel this might be a bug but I'd like to have some extra eyes on it.
I have migrated my tools
repository (github.com/campoy/tools) to use Go modules and as a test I've tagged two major version v1.0.0
and v2.0.0
.
I then wrote a little program the flags
package in the tools
modules that looks like this:
package main
import (
"flag"
"fmt"
"image/color"
"github.com/campoy/tools/flags"
)
func main() {
h := flags.HexColor("color", color.Black, "color")
flag.Parse()
fmt.Println(h.RGBA())
}
which produced the following go.mod
:
module github.com/campoy/tests/mods
go 1.12
require github.com/campoy/tools v1.0.0
Now, when I try to use v2.0.0 I modify the import path of the program to use github.com/campoy/tools/v2/flags
and the require line to be require github.com/campoy/tools/v2 v2.0.0
When I try to build this the compilation fails with the error message:
go: github.com/campoy/tools/v...@v2.0.0: go.mod has non-.../v2 module path "github.com/campoy/tools" (and .../v2/go.mod does not exist) at revision v2.0.0
go: error loading module requirements
But if I instead use the tag v2.0.1
which points to the same commit as v2.0.0
everything works correctly.
Am I doing something wrong or does this seem like a real bug?
Hi everyone,
I have a pretty weird error with Go modules that I can't explain - after some investigation I feel this might be a bug but I'd like to have some extra eyes on it.
I have migrated my
tools
repository (github.com/campoy/tools) to use Go modules and as a test I've tagged two major versionv1.0.0
andv2.0.0
.
I then wrote a little program the
flags
package in thetools
modules that looks like this:
package main import ( "flag" "fmt" "image/color" "github.com/campoy/tools/flags" ) func main() { h := flags.HexColor("color", color.Black, "color") flag.Parse() fmt.Println(h.RGBA()) }
which produced the following
go.mod
:
module github.com/campoy/tests/mods go 1.12 require github.com/campoy/tools v1.0.0
Now, when I try to use v2.0.0 I modify the import path of the program to use
github.com/campoy/tools/v2/flags
and the require line to berequire github.com/campoy/tools/v2 v2.0.0
When I try to build this the compilation fails with the error message:
go: github.com/campoy/tools/v2@v2.0.0: go.mod has non-.../v2 module path "github.com/campoy/tools" (and .../v2/go.mod does not exist) at revision v2.0.0 go: error loading module requirements