Update go version
This commit is contained in:
14
vendor/golang.org/x/tools/internal/modindex/index.go
generated
vendored
14
vendor/golang.org/x/tools/internal/modindex/index.go
generated
vendored
@@ -10,7 +10,6 @@ import (
|
||||
"encoding/csv"
|
||||
"fmt"
|
||||
"io"
|
||||
"log"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strconv"
|
||||
@@ -107,14 +106,14 @@ var IndexDir string = func() string {
|
||||
var err error
|
||||
dir, err = os.UserCacheDir()
|
||||
// shouldn't happen, but TempDir is better than
|
||||
// creating ./go/imports
|
||||
// creating ./goimports
|
||||
if err != nil {
|
||||
dir = os.TempDir()
|
||||
}
|
||||
}
|
||||
dir = filepath.Join(dir, "goimports")
|
||||
if err := os.MkdirAll(dir, 0777); err != nil {
|
||||
log.Printf("failed to create modcache index dir: %v", err)
|
||||
dir = "" // #75505, people complain about the error message
|
||||
}
|
||||
return dir
|
||||
}()
|
||||
@@ -127,6 +126,9 @@ func Read(gomodcache string) (*Index, error) {
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if IndexDir == "" {
|
||||
return nil, os.ErrNotExist
|
||||
}
|
||||
|
||||
// Read the "link" file for the specified gomodcache directory.
|
||||
// It names the payload file.
|
||||
@@ -186,6 +188,9 @@ func readIndexFrom(gomodcache string, r io.Reader) (*Index, error) {
|
||||
)
|
||||
for scan.Scan() {
|
||||
v := scan.Text()
|
||||
if len(v) < 2 {
|
||||
return nil, fmt.Errorf("malformed line: %q, %d entries", v, len(entries))
|
||||
}
|
||||
if v[0] == ':' {
|
||||
if curEntry != nil {
|
||||
entries = append(entries, *curEntry)
|
||||
@@ -227,6 +232,9 @@ func readIndexFrom(gomodcache string, r io.Reader) (*Index, error) {
|
||||
|
||||
// write writes the index file and updates the index directory to refer to it.
|
||||
func write(gomodcache string, ix *Index) error {
|
||||
if IndexDir == "" {
|
||||
return os.ErrNotExist
|
||||
}
|
||||
// Write the index into a payload file with a fresh name.
|
||||
f, err := os.CreateTemp(IndexDir, fmt.Sprintf("index-%d-*", CurrentVersion))
|
||||
if err != nil {
|
||||
|
||||
4
vendor/golang.org/x/tools/internal/modindex/modindex.go
generated
vendored
4
vendor/golang.org/x/tools/internal/modindex/modindex.go
generated
vendored
@@ -73,7 +73,9 @@ func build(gomodcache string, old *Index) (*Index, bool, error) {
|
||||
// Set the time window.
|
||||
var start time.Time // = dawn of time
|
||||
if old != nil {
|
||||
start = old.ValidAt
|
||||
// -1s to accommodate skew between (fine-grained) time.Now
|
||||
// and (coarse) file system's mtime clock.
|
||||
start = old.ValidAt.Add(-1 * time.Second)
|
||||
}
|
||||
now := time.Now()
|
||||
end := now.Add(24 * time.Hour) // safely in the future
|
||||
|
||||
Reference in New Issue
Block a user