mirror of
https://github.com/opencloud-eu/opencloud.git
synced 2026-05-24 16:41:35 -04:00
Merge pull request #2739 from opencloud-eu/dependabot/go_modules/github.com/onsi/ginkgo/v2-2.28.3
build(deps): bump github.com/onsi/ginkgo/v2 from 2.28.1 to 2.28.3
This commit is contained in:
10
go.mod
10
go.mod
@@ -60,7 +60,7 @@ require (
|
||||
github.com/oklog/run v1.2.0
|
||||
github.com/olekukonko/tablewriter v1.1.4
|
||||
github.com/onsi/ginkgo v1.16.5
|
||||
github.com/onsi/ginkgo/v2 v2.28.1
|
||||
github.com/onsi/ginkgo/v2 v2.28.3
|
||||
github.com/onsi/gomega v1.40.0
|
||||
github.com/open-policy-agent/opa v1.15.2
|
||||
github.com/opencloud-eu/icap-client v0.0.0-20250930132611-28a2afe62d89
|
||||
@@ -106,7 +106,7 @@ require (
|
||||
golang.org/x/crypto v0.50.0
|
||||
golang.org/x/exp v0.0.0-20250210185358-939b2ce775ac
|
||||
golang.org/x/image v0.38.0
|
||||
golang.org/x/net v0.52.0
|
||||
golang.org/x/net v0.53.0
|
||||
golang.org/x/oauth2 v0.36.0
|
||||
golang.org/x/sync v0.20.0
|
||||
golang.org/x/term v0.42.0
|
||||
@@ -239,7 +239,7 @@ require (
|
||||
github.com/golang/snappy v0.0.4 // indirect
|
||||
github.com/google/go-querystring v1.1.0 // indirect
|
||||
github.com/google/go-tpm v0.9.8 // indirect
|
||||
github.com/google/pprof v0.0.0-20260115054156-294ebfa9ad83 // indirect
|
||||
github.com/google/pprof v0.0.0-20260402051712-545e8a4df936 // indirect
|
||||
github.com/google/renameio/v2 v2.0.2 // indirect
|
||||
github.com/gookit/goutil v0.7.4 // indirect
|
||||
github.com/gorilla/handlers v1.5.1 // indirect
|
||||
@@ -389,10 +389,10 @@ require (
|
||||
go.uber.org/zap v1.27.0 // indirect
|
||||
go.yaml.in/yaml/v2 v2.4.3 // indirect
|
||||
go.yaml.in/yaml/v3 v3.0.4 // indirect
|
||||
golang.org/x/mod v0.34.0 // indirect
|
||||
golang.org/x/mod v0.35.0 // indirect
|
||||
golang.org/x/sys v0.43.0 // indirect
|
||||
golang.org/x/time v0.15.0 // indirect
|
||||
golang.org/x/tools v0.43.0 // indirect
|
||||
golang.org/x/tools v0.44.0 // indirect
|
||||
google.golang.org/genproto v0.0.0-20260128011058-8636f8732409 // indirect
|
||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20260406210006-6f92a3bedf2d // indirect
|
||||
gopkg.in/cenkalti/backoff.v1 v1.1.0 // indirect
|
||||
|
||||
20
go.sum
20
go.sum
@@ -576,8 +576,8 @@ github.com/google/pprof v0.0.0-20200212024743-f11f1df84d12/go.mod h1:ZgVRPoUq/hf
|
||||
github.com/google/pprof v0.0.0-20200229191704-1ebb73c60ed3/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM=
|
||||
github.com/google/pprof v0.0.0-20200430221834-fc25d7d30c6d/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM=
|
||||
github.com/google/pprof v0.0.0-20200708004538-1a94d8640e99/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM=
|
||||
github.com/google/pprof v0.0.0-20260115054156-294ebfa9ad83 h1:z2ogiKUYzX5Is6zr/vP9vJGqPwcdqsWjOt+V8J7+bTc=
|
||||
github.com/google/pprof v0.0.0-20260115054156-294ebfa9ad83/go.mod h1:MxpfABSjhmINe3F1It9d+8exIHFvUqtLIRCdOGNXqiI=
|
||||
github.com/google/pprof v0.0.0-20260402051712-545e8a4df936 h1:EwtI+Al+DeppwYX2oXJCETMO23COyaKGP6fHVpkpWpg=
|
||||
github.com/google/pprof v0.0.0-20260402051712-545e8a4df936/go.mod h1:MxpfABSjhmINe3F1It9d+8exIHFvUqtLIRCdOGNXqiI=
|
||||
github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI=
|
||||
github.com/google/renameio/v2 v2.0.2 h1:qKZs+tfn+arruZZhQ7TKC/ergJunuJicWS6gLDt/dGw=
|
||||
github.com/google/renameio/v2 v2.0.2/go.mod h1:OX+G6WHHpHq3NVj7cAOleLOwJfcQ1s3uUJQCrr78SWo=
|
||||
@@ -935,8 +935,8 @@ github.com/onsi/ginkgo v1.7.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+W
|
||||
github.com/onsi/ginkgo v1.12.1/go.mod h1:zj2OWP4+oCPe1qIXoGWkgMRwljMUYCdkwsT2108oapk=
|
||||
github.com/onsi/ginkgo v1.16.5 h1:8xi0RTUf59SOSfEtZMvwTvXYMzG4gV23XVHOZiXNtnE=
|
||||
github.com/onsi/ginkgo v1.16.5/go.mod h1:+E8gABHa3K6zRBolWtd+ROzc/U5bkGt0FwiG042wbpU=
|
||||
github.com/onsi/ginkgo/v2 v2.28.1 h1:S4hj+HbZp40fNKuLUQOYLDgZLwNUVn19N3Atb98NCyI=
|
||||
github.com/onsi/ginkgo/v2 v2.28.1/go.mod h1:CLtbVInNckU3/+gC8LzkGUb9oF+e8W8TdUsxPwvdOgE=
|
||||
github.com/onsi/ginkgo/v2 v2.28.3 h1:4JvMdwtFU0imd8fHx25OJXoDMRexnf8v5NHKYSTTji4=
|
||||
github.com/onsi/ginkgo/v2 v2.28.3/go.mod h1:+aXOY+vzZ5mu2iI2HpTZUPmM//oQfsNFX6gU9kNcA44=
|
||||
github.com/onsi/gomega v1.4.3/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY=
|
||||
github.com/onsi/gomega v1.7.1/go.mod h1:XdKZgCCFLUoM/7CFJVPcG8C1xQ1AJ0vpAezJrB7JYyY=
|
||||
github.com/onsi/gomega v1.10.1/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1ybHNo=
|
||||
@@ -1401,8 +1401,8 @@ golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
|
||||
golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
|
||||
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4=
|
||||
golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
|
||||
golang.org/x/mod v0.34.0 h1:xIHgNUUnW6sYkcM5Jleh05DvLOtwc6RitGHbDk4akRI=
|
||||
golang.org/x/mod v0.34.0/go.mod h1:ykgH52iCZe79kzLLMhyCUzhMci+nQj+0XkbXpNYtVjY=
|
||||
golang.org/x/mod v0.35.0 h1:Ww1D637e6Pg+Zb2KrWfHQUnH2dQRLBQyAtpr/haaJeM=
|
||||
golang.org/x/mod v0.35.0/go.mod h1:+GwiRhIInF8wPm+4AoT6L0FA1QWAad3OMdTRx4tFYlU=
|
||||
golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
@@ -1453,8 +1453,8 @@ golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs=
|
||||
golang.org/x/net v0.10.0/go.mod h1:0qNGK6F8kojg2nk9dLZ2mShWaEBan6FAoqfSigmmuDg=
|
||||
golang.org/x/net v0.21.0/go.mod h1:bIjVDfnllIU7BJ2DNgfnXvpSvtn8VRwhlsaeUTyUS44=
|
||||
golang.org/x/net v0.23.0/go.mod h1:JKghWKKOSdJwpW2GEx0Ja7fmaKnMsbu+MWVZTokSYmg=
|
||||
golang.org/x/net v0.52.0 h1:He/TN1l0e4mmR3QqHMT2Xab3Aj3L9qjbhRm78/6jrW0=
|
||||
golang.org/x/net v0.52.0/go.mod h1:R1MAz7uMZxVMualyPXb+VaqGSa3LIaUqk0eEt3w36Sw=
|
||||
golang.org/x/net v0.53.0 h1:d+qAbo5L0orcWAr0a9JweQpjXF19LMXJE8Ey7hwOdUA=
|
||||
golang.org/x/net v0.53.0/go.mod h1:JvMuJH7rrdiCfbeHoo3fCQU24Lf5JJwT9W3sJFulfgs=
|
||||
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
|
||||
golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
|
||||
golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
|
||||
@@ -1646,8 +1646,8 @@ golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4f
|
||||
golang.org/x/tools v0.0.0-20210112230658-8b4aab62c064/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
|
||||
golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc=
|
||||
golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU=
|
||||
golang.org/x/tools v0.43.0 h1:12BdW9CeB3Z+J/I/wj34VMl8X+fEXBxVR90JeMX5E7s=
|
||||
golang.org/x/tools v0.43.0/go.mod h1:uHkMso649BX2cZK6+RpuIPXS3ho2hZo4FVwfoy1vIk0=
|
||||
golang.org/x/tools v0.44.0 h1:UP4ajHPIcuMjT1GqzDWRlalUEoY+uzoZKnhOjbIPD2c=
|
||||
golang.org/x/tools v0.44.0/go.mod h1:KA0AfVErSdxRZIsOVipbv3rQhVXTnlU6UhKxHd1seDI=
|
||||
golang.org/x/tools/godoc v0.1.0-deprecated h1:o+aZ1BOj6Hsx/GBdJO/s815sqftjSnrZZwyYTHODvtk=
|
||||
golang.org/x/tools/godoc v0.1.0-deprecated/go.mod h1:qM63CriJ961IHWmnWa9CjZnBndniPt4a3CK0PVB9bIg=
|
||||
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
|
||||
14
vendor/github.com/onsi/ginkgo/v2/CHANGELOG.md
generated
vendored
14
vendor/github.com/onsi/ginkgo/v2/CHANGELOG.md
generated
vendored
@@ -1,3 +1,17 @@
|
||||
## 2.28.3
|
||||
|
||||
### Maintenance
|
||||
Bump all dependencies
|
||||
|
||||
## 2.28.2
|
||||
|
||||
- Add ArtifactDir() to support Go 1.26 testing.TB interface [f3a36b6]
|
||||
- Implement shell completion [94151c8]
|
||||
- Add asan CLI option mirroring msan implementation [4d21dbb]
|
||||
- Bump uri from 1.0.3 to 1.0.4 in /docs (#1630) [c102161]
|
||||
- fix aspect ratio [9619647]
|
||||
- update logos [5779304]
|
||||
|
||||
## 2.28.1
|
||||
|
||||
Update all dependencies. This auto-updated the required version of Go to 1.24, consistent with the fact that Go 1.23 has been out of support for almost six months.
|
||||
|
||||
2
vendor/github.com/onsi/ginkgo/v2/README.md
generated
vendored
2
vendor/github.com/onsi/ginkgo/v2/README.md
generated
vendored
@@ -120,6 +120,6 @@ Sponsors commit to a [sponsorship](https://github.com/sponsors/onsi) for a year.
|
||||
|
||||
<p style="font-size:21px; color:black;">Browser testing via
|
||||
<a href="https://www.testmu.ai/" target="_blank">
|
||||
<img src="https://www.testmu.ai/blue-logo.png" style="vertical-align: middle;" width="250" height="45" />
|
||||
<img src="https://assets.testmu.ai/resources/images/logos/white-logo.png" style="vertical-align: middle;" width="250" />
|
||||
</a>
|
||||
</p>
|
||||
|
||||
164
vendor/github.com/onsi/ginkgo/v2/ginkgo/command/program.go
generated
vendored
164
vendor/github.com/onsi/ginkgo/v2/ginkgo/command/program.go
generated
vendored
@@ -1,9 +1,13 @@
|
||||
package command
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
"fmt"
|
||||
"io"
|
||||
"maps"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"slices"
|
||||
"strings"
|
||||
|
||||
"github.com/onsi/ginkgo/v2/formatter"
|
||||
@@ -158,6 +162,166 @@ func (p Program) handleHelpRequestsAndExit(writer io.Writer, args []string) {
|
||||
}
|
||||
}
|
||||
|
||||
type completionOptions = struct {
|
||||
Complete bool
|
||||
Install bool
|
||||
}
|
||||
|
||||
func (p *Program) BuildCompletionCommand() Command {
|
||||
opts := completionOptions{}
|
||||
flags, err := types.NewGinkgoFlagSet(
|
||||
types.GinkgoFlags{
|
||||
{Name: "complete", KeyPath: "Complete", Usage: "Generate completion for arguments after --"},
|
||||
{Name: "install", KeyPath: "Install", Usage: "Install shell completion script into $XDG_DATA_HOME, ~/.local/share"},
|
||||
},
|
||||
&opts,
|
||||
types.GinkgoFlagSections{},
|
||||
)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return Command{
|
||||
Name: "completion",
|
||||
Usage: "ginkgo completion <FLAGS> <SHELL> [-- <COMPLETE>]",
|
||||
Flags: flags,
|
||||
ShortDoc: "Generate shell completion",
|
||||
Documentation: `To use install completion script for your shell (bash, fish, zsh).
|
||||
Or load completion code by: {{bold}}source <(ginkgo completion <SHELL>){{/}}.`,
|
||||
Command: func(args []string, completeArgs []string) {
|
||||
p.handleCompletionAndExit(args, completeArgs, opts)
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func (p Program) generateShellCompletionScript(shell string) (scriptPath string, script string) {
|
||||
switch shell {
|
||||
case "bash":
|
||||
scriptPath = fmt.Sprintf("bash-completion/completions/%s", p.Name)
|
||||
script = fmt.Sprintf(`__%s_complete_bash() {
|
||||
mapfile -t COMPREPLY < <("${COMP_WORDS[0]}" completion --complete bash -- "${COMP_WORDS[@]:1:COMP_CWORD}")
|
||||
}
|
||||
complete -o bashdefault -o default -F __%[1]s_complete_bash %[1]s
|
||||
`, p.Name)
|
||||
|
||||
case "fish":
|
||||
scriptPath = fmt.Sprintf("fish/vendor_completions.d/%s.fish", p.Name)
|
||||
script = fmt.Sprintf(`function __fish_%[1]s_complete
|
||||
set -l args (commandline -opc) (commandline -ct)
|
||||
set -e args[1]
|
||||
%[1]s completion --complete fish -- $args
|
||||
end
|
||||
complete -c %[1]s -a "(__fish_%[1]s_complete)"
|
||||
`, p.Name)
|
||||
|
||||
case "zsh":
|
||||
scriptPath = fmt.Sprintf("zsh/site-functions/_%s", p.Name)
|
||||
script = fmt.Sprintf(`#compdef %[1]s
|
||||
_%[1]s() {
|
||||
local -a completions
|
||||
completions=(${(f)"$("${words[1]}" completion --complete zsh -- "${words[@]:1:$((CURRENT-1))}")"})
|
||||
if (( ${#completions[@]} )); then
|
||||
_describe 'completions' completions
|
||||
else
|
||||
_default
|
||||
fi
|
||||
}
|
||||
compdef _%[1]s %[1]s
|
||||
if [ "$funcstack[1]" = "_%[1]s" ]; then
|
||||
_%[1]s
|
||||
fi
|
||||
`, p.Name)
|
||||
|
||||
case "":
|
||||
AbortWithUsage("Shell is not specified")
|
||||
default:
|
||||
AbortWith("Shell %q is not supported yet. Choose: bash, fish, zsh", shell)
|
||||
}
|
||||
|
||||
return scriptPath, script
|
||||
}
|
||||
|
||||
func (p Program) handleCompletionAndExit(args, completeArgs []string, opts completionOptions) {
|
||||
writer := p.OutWriter
|
||||
if writer == nil {
|
||||
writer = os.Stdout
|
||||
}
|
||||
buffer := bufio.NewWriter(writer)
|
||||
defer buffer.Flush()
|
||||
|
||||
var shell string
|
||||
if len(args) > 0 {
|
||||
shell = args[0]
|
||||
}
|
||||
|
||||
if !opts.Complete {
|
||||
scriptPath, script := p.generateShellCompletionScript(shell)
|
||||
if opts.Install {
|
||||
dataHomeDir := os.Getenv("XDG_DATA_HOME")
|
||||
if dataHomeDir == "" {
|
||||
userHomeDir, err := os.UserHomeDir()
|
||||
AbortIfError("Failed to find home", err)
|
||||
dataHomeDir = filepath.Join(userHomeDir, ".local/share")
|
||||
}
|
||||
scriptPath = filepath.Join(dataHomeDir, scriptPath)
|
||||
fmt.Fprintf(buffer, "Installing completion script: %v\n", scriptPath)
|
||||
err := os.WriteFile(scriptPath, []byte(script), 0644)
|
||||
AbortIfError("Failed to install completion script", err)
|
||||
} else {
|
||||
buffer.Write([]byte(script))
|
||||
}
|
||||
Abort(AbortDetails{})
|
||||
}
|
||||
|
||||
var lastArg string
|
||||
var result map[string]string
|
||||
if len(completeArgs) > 0 {
|
||||
lastArg = completeArgs[len(completeArgs)-1]
|
||||
}
|
||||
|
||||
if delim := slices.Index(completeArgs, "--"); delim >= 0 && delim != len(completeArgs)-1 {
|
||||
// No completion for pass-through arguments after "--"
|
||||
} else if len(lastArg) > 0 && lastArg[0] == '-' {
|
||||
// Complete flags
|
||||
cmd := &p.DefaultCommand
|
||||
for i := range p.Commands {
|
||||
if p.Commands[i].Name == completeArgs[0] {
|
||||
cmd = &p.Commands[i]
|
||||
break
|
||||
}
|
||||
}
|
||||
result = cmd.Flags.Completion(lastArg)
|
||||
} else if len(completeArgs) <= 1 {
|
||||
// Complete commands
|
||||
result = make(map[string]string, len(p.Commands)+1)
|
||||
for _, cmd := range append(p.Commands, p.DefaultCommand) {
|
||||
if strings.HasPrefix(cmd.Name, lastArg) {
|
||||
result[cmd.Name] = cmd.Usage
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
width := 0
|
||||
for suggest := range result {
|
||||
width = max(width, len(suggest))
|
||||
}
|
||||
|
||||
for _, suggest := range slices.Sorted(maps.Keys(result)) {
|
||||
usage := result[suggest]
|
||||
switch {
|
||||
case shell == "bash" && usage != "" && len(result) > 1:
|
||||
fmt.Fprintf(buffer, "%*s (%s)\n", -width-2, suggest, usage)
|
||||
case shell == "fish":
|
||||
fmt.Fprintf(buffer, "%s\t%s\n", suggest, usage)
|
||||
case shell == "zsh":
|
||||
fmt.Fprintf(buffer, "%s:%s\n", suggest, usage)
|
||||
default:
|
||||
fmt.Fprintln(buffer, suggest)
|
||||
}
|
||||
}
|
||||
|
||||
Abort(AbortDetails{})
|
||||
}
|
||||
|
||||
func (p Program) EmitUsage(writer io.Writer) {
|
||||
fmt.Fprintln(writer, formatter.F(p.Heading))
|
||||
fmt.Fprintln(writer, formatter.F("{{gray}}%s{{/}}", strings.Repeat("-", len(p.Heading))))
|
||||
|
||||
1
vendor/github.com/onsi/ginkgo/v2/ginkgo/main.go
generated
vendored
1
vendor/github.com/onsi/ginkgo/v2/ginkgo/main.go
generated
vendored
@@ -41,6 +41,7 @@ func main() {
|
||||
{Name: "nodot", Deprecation: types.Deprecations.Nodot()},
|
||||
},
|
||||
}
|
||||
program.Commands = append(program.Commands, program.BuildCompletionCommand())
|
||||
|
||||
program.RunAndExit(os.Args)
|
||||
}
|
||||
|
||||
4
vendor/github.com/onsi/ginkgo/v2/ginkgo_t_dsl.go
generated
vendored
4
vendor/github.com/onsi/ginkgo/v2/ginkgo_t_dsl.go
generated
vendored
@@ -72,6 +72,7 @@ type GinkgoTInterface interface {
|
||||
TempDir() string
|
||||
Attr(key, value string)
|
||||
Output() io.Writer
|
||||
ArtifactDir() string
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -196,3 +197,6 @@ func (g *GinkgoTBWrapper) Attr(key, value string) {
|
||||
func (g *GinkgoTBWrapper) Output() io.Writer {
|
||||
return g.GinkgoT.Output()
|
||||
}
|
||||
func (g *GinkgoTBWrapper) ArtifactDir() string {
|
||||
return g.GinkgoT.ArtifactDir()
|
||||
}
|
||||
|
||||
9
vendor/github.com/onsi/ginkgo/v2/internal/testingtproxy/testing_t_proxy.go
generated
vendored
9
vendor/github.com/onsi/ginkgo/v2/internal/testingtproxy/testing_t_proxy.go
generated
vendored
@@ -181,6 +181,15 @@ func (t *ginkgoTestingTProxy) TempDir() string {
|
||||
return tmpDir
|
||||
}
|
||||
|
||||
func (t *ginkgoTestingTProxy) ArtifactDir() string {
|
||||
artifactDir, err := os.MkdirTemp("", "ginkgo")
|
||||
if err != nil {
|
||||
t.fail(fmt.Sprintf("Failed to create artifact directory: %v", err), 1)
|
||||
return ""
|
||||
}
|
||||
return artifactDir
|
||||
}
|
||||
|
||||
// FullGinkgoTInterface
|
||||
func (t *ginkgoTestingTProxy) AddReportEntryVisibilityAlways(name string, args ...any) {
|
||||
finalArgs := []any{internal.Offset(1), types.ReportEntryVisibilityAlways}
|
||||
|
||||
3
vendor/github.com/onsi/ginkgo/v2/types/config.go
generated
vendored
3
vendor/github.com/onsi/ginkgo/v2/types/config.go
generated
vendored
@@ -215,6 +215,7 @@ type GoFlagsConfig struct {
|
||||
N bool
|
||||
ModFile string
|
||||
ModCacheRW bool
|
||||
ASan bool
|
||||
MSan bool
|
||||
PkgDir string
|
||||
Tags string
|
||||
@@ -570,6 +571,8 @@ var GoBuildFlags = GinkgoFlags{
|
||||
Usage: "leave newly-created directories in the module cache read-write instead of making them read-only."},
|
||||
{KeyPath: "Go.ModFile", Name: "modfile", UsageArgument: "file", SectionKey: "go-build",
|
||||
Usage: `in module aware mode, read (and possibly write) an alternate go.mod file instead of the one in the module root directory. A file named go.mod must still be present in order to determine the module root directory, but it is not accessed. When -modfile is specified, an alternate go.sum file is also used: its path is derived from the -modfile flag by trimming the ".mod" extension and appending ".sum".`},
|
||||
{KeyPath: "Go.ASan", Name: "asan", SectionKey: "go-build",
|
||||
Usage: "enable interoperation with address sanitizer."},
|
||||
{KeyPath: "Go.MSan", Name: "msan", SectionKey: "go-build",
|
||||
Usage: "enable interoperation with memory sanitizer. Supported only on linux/amd64, linux/arm64 and only with Clang/LLVM as the host C compiler. On linux/arm64, pie build mode will be used."},
|
||||
{KeyPath: "Go.N", Name: "n", SectionKey: "go-build",
|
||||
|
||||
18
vendor/github.com/onsi/ginkgo/v2/types/flags.go
generated
vendored
18
vendor/github.com/onsi/ginkgo/v2/types/flags.go
generated
vendored
@@ -212,6 +212,24 @@ func (f GinkgoFlagSet) IsZero() bool {
|
||||
return f.flagSet == nil
|
||||
}
|
||||
|
||||
func (f GinkgoFlagSet) Completion(arg string) map[string]string {
|
||||
if f.IsZero() {
|
||||
return nil
|
||||
}
|
||||
prefix := strings.TrimLeft(arg, "-")
|
||||
dash := arg[:len(arg)-len(prefix)]
|
||||
if len(dash) < 1 || len(dash) > 3 {
|
||||
return nil
|
||||
}
|
||||
result := make(map[string]string, len(f.flags))
|
||||
for _, flag := range f.flags {
|
||||
if flag.Name != "" && strings.HasPrefix(flag.Name, prefix) {
|
||||
result[dash+flag.Name] = flag.Usage
|
||||
}
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
func (f GinkgoFlagSet) WasSet(name string) bool {
|
||||
found := false
|
||||
f.flagSet.Visit(func(f *flag.Flag) {
|
||||
|
||||
2
vendor/github.com/onsi/ginkgo/v2/types/version.go
generated
vendored
2
vendor/github.com/onsi/ginkgo/v2/types/version.go
generated
vendored
@@ -1,3 +1,3 @@
|
||||
package types
|
||||
|
||||
const VERSION = "2.28.1"
|
||||
const VERSION = "2.28.3"
|
||||
|
||||
13
vendor/golang.org/x/net/http2/hpack/tables.go
generated
vendored
13
vendor/golang.org/x/net/http2/hpack/tables.go
generated
vendored
@@ -6,6 +6,7 @@ package hpack
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
)
|
||||
|
||||
// headerFieldTable implements a list of HeaderFields.
|
||||
@@ -54,10 +55,16 @@ func (t *headerFieldTable) len() int {
|
||||
|
||||
// addEntry adds a new entry.
|
||||
func (t *headerFieldTable) addEntry(f HeaderField) {
|
||||
// Prevent f from escaping to the heap.
|
||||
f2 := HeaderField{
|
||||
Name: strings.Clone(f.Name),
|
||||
Value: strings.Clone(f.Value),
|
||||
Sensitive: f.Sensitive,
|
||||
}
|
||||
id := uint64(t.len()) + t.evictCount + 1
|
||||
t.byName[f.Name] = id
|
||||
t.byNameValue[pairNameValue{f.Name, f.Value}] = id
|
||||
t.ents = append(t.ents, f)
|
||||
t.byName[f2.Name] = id
|
||||
t.byNameValue[pairNameValue{f2.Name, f2.Value}] = id
|
||||
t.ents = append(t.ents, f2)
|
||||
}
|
||||
|
||||
// evictOldest evicts the n oldest entries in the table.
|
||||
|
||||
9
vendor/golang.org/x/net/http2/transport.go
generated
vendored
9
vendor/golang.org/x/net/http2/transport.go
generated
vendored
@@ -718,9 +718,6 @@ func canRetryError(err error) bool {
|
||||
}
|
||||
|
||||
func (t *Transport) dialClientConn(ctx context.Context, addr string, singleUse bool) (*ClientConn, error) {
|
||||
if t.transportTestHooks != nil {
|
||||
return t.newClientConn(nil, singleUse, nil)
|
||||
}
|
||||
host, _, err := net.SplitHostPort(addr)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -2861,6 +2858,9 @@ func (rl *clientConnReadLoop) processSettingsNoWrite(f *SettingsFrame) error {
|
||||
|
||||
var seenMaxConcurrentStreams bool
|
||||
err := f.ForeachSetting(func(s Setting) error {
|
||||
if err := s.Valid(); err != nil {
|
||||
return err
|
||||
}
|
||||
switch s.ID {
|
||||
case SettingMaxFrameSize:
|
||||
cc.maxFrameSize = s.Val
|
||||
@@ -2892,9 +2892,6 @@ func (rl *clientConnReadLoop) processSettingsNoWrite(f *SettingsFrame) error {
|
||||
cc.henc.SetMaxDynamicTableSize(s.Val)
|
||||
cc.peerMaxHeaderTableSize = s.Val
|
||||
case SettingEnableConnectProtocol:
|
||||
if err := s.Valid(); err != nil {
|
||||
return err
|
||||
}
|
||||
// If the peer wants to send us SETTINGS_ENABLE_CONNECT_PROTOCOL,
|
||||
// we require that it do so in the first SETTINGS frame.
|
||||
//
|
||||
|
||||
2
vendor/golang.org/x/tools/go/types/objectpath/objectpath.go
generated
vendored
2
vendor/golang.org/x/tools/go/types/objectpath/objectpath.go
generated
vendored
@@ -524,7 +524,7 @@ func (f *finder) find(T types.Type, path []byte) []byte {
|
||||
for i := 0; i < T.NumMethods(); i++ {
|
||||
m := T.Method(i)
|
||||
if f.seenMethods[m] {
|
||||
return nil
|
||||
continue // break cycles (see TestIssue70418)
|
||||
}
|
||||
path2 := appendOpArg(path, opMethod, i)
|
||||
if m == f.obj {
|
||||
|
||||
@@ -35,6 +35,10 @@ type pkgReader struct {
|
||||
|
||||
// laterFns holds functions that need to be invoked at the end of
|
||||
// import reading.
|
||||
//
|
||||
// TODO(mdempsky): Is it safe to have a single "later" slice or do
|
||||
// we need to have multiple passes? See comments on CL 386002 and
|
||||
// go.dev/issue/52104.
|
||||
laterFns []func()
|
||||
// laterFors is used in case of 'type A B' to ensure that B is processed before A.
|
||||
laterFors map[types.Type]int
|
||||
@@ -158,12 +162,11 @@ type reader struct {
|
||||
// A readerDict holds the state for type parameters that parameterize
|
||||
// the current unified IR element.
|
||||
type readerDict struct {
|
||||
// bounds is a slice of typeInfos corresponding to the underlying
|
||||
// bounds of the element's type parameters.
|
||||
bounds []typeInfo
|
||||
rtbounds []typeInfo // contains constraint types for each parameter in rtparams
|
||||
rtparams []*types.TypeParam // contains receiver type parameters for an element
|
||||
|
||||
// tparams is a slice of the constructed TypeParams for the element.
|
||||
tparams []*types.TypeParam
|
||||
tbounds []typeInfo // contains constraint types for each parameter in tparams
|
||||
tparams []*types.TypeParam // contains type parameters for an element
|
||||
|
||||
// derived is a slice of types derived from tparams, which may be
|
||||
// instantiated while reading the current element.
|
||||
@@ -353,7 +356,11 @@ func (r *reader) doTyp() (res types.Type) {
|
||||
return name.Type()
|
||||
|
||||
case pkgbits.TypeTypeParam:
|
||||
return r.dict.tparams[r.Len()]
|
||||
n := r.Len()
|
||||
if n < len(r.dict.rtbounds) {
|
||||
return r.dict.rtparams[n]
|
||||
}
|
||||
return r.dict.tparams[n-len(r.dict.rtbounds)]
|
||||
|
||||
case pkgbits.TypeArray:
|
||||
len := int64(r.Uint64())
|
||||
@@ -534,7 +541,7 @@ func (pr *pkgReader) objIdx(idx pkgbits.Index) (*types.Package, string) {
|
||||
pos := r.pos()
|
||||
var tparams []*types.TypeParam
|
||||
if r.Version().Has(pkgbits.AliasTypeParamNames) {
|
||||
tparams = r.typeParamNames()
|
||||
tparams = r.typeParamNames(false)
|
||||
}
|
||||
typ := r.typ()
|
||||
declare(aliases.New(pos, objPkg, objName, typ, tparams))
|
||||
@@ -547,8 +554,15 @@ func (pr *pkgReader) objIdx(idx pkgbits.Index) (*types.Package, string) {
|
||||
|
||||
case pkgbits.ObjFunc:
|
||||
pos := r.pos()
|
||||
tparams := r.typeParamNames()
|
||||
sig := r.signature(nil, nil, tparams)
|
||||
var rtparams []*types.TypeParam
|
||||
var recv *types.Var
|
||||
if r.Version().Has(pkgbits.GenericMethods) && r.Bool() {
|
||||
r.selector()
|
||||
rtparams = r.typeParamNames(true)
|
||||
recv = r.param()
|
||||
}
|
||||
tparams := r.typeParamNames(false)
|
||||
sig := r.signature(recv, rtparams, tparams)
|
||||
declare(types.NewFunc(pos, objPkg, objName, sig))
|
||||
|
||||
case pkgbits.ObjType:
|
||||
@@ -558,7 +572,7 @@ func (pr *pkgReader) objIdx(idx pkgbits.Index) (*types.Package, string) {
|
||||
named := types.NewNamed(obj, nil, nil)
|
||||
declare(obj)
|
||||
|
||||
named.SetTypeParams(r.typeParamNames())
|
||||
named.SetTypeParams(r.typeParamNames(false))
|
||||
|
||||
setUnderlying := func(underlying types.Type) {
|
||||
// If the underlying type is an interface, we need to
|
||||
@@ -638,9 +652,20 @@ func (pr *pkgReader) objDictIdx(idx pkgbits.Index) *readerDict {
|
||||
errorf("unexpected object with %v implicit type parameter(s)", implicits)
|
||||
}
|
||||
|
||||
dict.bounds = make([]typeInfo, r.Len())
|
||||
for i := range dict.bounds {
|
||||
dict.bounds[i] = r.typInfo()
|
||||
nreceivers := 0
|
||||
if r.Version().Has(pkgbits.GenericMethods) && r.Bool() {
|
||||
nreceivers = r.Len()
|
||||
}
|
||||
nexplicits := r.Len()
|
||||
|
||||
dict.rtbounds = make([]typeInfo, nreceivers)
|
||||
for i := range dict.rtbounds {
|
||||
dict.rtbounds[i] = r.typInfo()
|
||||
}
|
||||
|
||||
dict.tbounds = make([]typeInfo, nexplicits)
|
||||
for i := range dict.tbounds {
|
||||
dict.tbounds[i] = r.typInfo()
|
||||
}
|
||||
|
||||
dict.derived = make([]derivedInfo, r.Len())
|
||||
@@ -659,15 +684,24 @@ func (pr *pkgReader) objDictIdx(idx pkgbits.Index) *readerDict {
|
||||
return &dict
|
||||
}
|
||||
|
||||
func (r *reader) typeParamNames() []*types.TypeParam {
|
||||
func (r *reader) typeParamNames(isGenMeth bool) []*types.TypeParam {
|
||||
r.Sync(pkgbits.SyncTypeParamNames)
|
||||
|
||||
// Note: This code assumes it only processes objects without
|
||||
// implement type parameters. This is currently fine, because
|
||||
// reader is only used to read in exported declarations, which are
|
||||
// always package scoped.
|
||||
// Note: This code assumes there are no implicit type parameters.
|
||||
// This is fine since it only reads exported declarations, which
|
||||
// never have implicits.
|
||||
|
||||
if len(r.dict.bounds) == 0 {
|
||||
var in []typeInfo
|
||||
var out *[]*types.TypeParam
|
||||
if isGenMeth {
|
||||
in = r.dict.rtbounds
|
||||
out = &r.dict.rtparams
|
||||
} else {
|
||||
in = r.dict.tbounds
|
||||
out = &r.dict.tparams
|
||||
}
|
||||
|
||||
if len(in) == 0 {
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -676,40 +710,34 @@ func (r *reader) typeParamNames() []*types.TypeParam {
|
||||
// create all the TypeNames and TypeParams, then we construct and
|
||||
// set the bound type.
|
||||
|
||||
r.dict.tparams = make([]*types.TypeParam, len(r.dict.bounds))
|
||||
for i := range r.dict.bounds {
|
||||
// We have to save tparams outside of the closure, because typeParamNames
|
||||
// can be called multiple times with the same dictionary instance.
|
||||
tparams := make([]*types.TypeParam, len(in))
|
||||
*out = tparams
|
||||
|
||||
for i := range in {
|
||||
pos := r.pos()
|
||||
pkg, name := r.localIdent()
|
||||
|
||||
tname := types.NewTypeName(pos, pkg, name, nil)
|
||||
r.dict.tparams[i] = types.NewTypeParam(tname, nil)
|
||||
tparams[i] = types.NewTypeParam(tname, nil)
|
||||
}
|
||||
|
||||
typs := make([]types.Type, len(r.dict.bounds))
|
||||
for i, bound := range r.dict.bounds {
|
||||
typs[i] = r.p.typIdx(bound, r.dict)
|
||||
// The reader dictionary will continue mutating before we have time
|
||||
// to call delayed functions; make a local copy of the constraints.
|
||||
types := make([]types.Type, len(in))
|
||||
for i, info := range in {
|
||||
types[i] = r.p.typIdx(info, r.dict)
|
||||
}
|
||||
|
||||
// TODO(mdempsky): This is subtle, elaborate further.
|
||||
//
|
||||
// We have to save tparams outside of the closure, because
|
||||
// typeParamNames() can be called multiple times with the same
|
||||
// dictionary instance.
|
||||
//
|
||||
// Also, this needs to happen later to make sure SetUnderlying has
|
||||
// been called.
|
||||
//
|
||||
// TODO(mdempsky): Is it safe to have a single "later" slice or do
|
||||
// we need to have multiple passes? See comments on CL 386002 and
|
||||
// go.dev/issue/52104.
|
||||
tparams := r.dict.tparams
|
||||
// This needs to happen later to make sure SetUnderlying has been called.
|
||||
r.p.later(func() {
|
||||
for i, typ := range typs {
|
||||
for i, typ := range types {
|
||||
tparams[i].SetConstraint(typ)
|
||||
}
|
||||
})
|
||||
|
||||
return r.dict.tparams
|
||||
return tparams
|
||||
}
|
||||
|
||||
func (r *reader) method() *types.Func {
|
||||
@@ -717,7 +745,7 @@ func (r *reader) method() *types.Func {
|
||||
pos := r.pos()
|
||||
pkg, name := r.selector()
|
||||
|
||||
rparams := r.typeParamNames()
|
||||
rparams := r.typeParamNames(false)
|
||||
sig := r.signature(r.param(), rparams, nil)
|
||||
|
||||
_ = r.pos() // TODO(mdempsky): Remove; this is a hacker for linker.go.
|
||||
3
vendor/golang.org/x/tools/internal/gocommand/version.go
generated
vendored
3
vendor/golang.org/x/tools/internal/gocommand/version.go
generated
vendored
@@ -26,6 +26,9 @@ func GoVersion(ctx context.Context, inv Invocation, r *Runner) (int, error) {
|
||||
inv.BuildFlags = nil // This is not a build command.
|
||||
inv.ModFlag = ""
|
||||
inv.ModFile = ""
|
||||
// Set GO111MODULE=off so that we are immune to errors in go.{work,mod}.
|
||||
// Unfortunately, this breaks the Go 1.21+ toolchain directive and
|
||||
// may affect the set of ReleaseTags; see #68495.
|
||||
inv.Env = append(inv.Env[:len(inv.Env):len(inv.Env)], "GO111MODULE=off")
|
||||
|
||||
stdoutBytes, err := r.Run(ctx, inv)
|
||||
|
||||
100
vendor/golang.org/x/tools/internal/imports/source_modindex.go
generated
vendored
100
vendor/golang.org/x/tools/internal/imports/source_modindex.go
generated
vendored
@@ -1,100 +0,0 @@
|
||||
// Copyright 2024 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.
|
||||
|
||||
package imports
|
||||
|
||||
import (
|
||||
"context"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"golang.org/x/tools/internal/modindex"
|
||||
)
|
||||
|
||||
// This code is here rather than in the modindex package
|
||||
// to avoid import loops
|
||||
|
||||
// TODO(adonovan): this code is only used by a test in this package.
|
||||
// Can we delete it? Or is there a plan to call NewIndexSource from
|
||||
// cmd/goimports?
|
||||
|
||||
// implements Source using modindex, so only for module cache.
|
||||
//
|
||||
// this is perhaps over-engineered. A new Index is read at first use.
|
||||
// And then Update is called after every 15 minutes, and a new Index
|
||||
// is read if the index changed. It is not clear the Mutex is needed.
|
||||
type IndexSource struct {
|
||||
modcachedir string
|
||||
mu sync.Mutex
|
||||
index *modindex.Index // (access via getIndex)
|
||||
expires time.Time
|
||||
}
|
||||
|
||||
// create a new Source. Called from NewView in cache/session.go.
|
||||
func NewIndexSource(cachedir string) *IndexSource {
|
||||
return &IndexSource{modcachedir: cachedir}
|
||||
}
|
||||
|
||||
func (s *IndexSource) LoadPackageNames(ctx context.Context, srcDir string, paths []ImportPath) (map[ImportPath]PackageName, error) {
|
||||
/// This is used by goimports to resolve the package names of imports of the
|
||||
// current package, which is irrelevant for the module cache.
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
func (s *IndexSource) ResolveReferences(ctx context.Context, filename string, missing References) ([]*Result, error) {
|
||||
index, err := s.getIndex()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
var cs []modindex.Candidate
|
||||
for pkg, nms := range missing {
|
||||
for nm := range nms {
|
||||
x := index.Lookup(pkg, nm, false)
|
||||
cs = append(cs, x...)
|
||||
}
|
||||
}
|
||||
found := make(map[string]*Result)
|
||||
for _, c := range cs {
|
||||
var x *Result
|
||||
if x = found[c.ImportPath]; x == nil {
|
||||
x = &Result{
|
||||
Import: &ImportInfo{
|
||||
ImportPath: c.ImportPath,
|
||||
Name: "",
|
||||
},
|
||||
Package: &PackageInfo{
|
||||
Name: c.PkgName,
|
||||
Exports: make(map[string]bool),
|
||||
},
|
||||
}
|
||||
found[c.ImportPath] = x
|
||||
}
|
||||
x.Package.Exports[c.Name] = true
|
||||
}
|
||||
var ans []*Result
|
||||
for _, x := range found {
|
||||
ans = append(ans, x)
|
||||
}
|
||||
return ans, nil
|
||||
}
|
||||
|
||||
func (s *IndexSource) getIndex() (*modindex.Index, error) {
|
||||
s.mu.Lock()
|
||||
defer s.mu.Unlock()
|
||||
|
||||
// (s.index = nil => s.expires is zero,
|
||||
// so the first condition is strictly redundant.
|
||||
// But it makes the postcondition very clear.)
|
||||
if s.index == nil || time.Now().After(s.expires) {
|
||||
index, err := modindex.Update(s.modcachedir)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
s.index = index
|
||||
s.expires = index.ValidAt.Add(15 * time.Minute) // (refresh period)
|
||||
}
|
||||
// Inv: s.index != nil
|
||||
|
||||
return s.index, nil
|
||||
}
|
||||
131
vendor/golang.org/x/tools/internal/modindex/directories.go
generated
vendored
131
vendor/golang.org/x/tools/internal/modindex/directories.go
generated
vendored
@@ -1,131 +0,0 @@
|
||||
// Copyright 2024 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.
|
||||
|
||||
package modindex
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"log"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"regexp"
|
||||
"strings"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"golang.org/x/mod/semver"
|
||||
"golang.org/x/tools/internal/gopathwalk"
|
||||
)
|
||||
|
||||
type directory struct {
|
||||
path string // relative to GOMODCACHE
|
||||
importPath string
|
||||
version string // semantic version
|
||||
}
|
||||
|
||||
// bestDirByImportPath returns the best directory for each import
|
||||
// path, where "best" means most recent semantic version. These import
|
||||
// paths are inferred from the GOMODCACHE-relative dir names in dirs.
|
||||
func bestDirByImportPath(dirs []string) (map[string]directory, error) {
|
||||
dirsByPath := make(map[string]directory)
|
||||
for _, dir := range dirs {
|
||||
importPath, version, err := dirToImportPathVersion(dir)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
new := directory{
|
||||
path: dir,
|
||||
importPath: importPath,
|
||||
version: version,
|
||||
}
|
||||
if old, ok := dirsByPath[importPath]; !ok || compareDirectory(new, old) < 0 {
|
||||
dirsByPath[importPath] = new
|
||||
}
|
||||
}
|
||||
return dirsByPath, nil
|
||||
}
|
||||
|
||||
// compareDirectory defines an ordering of path@version directories,
|
||||
// by descending version, then by ascending path.
|
||||
func compareDirectory(x, y directory) int {
|
||||
if sign := -semver.Compare(x.version, y.version); sign != 0 {
|
||||
return sign // latest first
|
||||
}
|
||||
return strings.Compare(string(x.path), string(y.path))
|
||||
}
|
||||
|
||||
// modCacheRegexp splits a relpathpath into module, module version, and package.
|
||||
var modCacheRegexp = regexp.MustCompile(`(.*)@([^/\\]*)(.*)`)
|
||||
|
||||
// dirToImportPathVersion computes import path and semantic version
|
||||
// from a GOMODCACHE-relative directory name.
|
||||
func dirToImportPathVersion(dir string) (string, string, error) {
|
||||
m := modCacheRegexp.FindStringSubmatch(string(dir))
|
||||
// m[1] is the module path
|
||||
// m[2] is the version major.minor.patch(-<pre release identifier)
|
||||
// m[3] is the rest of the package path
|
||||
if len(m) != 4 {
|
||||
return "", "", fmt.Errorf("bad dir %s", dir)
|
||||
}
|
||||
if !semver.IsValid(m[2]) {
|
||||
return "", "", fmt.Errorf("bad semantic version %s", m[2])
|
||||
}
|
||||
// ToSlash is required to convert Windows file paths
|
||||
// into Go package import paths.
|
||||
return filepath.ToSlash(m[1] + m[3]), m[2], nil
|
||||
}
|
||||
|
||||
// findDirs returns an unordered list of relevant package directories,
|
||||
// relative to the specified module cache root. The result includes only
|
||||
// module dirs whose mtime is within (start, end).
|
||||
func findDirs(root string, start, end time.Time) []string {
|
||||
var (
|
||||
resMu sync.Mutex
|
||||
res []string
|
||||
)
|
||||
|
||||
addDir := func(root gopathwalk.Root, dir string) {
|
||||
// TODO(pjw): do we need to check times?
|
||||
resMu.Lock()
|
||||
defer resMu.Unlock()
|
||||
res = append(res, relative(root.Path, dir))
|
||||
}
|
||||
|
||||
skipDir := func(_ gopathwalk.Root, dir string) bool {
|
||||
// The cache directory is already ignored in gopathwalk.
|
||||
if filepath.Base(dir) == "internal" {
|
||||
return true
|
||||
}
|
||||
|
||||
// Skip toolchains.
|
||||
if strings.Contains(dir, "toolchain@") {
|
||||
return true
|
||||
}
|
||||
|
||||
// Don't look inside @ directories that are too old/new.
|
||||
if strings.Contains(filepath.Base(dir), "@") {
|
||||
st, err := os.Stat(dir)
|
||||
if err != nil {
|
||||
log.Printf("can't stat dir %s %v", dir, err)
|
||||
return true
|
||||
}
|
||||
mtime := st.ModTime()
|
||||
return mtime.Before(start) || mtime.After(end)
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
// TODO(adonovan): parallelize this. Even with a hot buffer cache,
|
||||
// find $(go env GOMODCACHE) -type d
|
||||
// can easily take up a minute.
|
||||
roots := []gopathwalk.Root{{Path: root, Type: gopathwalk.RootModuleCache}}
|
||||
gopathwalk.WalkSkip(roots, addDir, skipDir, gopathwalk.Options{
|
||||
ModulesEnabled: true,
|
||||
Concurrency: 1, // TODO(pjw): adjust concurrency
|
||||
// Logf: log.Printf,
|
||||
})
|
||||
|
||||
return res
|
||||
}
|
||||
292
vendor/golang.org/x/tools/internal/modindex/index.go
generated
vendored
292
vendor/golang.org/x/tools/internal/modindex/index.go
generated
vendored
@@ -1,292 +0,0 @@
|
||||
// Copyright 2024 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.
|
||||
|
||||
package modindex
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
"crypto/sha256"
|
||||
"encoding/csv"
|
||||
"fmt"
|
||||
"io"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strconv"
|
||||
"strings"
|
||||
"testing"
|
||||
"time"
|
||||
)
|
||||
|
||||
/*
|
||||
The on-disk index ("payload") is a text file.
|
||||
The first 3 lines are header information containing CurrentVersion,
|
||||
the value of GOMODCACHE, and the validity date of the index.
|
||||
(This is when the code started building the index.)
|
||||
Following the header are sections of lines, one section for each
|
||||
import path. These sections are sorted by package name.
|
||||
The first line of each section, marked by a leading :, contains
|
||||
the package name, the import path, the name of the directory relative
|
||||
to GOMODCACHE, and its semantic version.
|
||||
The rest of each section consists of one line per exported symbol.
|
||||
The lines are sorted by the symbol's name and contain the name,
|
||||
an indication of its lexical type (C, T, V, F), and if it is the
|
||||
name of a function, information about the signature.
|
||||
|
||||
The fields in the section header lines are separated by commas, and
|
||||
in the unlikely event this would be confusing, the csv package is used
|
||||
to write (and read) them.
|
||||
|
||||
In the lines containing exported names, C=const, V=var, T=type, F=func.
|
||||
If it is a func, the next field is the number of returned values,
|
||||
followed by pairs consisting of formal parameter names and types.
|
||||
All these fields are separated by spaces. Any spaces in a type
|
||||
(e.g., chan struct{}) are replaced by $s on the disk. The $s are
|
||||
turned back into spaces when read.
|
||||
|
||||
Here is an index header (the comments are not part of the index):
|
||||
0 // version (of the index format)
|
||||
/usr/local/google/home/pjw/go/pkg/mod // GOMODCACHE
|
||||
2024-09-11 18:55:09 // validity date of the index
|
||||
|
||||
Here is an index section:
|
||||
:yaml,gopkg.in/yaml.v1,gopkg.in/yaml.v1@v1.0.0-20140924161607-9f9df34309c0,v1.0.0-20140924161607-9f9df34309c0
|
||||
Getter T
|
||||
Marshal F 2 in interface{}
|
||||
Setter T
|
||||
Unmarshal F 1 in []byte out interface{}
|
||||
|
||||
The package name is yaml, the import path is gopkg.in/yaml.v1.
|
||||
Getter and Setter are types, and Marshal and Unmarshal are functions.
|
||||
The latter returns one value and has two arguments, 'in' and 'out'
|
||||
whose types are []byte and interface{}.
|
||||
*/
|
||||
|
||||
// CurrentVersion tells readers about the format of the index.
|
||||
const CurrentVersion int = 0
|
||||
|
||||
// Index is returned by [Read].
|
||||
type Index struct {
|
||||
Version int
|
||||
GOMODCACHE string // absolute path of Go module cache dir
|
||||
ValidAt time.Time // moment at which the index was up to date
|
||||
Entries []Entry
|
||||
}
|
||||
|
||||
func (ix *Index) String() string {
|
||||
return fmt.Sprintf("Index(%s v%d has %d entries at %v)",
|
||||
ix.GOMODCACHE, ix.Version, len(ix.Entries), ix.ValidAt)
|
||||
}
|
||||
|
||||
// An Entry contains information for an import path.
|
||||
type Entry struct {
|
||||
Dir string // package directory relative to GOMODCACHE; uses OS path separator
|
||||
ImportPath string
|
||||
PkgName string
|
||||
Version string
|
||||
Names []string // exported names and information
|
||||
}
|
||||
|
||||
// IndexDir is where the module index is stored.
|
||||
// Each logical index entry consists of a pair of files:
|
||||
//
|
||||
// - the "payload" (index-VERSION-XXX), whose name is
|
||||
// randomized, holds the actual index; and
|
||||
// - the "link" (index-name-VERSION-HASH),
|
||||
// whose name is predictable, contains the
|
||||
// name of the payload file.
|
||||
//
|
||||
// Since the link file is small (<512B),
|
||||
// reads and writes to it may be assumed atomic.
|
||||
var IndexDir string = func() string {
|
||||
var dir string
|
||||
if testing.Testing() {
|
||||
dir = os.TempDir()
|
||||
} else {
|
||||
var err error
|
||||
dir, err = os.UserCacheDir()
|
||||
// shouldn't happen, but TempDir is better than
|
||||
// creating ./goimports
|
||||
if err != nil {
|
||||
dir = os.TempDir()
|
||||
}
|
||||
}
|
||||
dir = filepath.Join(dir, "goimports")
|
||||
if err := os.MkdirAll(dir, 0777); err != nil {
|
||||
dir = "" // #75505, people complain about the error message
|
||||
}
|
||||
return dir
|
||||
}()
|
||||
|
||||
// Read reads the latest version of the on-disk index
|
||||
// for the specified Go module cache directory.
|
||||
// If there is no index, it returns a nil Index and an fs.ErrNotExist error.
|
||||
func Read(gomodcache string) (*Index, error) {
|
||||
gomodcache, err := filepath.Abs(gomodcache)
|
||||
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.
|
||||
content, err := os.ReadFile(filepath.Join(IndexDir, linkFileBasename(gomodcache)))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
payloadFile := filepath.Join(IndexDir, string(content))
|
||||
|
||||
// Read the index out of the payload file.
|
||||
f, err := os.Open(payloadFile)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer f.Close()
|
||||
return readIndexFrom(gomodcache, bufio.NewReader(f))
|
||||
}
|
||||
|
||||
func readIndexFrom(gomodcache string, r io.Reader) (*Index, error) {
|
||||
scan := bufio.NewScanner(r)
|
||||
|
||||
// version
|
||||
if !scan.Scan() {
|
||||
return nil, fmt.Errorf("unexpected scan error: %v", scan.Err())
|
||||
}
|
||||
version, err := strconv.Atoi(scan.Text())
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if version != CurrentVersion {
|
||||
return nil, fmt.Errorf("got version %d, expected %d", version, CurrentVersion)
|
||||
}
|
||||
|
||||
// gomodcache
|
||||
if !scan.Scan() {
|
||||
return nil, fmt.Errorf("scanner error reading module cache dir: %v", scan.Err())
|
||||
}
|
||||
// TODO(pjw): need to check that this is the expected cache dir
|
||||
// so the tag should be passed in to this function
|
||||
if dir := string(scan.Text()); dir != gomodcache {
|
||||
return nil, fmt.Errorf("index file GOMODCACHE mismatch: got %q, want %q", dir, gomodcache)
|
||||
}
|
||||
|
||||
// changed
|
||||
if !scan.Scan() {
|
||||
return nil, fmt.Errorf("scanner error reading index creation time: %v", scan.Err())
|
||||
}
|
||||
changed, err := time.ParseInLocation(time.DateTime, scan.Text(), time.Local)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// entries
|
||||
var (
|
||||
curEntry *Entry
|
||||
entries []Entry
|
||||
)
|
||||
for scan.Scan() {
|
||||
v := scan.Text()
|
||||
if v[0] == ':' {
|
||||
if curEntry != nil {
|
||||
entries = append(entries, *curEntry)
|
||||
}
|
||||
// as directories may contain commas and quotes, they need to be read as csv.
|
||||
rdr := strings.NewReader(v[1:])
|
||||
cs := csv.NewReader(rdr)
|
||||
flds, err := cs.Read()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if len(flds) != 4 {
|
||||
return nil, fmt.Errorf("header contains %d fields, not 4: %q", len(v), v)
|
||||
}
|
||||
curEntry = &Entry{
|
||||
PkgName: flds[0],
|
||||
ImportPath: flds[1],
|
||||
Dir: relative(gomodcache, flds[2]),
|
||||
Version: flds[3],
|
||||
}
|
||||
continue
|
||||
}
|
||||
curEntry.Names = append(curEntry.Names, v)
|
||||
}
|
||||
if err := scan.Err(); err != nil {
|
||||
return nil, fmt.Errorf("scanner failed while reading modindex entry: %v", err)
|
||||
}
|
||||
if curEntry != nil {
|
||||
entries = append(entries, *curEntry)
|
||||
}
|
||||
|
||||
return &Index{
|
||||
Version: version,
|
||||
GOMODCACHE: gomodcache,
|
||||
ValidAt: changed,
|
||||
Entries: entries,
|
||||
}, nil
|
||||
}
|
||||
|
||||
// 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 {
|
||||
return err // e.g. disk full, or index dir deleted
|
||||
}
|
||||
if err := writeIndexToFile(ix, bufio.NewWriter(f)); err != nil {
|
||||
_ = f.Close() // ignore error
|
||||
return err
|
||||
}
|
||||
if err := f.Close(); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// Write the name of the payload file into a link file.
|
||||
indexDirFile := filepath.Join(IndexDir, linkFileBasename(gomodcache))
|
||||
content := []byte(filepath.Base(f.Name()))
|
||||
return os.WriteFile(indexDirFile, content, 0666)
|
||||
}
|
||||
|
||||
func writeIndexToFile(x *Index, w *bufio.Writer) error {
|
||||
fmt.Fprintf(w, "%d\n", x.Version)
|
||||
fmt.Fprintf(w, "%s\n", x.GOMODCACHE)
|
||||
tm := x.ValidAt.Truncate(time.Second) // round the time down
|
||||
fmt.Fprintf(w, "%s\n", tm.Format(time.DateTime))
|
||||
for _, e := range x.Entries {
|
||||
if e.ImportPath == "" {
|
||||
continue // shouldn't happen
|
||||
}
|
||||
// PJW: maybe always write these headers as csv?
|
||||
if strings.ContainsAny(string(e.Dir), ",\"") {
|
||||
cw := csv.NewWriter(w)
|
||||
cw.Write([]string{":" + e.PkgName, e.ImportPath, string(e.Dir), e.Version})
|
||||
cw.Flush()
|
||||
} else {
|
||||
fmt.Fprintf(w, ":%s,%s,%s,%s\n", e.PkgName, e.ImportPath, e.Dir, e.Version)
|
||||
}
|
||||
for _, x := range e.Names {
|
||||
fmt.Fprintf(w, "%s\n", x)
|
||||
}
|
||||
}
|
||||
return w.Flush()
|
||||
}
|
||||
|
||||
// linkFileBasename returns the base name of the link file in the
|
||||
// index directory that holds the name of the payload file for the
|
||||
// specified (absolute) Go module cache dir.
|
||||
func linkFileBasename(gomodcache string) string {
|
||||
// Note: coupled to logic in ./gomodindex/cmd.go. TODO: factor.
|
||||
h := sha256.Sum256([]byte(gomodcache)) // collision-resistant hash
|
||||
return fmt.Sprintf("index-name-%d-%032x", CurrentVersion, h)
|
||||
}
|
||||
|
||||
func relative(base, file string) string {
|
||||
if rel, err := filepath.Rel(base, file); err == nil {
|
||||
return rel
|
||||
}
|
||||
return file
|
||||
}
|
||||
184
vendor/golang.org/x/tools/internal/modindex/lookup.go
generated
vendored
184
vendor/golang.org/x/tools/internal/modindex/lookup.go
generated
vendored
@@ -1,184 +0,0 @@
|
||||
// Copyright 2024 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.
|
||||
|
||||
package modindex
|
||||
|
||||
import (
|
||||
"slices"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"golang.org/x/mod/module"
|
||||
)
|
||||
|
||||
type Candidate struct {
|
||||
PkgName string
|
||||
Name string
|
||||
Dir string
|
||||
ImportPath string
|
||||
Type LexType
|
||||
Deprecated bool
|
||||
// information for Funcs
|
||||
Results int16 // how many results
|
||||
Sig []Field // arg names and types
|
||||
}
|
||||
|
||||
type Field struct {
|
||||
Arg, Type string
|
||||
}
|
||||
|
||||
type LexType int8
|
||||
|
||||
const (
|
||||
Const LexType = iota
|
||||
Var
|
||||
Type
|
||||
Func
|
||||
)
|
||||
|
||||
// LookupAll only returns those Candidates whose import path
|
||||
// finds all the names.
|
||||
func (ix *Index) LookupAll(pkgName string, names ...string) map[string][]Candidate {
|
||||
// this can be made faster when benchmarks show that it needs to be
|
||||
names = uniquify(names)
|
||||
byImpPath := make(map[string][]Candidate)
|
||||
for _, nm := range names {
|
||||
cands := ix.Lookup(pkgName, nm, false)
|
||||
for _, c := range cands {
|
||||
byImpPath[c.ImportPath] = append(byImpPath[c.ImportPath], c)
|
||||
}
|
||||
}
|
||||
for k, v := range byImpPath {
|
||||
if len(v) != len(names) {
|
||||
delete(byImpPath, k)
|
||||
}
|
||||
}
|
||||
return byImpPath
|
||||
}
|
||||
|
||||
// remove duplicates
|
||||
func uniquify(in []string) []string {
|
||||
if len(in) == 0 {
|
||||
return in
|
||||
}
|
||||
in = slices.Clone(in)
|
||||
slices.Sort(in)
|
||||
return slices.Compact(in)
|
||||
}
|
||||
|
||||
// Lookup finds all the symbols in the index with the given PkgName and name.
|
||||
// If prefix is true, it finds all of these with name as a prefix.
|
||||
func (ix *Index) Lookup(pkgName, name string, prefix bool) []Candidate {
|
||||
loc, ok := slices.BinarySearchFunc(ix.Entries, pkgName, func(e Entry, pkg string) int {
|
||||
return strings.Compare(e.PkgName, pkgName)
|
||||
})
|
||||
if !ok {
|
||||
return nil // didn't find the package
|
||||
}
|
||||
var ans []Candidate
|
||||
// loc is the first entry for this package name, but there may be several
|
||||
for i := loc; i < len(ix.Entries); i++ {
|
||||
e := ix.Entries[i]
|
||||
if e.PkgName != pkgName {
|
||||
break // end of sorted package names
|
||||
}
|
||||
nloc, ok := slices.BinarySearchFunc(e.Names, name, func(s string, name string) int {
|
||||
if strings.HasPrefix(s, name) {
|
||||
return 0
|
||||
}
|
||||
if s < name {
|
||||
return -1
|
||||
}
|
||||
return 1
|
||||
})
|
||||
if !ok {
|
||||
continue // didn't find the name, nor any symbols with name as a prefix
|
||||
}
|
||||
for j := nloc; j < len(e.Names); j++ {
|
||||
nstr := e.Names[j]
|
||||
// benchmarks show this makes a difference when there are a lot of Possibilities
|
||||
flds := fastSplit(nstr)
|
||||
if !(flds[0] == name || prefix && strings.HasPrefix(flds[0], name)) {
|
||||
// past range of matching Names
|
||||
break
|
||||
}
|
||||
if len(flds) < 2 {
|
||||
continue // should never happen
|
||||
}
|
||||
impPath, err := module.UnescapePath(e.ImportPath)
|
||||
if err != nil {
|
||||
continue
|
||||
}
|
||||
px := Candidate{
|
||||
PkgName: pkgName,
|
||||
Name: flds[0],
|
||||
Dir: string(e.Dir),
|
||||
ImportPath: impPath,
|
||||
Type: asLexType(flds[1][0]),
|
||||
Deprecated: len(flds[1]) > 1 && flds[1][1] == 'D',
|
||||
}
|
||||
if px.Type == Func {
|
||||
n, err := strconv.Atoi(flds[2])
|
||||
if err != nil {
|
||||
continue // should never happen
|
||||
}
|
||||
px.Results = int16(n)
|
||||
if len(flds) >= 4 {
|
||||
sig := strings.Split(flds[3], " ")
|
||||
for i := range sig {
|
||||
// $ cannot otherwise occur. removing the spaces
|
||||
// almost works, but for chan struct{}, e.g.
|
||||
sig[i] = strings.Replace(sig[i], "$", " ", -1)
|
||||
}
|
||||
px.Sig = toFields(sig)
|
||||
}
|
||||
}
|
||||
ans = append(ans, px)
|
||||
}
|
||||
}
|
||||
return ans
|
||||
}
|
||||
|
||||
func toFields(sig []string) []Field {
|
||||
ans := make([]Field, len(sig)/2)
|
||||
for i := range ans {
|
||||
ans[i] = Field{Arg: sig[2*i], Type: sig[2*i+1]}
|
||||
}
|
||||
return ans
|
||||
}
|
||||
|
||||
// benchmarks show this is measurably better than strings.Split
|
||||
// split into first 4 fields separated by single space
|
||||
func fastSplit(x string) []string {
|
||||
ans := make([]string, 0, 4)
|
||||
nxt := 0
|
||||
start := 0
|
||||
for i := 0; i < len(x); i++ {
|
||||
if x[i] != ' ' {
|
||||
continue
|
||||
}
|
||||
ans = append(ans, x[start:i])
|
||||
nxt++
|
||||
start = i + 1
|
||||
if nxt >= 3 {
|
||||
break
|
||||
}
|
||||
}
|
||||
ans = append(ans, x[start:])
|
||||
return ans
|
||||
}
|
||||
|
||||
func asLexType(c byte) LexType {
|
||||
switch c {
|
||||
case 'C':
|
||||
return Const
|
||||
case 'V':
|
||||
return Var
|
||||
case 'T':
|
||||
return Type
|
||||
case 'F':
|
||||
return Func
|
||||
}
|
||||
return -1
|
||||
}
|
||||
119
vendor/golang.org/x/tools/internal/modindex/modindex.go
generated
vendored
119
vendor/golang.org/x/tools/internal/modindex/modindex.go
generated
vendored
@@ -1,119 +0,0 @@
|
||||
// Copyright 2024 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.
|
||||
|
||||
// Package modindex contains code for building and searching an
|
||||
// [Index] of the Go module cache.
|
||||
package modindex
|
||||
|
||||
// The directory containing the index, returned by
|
||||
// [IndexDir], contains a file index-name-<ver> that contains the name
|
||||
// of the current index. We believe writing that short file is atomic.
|
||||
// [Read] reads that file to get the file name of the index.
|
||||
// WriteIndex writes an index with a unique name and then
|
||||
// writes that name into a new version of index-name-<ver>.
|
||||
// (<ver> stands for the CurrentVersion of the index format.)
|
||||
|
||||
import (
|
||||
"maps"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"slices"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"golang.org/x/mod/semver"
|
||||
)
|
||||
|
||||
// Update updates the index for the specified Go
|
||||
// module cache directory, creating it as needed.
|
||||
// On success it returns the current index.
|
||||
func Update(gomodcache string) (*Index, error) {
|
||||
prev, err := Read(gomodcache)
|
||||
if err != nil {
|
||||
if !os.IsNotExist(err) {
|
||||
return nil, err
|
||||
}
|
||||
prev = nil
|
||||
}
|
||||
return update(gomodcache, prev)
|
||||
}
|
||||
|
||||
// update builds, writes, and returns the current index.
|
||||
//
|
||||
// If old is nil, the new index is built from all of GOMODCACHE;
|
||||
// otherwise it is built from the old index plus cache updates
|
||||
// since the previous index's time.
|
||||
func update(gomodcache string, old *Index) (*Index, error) {
|
||||
gomodcache, err := filepath.Abs(gomodcache)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
new, changed, err := build(gomodcache, old)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if old == nil || changed {
|
||||
if err := write(gomodcache, new); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
return new, nil
|
||||
}
|
||||
|
||||
// build returns a new index for the specified Go module cache (an
|
||||
// absolute path).
|
||||
//
|
||||
// If an old index is provided, only directories more recent than it
|
||||
// that it are scanned; older directories are provided by the old
|
||||
// Index.
|
||||
//
|
||||
// The boolean result indicates whether new entries were found.
|
||||
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
|
||||
}
|
||||
now := time.Now()
|
||||
end := now.Add(24 * time.Hour) // safely in the future
|
||||
|
||||
// Enumerate GOMODCACHE package directories.
|
||||
// Choose the best (latest) package for each import path.
|
||||
pkgDirs := findDirs(gomodcache, start, end)
|
||||
dirByPath, err := bestDirByImportPath(pkgDirs)
|
||||
if err != nil {
|
||||
return nil, false, err
|
||||
}
|
||||
|
||||
// For each import path it might occur only in
|
||||
// dirByPath, only in old, or in both.
|
||||
// If both, use the semantically later one.
|
||||
var entries []Entry
|
||||
if old != nil {
|
||||
for _, entry := range old.Entries {
|
||||
dir, ok := dirByPath[entry.ImportPath]
|
||||
if !ok || semver.Compare(dir.version, entry.Version) <= 0 {
|
||||
// New dir is missing or not more recent; use old entry.
|
||||
entries = append(entries, entry)
|
||||
delete(dirByPath, entry.ImportPath)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Extract symbol information for all the new directories.
|
||||
newEntries := extractSymbols(gomodcache, maps.Values(dirByPath))
|
||||
entries = append(entries, newEntries...)
|
||||
slices.SortFunc(entries, func(x, y Entry) int {
|
||||
if n := strings.Compare(x.PkgName, y.PkgName); n != 0 {
|
||||
return n
|
||||
}
|
||||
return strings.Compare(x.ImportPath, y.ImportPath)
|
||||
})
|
||||
|
||||
return &Index{
|
||||
GOMODCACHE: gomodcache,
|
||||
ValidAt: now, // time before the directories were scanned
|
||||
Entries: entries,
|
||||
}, len(newEntries) > 0, nil
|
||||
}
|
||||
244
vendor/golang.org/x/tools/internal/modindex/symbols.go
generated
vendored
244
vendor/golang.org/x/tools/internal/modindex/symbols.go
generated
vendored
@@ -1,244 +0,0 @@
|
||||
// Copyright 2024 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.
|
||||
|
||||
package modindex
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"go/ast"
|
||||
"go/parser"
|
||||
"go/token"
|
||||
"go/types"
|
||||
"iter"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"runtime"
|
||||
"slices"
|
||||
"strings"
|
||||
"sync"
|
||||
|
||||
"golang.org/x/sync/errgroup"
|
||||
)
|
||||
|
||||
// The name of a symbol contains information about the symbol:
|
||||
// <name> T for types, TD if the type is deprecated
|
||||
// <name> C for consts, CD if the const is deprecated
|
||||
// <name> V for vars, VD if the var is deprecated
|
||||
// and for funcs: <name> F <num of return values> (<arg-name> <arg-type>)*
|
||||
// any spaces in <arg-type> are replaced by $s so that the fields
|
||||
// of the name are space separated. F is replaced by FD if the func
|
||||
// is deprecated.
|
||||
type symbol struct {
|
||||
pkg string // name of the symbols's package
|
||||
name string // declared name
|
||||
kind string // T, C, V, or F, followed by D if deprecated
|
||||
sig string // signature information, for F
|
||||
}
|
||||
|
||||
// extractSymbols returns a (new, unordered) array of Entries, one for
|
||||
// each provided package directory, describing its exported symbols.
|
||||
func extractSymbols(cwd string, dirs iter.Seq[directory]) []Entry {
|
||||
var (
|
||||
mu sync.Mutex
|
||||
entries []Entry
|
||||
)
|
||||
|
||||
var g errgroup.Group
|
||||
g.SetLimit(max(2, runtime.GOMAXPROCS(0)/2))
|
||||
for dir := range dirs {
|
||||
g.Go(func() error {
|
||||
thedir := filepath.Join(cwd, string(dir.path))
|
||||
mode := parser.SkipObjectResolution | parser.ParseComments
|
||||
|
||||
// Parse all Go files in dir and extract symbols.
|
||||
dirents, err := os.ReadDir(thedir)
|
||||
if err != nil {
|
||||
return nil // log this someday?
|
||||
}
|
||||
var syms []symbol
|
||||
for _, dirent := range dirents {
|
||||
if !strings.HasSuffix(dirent.Name(), ".go") ||
|
||||
strings.HasSuffix(dirent.Name(), "_test.go") {
|
||||
continue
|
||||
}
|
||||
fname := filepath.Join(thedir, dirent.Name())
|
||||
tr, err := parser.ParseFile(token.NewFileSet(), fname, nil, mode)
|
||||
if err != nil {
|
||||
continue // ignore errors, someday log them?
|
||||
}
|
||||
syms = append(syms, getFileExports(tr)...)
|
||||
}
|
||||
|
||||
// Create an entry for the package.
|
||||
pkg, names := processSyms(syms)
|
||||
if pkg != "" {
|
||||
mu.Lock()
|
||||
defer mu.Unlock()
|
||||
entries = append(entries, Entry{
|
||||
PkgName: pkg,
|
||||
Dir: dir.path,
|
||||
ImportPath: dir.importPath,
|
||||
Version: dir.version,
|
||||
Names: names,
|
||||
})
|
||||
}
|
||||
|
||||
return nil
|
||||
})
|
||||
}
|
||||
g.Wait() // ignore error
|
||||
|
||||
return entries
|
||||
}
|
||||
|
||||
func getFileExports(f *ast.File) []symbol {
|
||||
pkg := f.Name.Name
|
||||
if pkg == "main" || pkg == "" {
|
||||
return nil
|
||||
}
|
||||
var ans []symbol
|
||||
// should we look for //go:build ignore?
|
||||
for _, decl := range f.Decls {
|
||||
switch decl := decl.(type) {
|
||||
case *ast.FuncDecl:
|
||||
if decl.Recv != nil {
|
||||
// ignore methods, as we are completing package selections
|
||||
continue
|
||||
}
|
||||
name := decl.Name.Name
|
||||
dtype := decl.Type
|
||||
// not looking at dtype.TypeParams. That is, treating
|
||||
// generic functions just like non-generic ones.
|
||||
sig := dtype.Params
|
||||
kind := "F"
|
||||
if isDeprecated(decl.Doc) {
|
||||
kind += "D"
|
||||
}
|
||||
result := []string{fmt.Sprintf("%d", dtype.Results.NumFields())}
|
||||
for _, x := range sig.List {
|
||||
// This code creates a string representing the type.
|
||||
// TODO(pjw): it may be fragile:
|
||||
// 1. x.Type could be nil, perhaps in ill-formed code
|
||||
// 2. ExprString might someday change incompatibly to
|
||||
// include struct tags, which can be arbitrary strings
|
||||
if x.Type == nil {
|
||||
// Can this happen without a parse error? (Files with parse
|
||||
// errors are ignored in getSymbols)
|
||||
continue // maybe report this someday
|
||||
}
|
||||
tp := types.ExprString(x.Type)
|
||||
if len(tp) == 0 {
|
||||
// Can this happen?
|
||||
continue // maybe report this someday
|
||||
}
|
||||
// This is only safe if ExprString never returns anything with a $
|
||||
// The only place a $ can occur seems to be in a struct tag, which
|
||||
// can be an arbitrary string literal, and ExprString does not presently
|
||||
// print struct tags. So for this to happen the type of a formal parameter
|
||||
// has to be a explicit struct, e.g. foo(x struct{a int "$"}) and ExprString
|
||||
// would have to show the struct tag. Even testing for this case seems
|
||||
// a waste of effort, but let's remember the possibility
|
||||
if strings.Contains(tp, "$") {
|
||||
continue
|
||||
}
|
||||
tp = strings.Replace(tp, " ", "$", -1)
|
||||
if len(x.Names) == 0 {
|
||||
result = append(result, "_")
|
||||
result = append(result, tp)
|
||||
} else {
|
||||
for _, y := range x.Names {
|
||||
result = append(result, y.Name)
|
||||
result = append(result, tp)
|
||||
}
|
||||
}
|
||||
}
|
||||
sigs := strings.Join(result, " ")
|
||||
if s := newsym(pkg, name, kind, sigs); s != nil {
|
||||
ans = append(ans, *s)
|
||||
}
|
||||
case *ast.GenDecl:
|
||||
depr := isDeprecated(decl.Doc)
|
||||
switch decl.Tok {
|
||||
case token.CONST, token.VAR:
|
||||
tp := "V"
|
||||
if decl.Tok == token.CONST {
|
||||
tp = "C"
|
||||
}
|
||||
if depr {
|
||||
tp += "D"
|
||||
}
|
||||
for _, sp := range decl.Specs {
|
||||
for _, x := range sp.(*ast.ValueSpec).Names {
|
||||
if s := newsym(pkg, x.Name, tp, ""); s != nil {
|
||||
ans = append(ans, *s)
|
||||
}
|
||||
}
|
||||
}
|
||||
case token.TYPE:
|
||||
tp := "T"
|
||||
if depr {
|
||||
tp += "D"
|
||||
}
|
||||
for _, sp := range decl.Specs {
|
||||
if s := newsym(pkg, sp.(*ast.TypeSpec).Name.Name, tp, ""); s != nil {
|
||||
ans = append(ans, *s)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return ans
|
||||
}
|
||||
|
||||
func newsym(pkg, name, kind, sig string) *symbol {
|
||||
if len(name) == 0 || !ast.IsExported(name) {
|
||||
return nil
|
||||
}
|
||||
sym := symbol{pkg: pkg, name: name, kind: kind, sig: sig}
|
||||
return &sym
|
||||
}
|
||||
|
||||
func isDeprecated(doc *ast.CommentGroup) bool {
|
||||
if doc == nil {
|
||||
return false
|
||||
}
|
||||
// go.dev/wiki/Deprecated Paragraph starting 'Deprecated:'
|
||||
// This code fails for /* Deprecated: */, but it's the code from
|
||||
// gopls/internal/analysis/deprecated
|
||||
for line := range strings.SplitSeq(doc.Text(), "\n\n") {
|
||||
if strings.HasPrefix(line, "Deprecated:") {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
// return the package name and the value for the symbols.
|
||||
// if there are multiple packages, choose one arbitrarily
|
||||
// the returned slice is sorted lexicographically
|
||||
func processSyms(syms []symbol) (string, []string) {
|
||||
if len(syms) == 0 {
|
||||
return "", nil
|
||||
}
|
||||
slices.SortFunc(syms, func(l, r symbol) int {
|
||||
return strings.Compare(l.name, r.name)
|
||||
})
|
||||
pkg := syms[0].pkg
|
||||
var names []string
|
||||
for _, s := range syms {
|
||||
if s.pkg != pkg {
|
||||
// Symbols came from two files in same dir
|
||||
// with different package declarations.
|
||||
continue
|
||||
}
|
||||
var nx string
|
||||
if s.sig != "" {
|
||||
nx = fmt.Sprintf("%s %s %s", s.name, s.kind, s.sig)
|
||||
} else {
|
||||
nx = fmt.Sprintf("%s %s", s.name, s.kind)
|
||||
}
|
||||
names = append(names, nx)
|
||||
}
|
||||
return pkg, names
|
||||
}
|
||||
17
vendor/golang.org/x/tools/internal/pkgbits/version.go
generated
vendored
17
vendor/golang.org/x/tools/internal/pkgbits/version.go
generated
vendored
@@ -28,6 +28,15 @@ const (
|
||||
// - remove derived info "needed" bool
|
||||
V2
|
||||
|
||||
// V3: introduces a more compact format for composite literal element lists
|
||||
// - negative lengths indicate that (some) elements may have keys
|
||||
// - positive lengths indicate that no element has a key
|
||||
// - a negative struct field index indicates an embedded field
|
||||
V3
|
||||
|
||||
// V4: encodes generic methods as standalone function objects
|
||||
V4
|
||||
|
||||
numVersions = iota
|
||||
)
|
||||
|
||||
@@ -61,6 +70,12 @@ const (
|
||||
// whether a type was a derived type.
|
||||
DerivedInfoNeeded
|
||||
|
||||
// Composite literals use a more compact format for element lists.
|
||||
CompactCompLiterals
|
||||
|
||||
// Generic methods may appear as standalone function objects.
|
||||
GenericMethods
|
||||
|
||||
numFields = iota
|
||||
)
|
||||
|
||||
@@ -68,6 +83,8 @@ const (
|
||||
var introduced = [numFields]Version{
|
||||
Flags: V1,
|
||||
AliasTypeParamNames: V2,
|
||||
CompactCompLiterals: V3,
|
||||
GenericMethods: V4,
|
||||
}
|
||||
|
||||
// removed is the version a field was removed in or 0 for fields
|
||||
|
||||
8
vendor/golang.org/x/tools/internal/typeparams/coretype.go
generated
vendored
8
vendor/golang.org/x/tools/internal/typeparams/coretype.go
generated
vendored
@@ -11,7 +11,9 @@ import (
|
||||
|
||||
// CoreType returns the core type of T or nil if T does not have a core type.
|
||||
//
|
||||
// See https://go.dev/ref/spec#Core_types for the definition of a core type.
|
||||
// As of Go1.25, the notion of a core type has been removed from the language spec.
|
||||
// See https://go.dev/blog/coretypes for more details.
|
||||
// TODO(mkalil): We should eventually consider removing all uses of CoreType.
|
||||
func CoreType(T types.Type) types.Type {
|
||||
U := T.Underlying()
|
||||
if _, ok := U.(*types.Interface); !ok {
|
||||
@@ -34,7 +36,7 @@ func CoreType(T types.Type) types.Type {
|
||||
}
|
||||
|
||||
if identical == len(terms) {
|
||||
// https://go.dev/ref/spec#Core_types
|
||||
// From the deprecated core types spec:
|
||||
// "There is a single type U which is the underlying type of all types in the type set of T"
|
||||
return U
|
||||
}
|
||||
@@ -42,7 +44,7 @@ func CoreType(T types.Type) types.Type {
|
||||
if !ok {
|
||||
return nil // no core type as identical < len(terms) and U is not a channel.
|
||||
}
|
||||
// https://go.dev/ref/spec#Core_types
|
||||
// From the deprecated core types spec:
|
||||
// "the type chan E if T contains only bidirectional channels, or the type chan<- E or
|
||||
// <-chan E depending on the direction of the directional channels present."
|
||||
for chans := identical; chans < len(terms); chans++ {
|
||||
|
||||
48
vendor/golang.org/x/tools/internal/typesinternal/types.go
generated
vendored
48
vendor/golang.org/x/tools/internal/typesinternal/types.go
generated
vendored
@@ -194,3 +194,51 @@ func Imports(pkg *types.Package, path string) bool {
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
// ObjectKind returns a description of the object's kind.
|
||||
//
|
||||
// from objectKind in go/types
|
||||
func ObjectKind(obj types.Object) string {
|
||||
switch obj := obj.(type) {
|
||||
case *types.PkgName:
|
||||
return "package name"
|
||||
case *types.Const:
|
||||
return "constant"
|
||||
case *types.TypeName:
|
||||
if obj.IsAlias() {
|
||||
return "type alias"
|
||||
} else if _, ok := obj.Type().(*types.TypeParam); ok {
|
||||
return "type parameter"
|
||||
} else {
|
||||
return "defined type"
|
||||
}
|
||||
case *types.Var:
|
||||
switch obj.Kind() {
|
||||
case PackageVar:
|
||||
return "package-level variable"
|
||||
case LocalVar:
|
||||
return "local variable"
|
||||
case RecvVar:
|
||||
return "receiver"
|
||||
case ParamVar:
|
||||
return "parameter"
|
||||
case ResultVar:
|
||||
return "result variable"
|
||||
case FieldVar:
|
||||
return "struct field"
|
||||
}
|
||||
case *types.Func:
|
||||
if obj.Signature().Recv() != nil {
|
||||
return "method"
|
||||
} else {
|
||||
return "function"
|
||||
}
|
||||
case *types.Label:
|
||||
return "label"
|
||||
case *types.Builtin:
|
||||
return "built-in function"
|
||||
case *types.Nil:
|
||||
return "untyped nil"
|
||||
}
|
||||
return "unknown symbol"
|
||||
}
|
||||
|
||||
1
vendor/golang.org/x/tools/internal/versions/features.go
generated
vendored
1
vendor/golang.org/x/tools/internal/versions/features.go
generated
vendored
@@ -19,6 +19,7 @@ const (
|
||||
Go1_24 = "go1.24"
|
||||
Go1_25 = "go1.25"
|
||||
Go1_26 = "go1.26"
|
||||
Go1_27 = "go1.27"
|
||||
)
|
||||
|
||||
// Future is an invalid unknown Go version sometime in the future.
|
||||
|
||||
13
vendor/modules.txt
vendored
13
vendor/modules.txt
vendored
@@ -731,7 +731,7 @@ github.com/google/go-tika/tika
|
||||
github.com/google/go-tpm/legacy/tpm2
|
||||
github.com/google/go-tpm/tpmutil
|
||||
github.com/google/go-tpm/tpmutil/tbs
|
||||
# github.com/google/pprof v0.0.0-20260115054156-294ebfa9ad83
|
||||
# github.com/google/pprof v0.0.0-20260402051712-545e8a4df936
|
||||
## explicit; go 1.24.0
|
||||
github.com/google/pprof/profile
|
||||
# github.com/google/renameio/v2 v2.0.2
|
||||
@@ -1249,8 +1249,8 @@ github.com/onsi/ginkgo/reporters/stenographer
|
||||
github.com/onsi/ginkgo/reporters/stenographer/support/go-colorable
|
||||
github.com/onsi/ginkgo/reporters/stenographer/support/go-isatty
|
||||
github.com/onsi/ginkgo/types
|
||||
# github.com/onsi/ginkgo/v2 v2.28.1
|
||||
## explicit; go 1.24.0
|
||||
# github.com/onsi/ginkgo/v2 v2.28.3
|
||||
## explicit; go 1.25.0
|
||||
github.com/onsi/ginkgo/v2
|
||||
github.com/onsi/ginkgo/v2/config
|
||||
github.com/onsi/ginkgo/v2/formatter
|
||||
@@ -2468,12 +2468,12 @@ golang.org/x/image/vector
|
||||
golang.org/x/image/vp8
|
||||
golang.org/x/image/vp8l
|
||||
golang.org/x/image/webp
|
||||
# golang.org/x/mod v0.34.0
|
||||
# golang.org/x/mod v0.35.0
|
||||
## explicit; go 1.25.0
|
||||
golang.org/x/mod/internal/lazyregexp
|
||||
golang.org/x/mod/module
|
||||
golang.org/x/mod/semver
|
||||
# golang.org/x/net v0.52.0
|
||||
# golang.org/x/net v0.53.0
|
||||
## explicit; go 1.25.0
|
||||
golang.org/x/net/bpf
|
||||
golang.org/x/net/context
|
||||
@@ -2551,7 +2551,7 @@ golang.org/x/text/width
|
||||
# golang.org/x/time v0.15.0
|
||||
## explicit; go 1.25.0
|
||||
golang.org/x/time/rate
|
||||
# golang.org/x/tools v0.43.0
|
||||
# golang.org/x/tools v0.44.0
|
||||
## explicit; go 1.25.0
|
||||
golang.org/x/tools/cover
|
||||
golang.org/x/tools/go/ast/astutil
|
||||
@@ -2571,7 +2571,6 @@ golang.org/x/tools/internal/gcimporter
|
||||
golang.org/x/tools/internal/gocommand
|
||||
golang.org/x/tools/internal/gopathwalk
|
||||
golang.org/x/tools/internal/imports
|
||||
golang.org/x/tools/internal/modindex
|
||||
golang.org/x/tools/internal/packagesinternal
|
||||
golang.org/x/tools/internal/pkgbits
|
||||
golang.org/x/tools/internal/stdlib
|
||||
|
||||
Reference in New Issue
Block a user