File tree Expand file tree Collapse file tree 1 file changed +10
-0
lines changed
src/cmd/go/internal/modload Expand file tree Collapse file tree 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) {
17101710 badPathErr = err
17111711 break
17121712 }
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+ }
17131722 return path , nil
17141723 }
17151724 }
@@ -1725,6 +1734,7 @@ func findModulePath(dir string) (string, error) {
17251734Example usage:
17261735 'go mod init example.com/m' to initialize a v0 or v1 module
17271736 '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
17281738
17291739Run 'go help mod init' for more information.
17301740`
You can’t perform that action at this time.
0 commit comments