1
0
mirror of https://github.com/golang/go synced 2024-11-25 00:17:58 -07:00

cmd/go: undo import order changes in modinfo init

This commit is contained in:
Boston Cartwright 2022-03-26 01:55:01 +00:00 committed by GitHub
parent 15fe0889e3
commit 95efed774e

View File

@ -6,18 +6,12 @@ package modload
import ( import (
"bytes" "bytes"
"cmd/go/internal/base"
"cmd/go/internal/cfg"
"cmd/go/internal/fsys"
"cmd/go/internal/lockedfile"
"cmd/go/internal/modconv"
"cmd/go/internal/modfetch"
"cmd/go/internal/search"
"context" "context"
"encoding/json" "encoding/json"
"errors" "errors"
"fmt" "fmt"
"go/build" "go/build"
"internal/lazyregexp"
"io/ioutil" "io/ioutil"
"os" "os"
"path" "path"
@ -26,7 +20,13 @@ import (
"strings" "strings"
"sync" "sync"
"internal/lazyregexp" "cmd/go/internal/base"
"cmd/go/internal/cfg"
"cmd/go/internal/fsys"
"cmd/go/internal/lockedfile"
"cmd/go/internal/modconv"
"cmd/go/internal/modfetch"
"cmd/go/internal/search"
"golang.org/x/mod/modfile" "golang.org/x/mod/modfile"
"golang.org/x/mod/module" "golang.org/x/mod/module"
@ -1424,7 +1424,9 @@ Run 'go help mod init' for more information.
return "", fmt.Errorf(msg, dir, reason) return "", fmt.Errorf(msg, dir, reason)
} }
var importCommentRE = lazyregexp.New(`(?m)^package[ \t]+[^ \t\r\n/]+[ \t]+//[ \t]+import[ \t]+(\"[^"]+\")[ \t]*\r?\n`) var (
importCommentRE = lazyregexp.New(`(?m)^package[ \t]+[^ \t\r\n/]+[ \t]+//[ \t]+import[ \t]+(\"[^"]+\")[ \t]*\r?\n`)
)
func findImportComment(file string) string { func findImportComment(file string) string {
data, err := os.ReadFile(file) data, err := os.ReadFile(file)