]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/go/internal/modfile: prepare to move to x/mod
authorJay Conrod <jayconrod@google.com>
Tue, 22 Oct 2019 19:29:28 +0000 (15:29 -0400)
committerJay Conrod <jayconrod@google.com>
Tue, 22 Oct 2019 20:00:32 +0000 (20:00 +0000)
- Deleted dead code in gopkgin.go.
- Minor documentation changes.

Updates #34924

Change-Id: Ie2c744bbf6662cae20f09163200f20d7589fd237
Reviewed-on: https://go-review.googlesource.com/c/go/+/202565
Run-TryBot: Jay Conrod <jayconrod@google.com>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>

src/cmd/go/internal/modfile/gopkgin.go [deleted file]
src/cmd/go/internal/modfile/print.go
src/cmd/go/internal/modfile/read.go

diff --git a/src/cmd/go/internal/modfile/gopkgin.go b/src/cmd/go/internal/modfile/gopkgin.go
deleted file mode 100644 (file)
index c94b384..0000000
+++ /dev/null
@@ -1,47 +0,0 @@
-// Copyright 2018 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-// TODO: Figure out what gopkg.in should do.
-
-package modfile
-
-import "strings"
-
-// ParseGopkgIn splits gopkg.in import paths into their constituent parts
-func ParseGopkgIn(path string) (root, repo, major, subdir string, ok bool) {
-       if !strings.HasPrefix(path, "gopkg.in/") {
-               return
-       }
-       f := strings.Split(path, "/")
-       if len(f) >= 2 {
-               if elem, v, ok := dotV(f[1]); ok {
-                       root = strings.Join(f[:2], "/")
-                       repo = "github.com/go-" + elem + "/" + elem
-                       major = v
-                       subdir = strings.Join(f[2:], "/")
-                       return root, repo, major, subdir, true
-               }
-       }
-       if len(f) >= 3 {
-               if elem, v, ok := dotV(f[2]); ok {
-                       root = strings.Join(f[:3], "/")
-                       repo = "github.com/" + f[1] + "/" + elem
-                       major = v
-                       subdir = strings.Join(f[3:], "/")
-                       return root, repo, major, subdir, true
-               }
-       }
-       return
-}
-
-func dotV(name string) (elem, v string, ok bool) {
-       i := len(name) - 1
-       for i >= 0 && '0' <= name[i] && name[i] <= '9' {
-               i--
-       }
-       if i <= 2 || i+1 >= len(name) || name[i-1] != '.' || name[i] != 'v' || name[i+1] == '0' && len(name) != i+2 {
-               return "", "", false
-       }
-       return name[:i-1], name[i:], true
-}
index cefc43b141c6e88daa9731a4430dbaa913fbedb4..3bbea38529f8317d5e717e29563d9523efafef6c 100644 (file)
@@ -12,6 +12,7 @@ import (
        "strings"
 )
 
+// Format returns a go.mod file as a byte slice, formatted in standard style.
 func Format(f *FileSyntax) []byte {
        pr := &printer{}
        pr.file(f)
index 1d81ff1ab7a326061f9352bbfe485533b6f9a5f5..bfa90a5a6449ef9fab7cd155c5984d8673a2fd7a 100644 (file)
@@ -17,7 +17,8 @@ import (
        "unicode/utf8"
 )
 
-// A Position describes the position between two bytes of input.
+// A Position describes an arbitrary source position in a file, including the
+// file, line, column, and byte offset.
 type Position struct {
        Line     int // line in input (starting at 1)
        LineRune int // rune in line (starting at 1)