File tree 1 file changed +10
-0
lines changed
src/cmd/go/internal/modload
1 file changed +10
-0
lines changed Original file line number Diff line number Diff line change @@ -1710,6 +1710,15 @@ func findModulePath(dir string) (string, error) {
1710
1710
badPathErr = err
1711
1711
break
1712
1712
}
1713
+ // Ensure the inferred path is valid.
1714
+ if _ , _ , ok := module .SplitPathVersion (path ); ! ok {
1715
+ if strings .HasPrefix (path , "gopkg.in/" ) {
1716
+ badPathErr = errors .New ("module paths beginning with gopkg.in/ must always have a major version suffix in the form of .vN" )
1717
+ } else {
1718
+ badPathErr = errors .New ("major version suffixes must be in the form of /vN and are only allowed for v2 or later" )
1719
+ }
1720
+ break
1721
+ }
1713
1722
return path , nil
1714
1723
}
1715
1724
}
@@ -1725,6 +1734,7 @@ func findModulePath(dir string) (string, error) {
1725
1734
Example usage:
1726
1735
'go mod init example.com/m' to initialize a v0 or v1 module
1727
1736
'go mod init example.com/m/v2' to initialize a v2 module
1737
+ 'go mod init gopkg.in/m.v1' to initialize a gopkg.in module
1728
1738
1729
1739
Run 'go help mod init' for more information.
1730
1740
`
You can’t perform that action at this time.
0 commit comments