1
0
mirror of https://github.com/golang/go synced 2024-11-24 22:00:09 -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 (
"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"
"encoding/json"
"errors"
"fmt"
"go/build"
"internal/lazyregexp"
"io/ioutil"
"os"
"path"
@ -26,7 +20,13 @@ import (
"strings"
"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/module"
@ -1424,7 +1424,9 @@ Run 'go help mod init' for more information.
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 {
data, err := os.ReadFile(file)