mirror of
https://github.com/opencloud-eu/opencloud.git
synced 2026-03-31 13:52:10 -04:00
Bump github.com/onsi/ginkgo/v2 from 2.22.2 to 2.23.0
Bumps [github.com/onsi/ginkgo/v2](https://github.com/onsi/ginkgo) from 2.22.2 to 2.23.0. - [Release notes](https://github.com/onsi/ginkgo/releases) - [Changelog](https://github.com/onsi/ginkgo/blob/master/CHANGELOG.md) - [Commits](https://github.com/onsi/ginkgo/compare/v2.22.2...v2.23.0) --- updated-dependencies: - dependency-name: github.com/onsi/ginkgo/v2 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com>
This commit is contained in:
6
go.mod
6
go.mod
@@ -60,7 +60,7 @@ require (
|
||||
github.com/oklog/run v1.1.0
|
||||
github.com/olekukonko/tablewriter v0.0.5
|
||||
github.com/onsi/ginkgo v1.16.5
|
||||
github.com/onsi/ginkgo/v2 v2.22.2
|
||||
github.com/onsi/ginkgo/v2 v2.23.0
|
||||
github.com/onsi/gomega v1.36.2
|
||||
github.com/open-policy-agent/opa v1.1.0
|
||||
github.com/opencloud-eu/reva/v2 v2.27.3-0.20250304172421-22b1ead80cdd
|
||||
@@ -319,10 +319,10 @@ require (
|
||||
go.uber.org/atomic v1.11.0 // indirect
|
||||
go.uber.org/multierr v1.9.0 // indirect
|
||||
go.uber.org/zap v1.23.0 // indirect
|
||||
golang.org/x/mod v0.22.0 // indirect
|
||||
golang.org/x/mod v0.23.0 // indirect
|
||||
golang.org/x/sys v0.30.0 // indirect
|
||||
golang.org/x/time v0.10.0 // indirect
|
||||
golang.org/x/tools v0.28.0 // indirect
|
||||
golang.org/x/tools v0.30.0 // indirect
|
||||
golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2 // indirect
|
||||
google.golang.org/genproto v0.0.0-20241118233622-e639e219e697 // indirect
|
||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20250115164207-1a7da9e5054f // indirect
|
||||
|
||||
12
go.sum
12
go.sum
@@ -856,8 +856,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.22.2 h1:/3X8Panh8/WwhU/3Ssa6rCKqPLuAkVY2I0RoyDLySlU=
|
||||
github.com/onsi/ginkgo/v2 v2.22.2/go.mod h1:oeMosUL+8LtarXBHu/c0bx2D/K9zyQ6uX3cTyztHwsk=
|
||||
github.com/onsi/ginkgo/v2 v2.23.0 h1:FA1xjp8ieYDzlgS5ABTpdUDB7wtngggONc8a7ku2NqQ=
|
||||
github.com/onsi/ginkgo/v2 v2.23.0/go.mod h1:zXTP6xIp3U8aVuXN8ENK9IXRaTjFnpVB9mGmaSRvxnM=
|
||||
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=
|
||||
@@ -1269,8 +1269,8 @@ golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
|
||||
golang.org/x/mod v0.12.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
|
||||
golang.org/x/mod v0.15.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c=
|
||||
golang.org/x/mod v0.17.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c=
|
||||
golang.org/x/mod v0.22.0 h1:D4nJWe9zXqHOmWqj4VMOJhvzj7bEZg4wEYa759z1pH4=
|
||||
golang.org/x/mod v0.22.0/go.mod h1:6SkKJ3Xj0I0BrPOZoBy3bdMptDDU9oJrpohJ3eWZ1fY=
|
||||
golang.org/x/mod v0.23.0 h1:Zb7khfcRGKk+kqfxFaP5tZqCnDZMjC5VtUBs87Hr6QM=
|
||||
golang.org/x/mod v0.23.0/go.mod h1:6SkKJ3Xj0I0BrPOZoBy3bdMptDDU9oJrpohJ3eWZ1fY=
|
||||
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=
|
||||
@@ -1535,8 +1535,8 @@ 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.13.0/go.mod h1:HvlwmtVNQAhOuCjW7xxvovg8wbNq7LwfXh/k7wXUl58=
|
||||
golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d/go.mod h1:aiJjzUbINMkxbQROHiO6hDPo2LHcIPhhQsa9DLh0yGk=
|
||||
golang.org/x/tools v0.28.0 h1:WuB6qZ4RPCQo5aP3WdKZS7i595EdWqWR8vqJTlwTVK8=
|
||||
golang.org/x/tools v0.28.0/go.mod h1:dcIOrVd3mfQKTgrDVQHqCPMWy6lnhfhtX3hLXYVLfRw=
|
||||
golang.org/x/tools v0.30.0 h1:BgcpHewrV5AUp2G9MebG4XPFI1E2W41zU1SaqVA9vJY=
|
||||
golang.org/x/tools v0.30.0/go.mod h1:c347cR/OJfw5TI+GfX7RUPNMdDRRbjvYTS0jPyvsVtY=
|
||||
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
|
||||
25
vendor/github.com/onsi/ginkgo/v2/CHANGELOG.md
generated
vendored
25
vendor/github.com/onsi/ginkgo/v2/CHANGELOG.md
generated
vendored
@@ -1,3 +1,26 @@
|
||||
## 2.23.0
|
||||
|
||||
Ginkgo 2.23.0 adds a handful of methods to `GinkgoT()` to make it compatible with the `testing.TB` interface in Go 1.24. `GinkgoT().Context()`, in particular, is a useful shorthand for generating a new context that will clean itself up in a `DeferCleanup()`. This has subtle behavior differences from the golang implementation but should make sense in a Ginkgo... um... context.
|
||||
|
||||
### Features
|
||||
- bump to go 1.24.0 - support new testing.TB methods and add a test to cover testing.TB regressions [37a511b]
|
||||
|
||||
### Fixes
|
||||
- fix edge case where build -o is pointing at an explicit file, not a directory [7556a86]
|
||||
- Fix binary paths when precompiling multiple suites. [4df06c6]
|
||||
|
||||
### Maintenance
|
||||
- Fix: Correct Markdown list rendering in MIGRATING_TO_V2.md [cbcf39a]
|
||||
- docs: fix test workflow badge (#1512) [9b261ff]
|
||||
- Bump golang.org/x/net in /integration/_fixtures/version_mismatch_fixture (#1516) [00f19c8]
|
||||
- Bump golang.org/x/tools from 0.28.0 to 0.30.0 (#1515) [e98a4df]
|
||||
- Bump activesupport from 6.0.6.1 to 6.1.7.5 in /docs (#1504) [60cc4e2]
|
||||
- Bump github-pages from 231 to 232 in /docs (#1447) [fea6f2d]
|
||||
- Bump rexml from 3.2.8 to 3.3.9 in /docs (#1497) [31d7813]
|
||||
- Bump webrick from 1.8.1 to 1.9.1 in /docs (#1501) [fc3bbd6]
|
||||
- Code linting (#1500) [aee0d56]
|
||||
- change interface{} to any (#1502) [809a710]
|
||||
|
||||
## 2.22.2
|
||||
|
||||
### Maintenance
|
||||
@@ -630,7 +653,7 @@ Ginkgo also uses this progress reporting infrastructure under the hood when hand
|
||||
### Features
|
||||
- `BeforeSuite`, `AfterSuite`, `SynchronizedBeforeSuite`, `SynchronizedAfterSuite`, and `ReportAfterSuite` now support (the relevant subset of) decorators. These can be passed in _after_ the callback functions that are usually passed into these nodes.
|
||||
|
||||
As a result the **signature of these methods has changed** and now includes a trailing `args ...interface{}`. For most users simply using the DSL, this change is transparent. However if you were assigning one of these functions to a custom variable (or passing it around) then your code may need to change to reflect the new signature.
|
||||
As a result the **signature of these methods has changed** and now includes a trailing `args ...any`. For most users simply using the DSL, this change is transparent. However if you were assigning one of these functions to a custom variable (or passing it around) then your code may need to change to reflect the new signature.
|
||||
|
||||
### Maintenance
|
||||
- Modernize the invocation of Ginkgo in github actions [0ffde58]
|
||||
|
||||
2
vendor/github.com/onsi/ginkgo/v2/README.md
generated
vendored
2
vendor/github.com/onsi/ginkgo/v2/README.md
generated
vendored
@@ -1,6 +1,6 @@
|
||||

|
||||
|
||||
[](https://github.com/onsi/ginkgo/actions?query=workflow%3Atest+branch%3Amaster) | [Ginkgo Docs](https://onsi.github.io/ginkgo/)
|
||||
[](https://github.com/onsi/ginkgo/actions?query=workflow%3Atest+branch%3Amaster) | [Ginkgo Docs](https://onsi.github.io/ginkgo/)
|
||||
|
||||
---
|
||||
|
||||
|
||||
58
vendor/github.com/onsi/ginkgo/v2/core_dsl.go
generated
vendored
58
vendor/github.com/onsi/ginkgo/v2/core_dsl.go
generated
vendored
@@ -83,9 +83,9 @@ func exitIfErrors(errors []error) {
|
||||
type GinkgoWriterInterface interface {
|
||||
io.Writer
|
||||
|
||||
Print(a ...interface{})
|
||||
Printf(format string, a ...interface{})
|
||||
Println(a ...interface{})
|
||||
Print(a ...any)
|
||||
Printf(format string, a ...any)
|
||||
Println(a ...any)
|
||||
|
||||
TeeTo(writer io.Writer)
|
||||
ClearTeeWriters()
|
||||
@@ -243,7 +243,7 @@ for more on how specs are parallelized in Ginkgo.
|
||||
|
||||
You can also pass suite-level Label() decorators to RunSpecs. The passed-in labels will apply to all specs in the suite.
|
||||
*/
|
||||
func RunSpecs(t GinkgoTestingT, description string, args ...interface{}) bool {
|
||||
func RunSpecs(t GinkgoTestingT, description string, args ...any) bool {
|
||||
if suiteDidRun {
|
||||
exitIfErr(types.GinkgoErrors.RerunningSuite())
|
||||
}
|
||||
@@ -316,7 +316,7 @@ func RunSpecs(t GinkgoTestingT, description string, args ...interface{}) bool {
|
||||
return passed
|
||||
}
|
||||
|
||||
func extractSuiteConfiguration(args []interface{}) Labels {
|
||||
func extractSuiteConfiguration(args []any) Labels {
|
||||
suiteLabels := Labels{}
|
||||
configErrors := []error{}
|
||||
for _, arg := range args {
|
||||
@@ -491,14 +491,14 @@ to Describe the behavior of an object or function and, within that Describe, out
|
||||
You can learn more at https://onsi.github.io/ginkgo/#organizing-specs-with-container-nodes
|
||||
In addition, container nodes can be decorated with a variety of decorators. You can learn more here: https://onsi.github.io/ginkgo/#decorator-reference
|
||||
*/
|
||||
func Describe(text string, args ...interface{}) bool {
|
||||
func Describe(text string, args ...any) bool {
|
||||
return pushNode(internal.NewNode(deprecationTracker, types.NodeTypeContainer, text, args...))
|
||||
}
|
||||
|
||||
/*
|
||||
FDescribe focuses specs within the Describe block.
|
||||
*/
|
||||
func FDescribe(text string, args ...interface{}) bool {
|
||||
func FDescribe(text string, args ...any) bool {
|
||||
args = append(args, internal.Focus)
|
||||
return pushNode(internal.NewNode(deprecationTracker, types.NodeTypeContainer, text, args...))
|
||||
}
|
||||
@@ -506,7 +506,7 @@ func FDescribe(text string, args ...interface{}) bool {
|
||||
/*
|
||||
PDescribe marks specs within the Describe block as pending.
|
||||
*/
|
||||
func PDescribe(text string, args ...interface{}) bool {
|
||||
func PDescribe(text string, args ...any) bool {
|
||||
args = append(args, internal.Pending)
|
||||
return pushNode(internal.NewNode(deprecationTracker, types.NodeTypeContainer, text, args...))
|
||||
}
|
||||
@@ -522,18 +522,18 @@ var XDescribe = PDescribe
|
||||
var Context, FContext, PContext, XContext = Describe, FDescribe, PDescribe, XDescribe
|
||||
|
||||
/* When is an alias for Describe - it generates the exact same kind of Container node */
|
||||
func When(text string, args ...interface{}) bool {
|
||||
func When(text string, args ...any) bool {
|
||||
return pushNode(internal.NewNode(deprecationTracker, types.NodeTypeContainer, "when "+text, args...))
|
||||
}
|
||||
|
||||
/* When is an alias for Describe - it generates the exact same kind of Container node */
|
||||
func FWhen(text string, args ...interface{}) bool {
|
||||
func FWhen(text string, args ...any) bool {
|
||||
args = append(args, internal.Focus)
|
||||
return pushNode(internal.NewNode(deprecationTracker, types.NodeTypeContainer, "when "+text, args...))
|
||||
}
|
||||
|
||||
/* When is an alias for Describe - it generates the exact same kind of Container node */
|
||||
func PWhen(text string, args ...interface{}) bool {
|
||||
func PWhen(text string, args ...any) bool {
|
||||
args = append(args, internal.Pending)
|
||||
return pushNode(internal.NewNode(deprecationTracker, types.NodeTypeContainer, "when "+text, args...))
|
||||
}
|
||||
@@ -550,14 +550,14 @@ You can pass It nodes bare functions (func() {}) or functions that receive a Spe
|
||||
You can learn more at https://onsi.github.io/ginkgo/#spec-subjects-it
|
||||
In addition, subject nodes can be decorated with a variety of decorators. You can learn more here: https://onsi.github.io/ginkgo/#decorator-reference
|
||||
*/
|
||||
func It(text string, args ...interface{}) bool {
|
||||
func It(text string, args ...any) bool {
|
||||
return pushNode(internal.NewNode(deprecationTracker, types.NodeTypeIt, text, args...))
|
||||
}
|
||||
|
||||
/*
|
||||
FIt allows you to focus an individual It.
|
||||
*/
|
||||
func FIt(text string, args ...interface{}) bool {
|
||||
func FIt(text string, args ...any) bool {
|
||||
args = append(args, internal.Focus)
|
||||
return pushNode(internal.NewNode(deprecationTracker, types.NodeTypeIt, text, args...))
|
||||
}
|
||||
@@ -565,7 +565,7 @@ func FIt(text string, args ...interface{}) bool {
|
||||
/*
|
||||
PIt allows you to mark an individual It as pending.
|
||||
*/
|
||||
func PIt(text string, args ...interface{}) bool {
|
||||
func PIt(text string, args ...any) bool {
|
||||
args = append(args, internal.Pending)
|
||||
return pushNode(internal.NewNode(deprecationTracker, types.NodeTypeIt, text, args...))
|
||||
}
|
||||
@@ -611,8 +611,8 @@ BeforeSuite can take a func() body, or an interruptible func(SpecContext)/func(c
|
||||
You cannot nest any other Ginkgo nodes within a BeforeSuite node's closure.
|
||||
You can learn more here: https://onsi.github.io/ginkgo/#suite-setup-and-cleanup-beforesuite-and-aftersuite
|
||||
*/
|
||||
func BeforeSuite(body interface{}, args ...interface{}) bool {
|
||||
combinedArgs := []interface{}{body}
|
||||
func BeforeSuite(body any, args ...any) bool {
|
||||
combinedArgs := []any{body}
|
||||
combinedArgs = append(combinedArgs, args...)
|
||||
return pushNode(internal.NewNode(deprecationTracker, types.NodeTypeBeforeSuite, "", combinedArgs...))
|
||||
}
|
||||
@@ -630,8 +630,8 @@ AfterSuite can take a func() body, or an interruptible func(SpecContext)/func(co
|
||||
You cannot nest any other Ginkgo nodes within an AfterSuite node's closure.
|
||||
You can learn more here: https://onsi.github.io/ginkgo/#suite-setup-and-cleanup-beforesuite-and-aftersuite
|
||||
*/
|
||||
func AfterSuite(body interface{}, args ...interface{}) bool {
|
||||
combinedArgs := []interface{}{body}
|
||||
func AfterSuite(body any, args ...any) bool {
|
||||
combinedArgs := []any{body}
|
||||
combinedArgs = append(combinedArgs, args...)
|
||||
return pushNode(internal.NewNode(deprecationTracker, types.NodeTypeAfterSuite, "", combinedArgs...))
|
||||
}
|
||||
@@ -667,8 +667,8 @@ If either function receives a context.Context/SpecContext it is considered inter
|
||||
You cannot nest any other Ginkgo nodes within an SynchronizedBeforeSuite node's closure.
|
||||
You can learn more, and see some examples, here: https://onsi.github.io/ginkgo/#parallel-suite-setup-and-cleanup-synchronizedbeforesuite-and-synchronizedaftersuite
|
||||
*/
|
||||
func SynchronizedBeforeSuite(process1Body interface{}, allProcessBody interface{}, args ...interface{}) bool {
|
||||
combinedArgs := []interface{}{process1Body, allProcessBody}
|
||||
func SynchronizedBeforeSuite(process1Body any, allProcessBody any, args ...any) bool {
|
||||
combinedArgs := []any{process1Body, allProcessBody}
|
||||
combinedArgs = append(combinedArgs, args...)
|
||||
|
||||
return pushNode(internal.NewNode(deprecationTracker, types.NodeTypeSynchronizedBeforeSuite, "", combinedArgs...))
|
||||
@@ -687,8 +687,8 @@ Note that you can also use DeferCleanup() in SynchronizedBeforeSuite to accompli
|
||||
You cannot nest any other Ginkgo nodes within an SynchronizedAfterSuite node's closure.
|
||||
You can learn more, and see some examples, here: https://onsi.github.io/ginkgo/#parallel-suite-setup-and-cleanup-synchronizedbeforesuite-and-synchronizedaftersuite
|
||||
*/
|
||||
func SynchronizedAfterSuite(allProcessBody interface{}, process1Body interface{}, args ...interface{}) bool {
|
||||
combinedArgs := []interface{}{allProcessBody, process1Body}
|
||||
func SynchronizedAfterSuite(allProcessBody any, process1Body any, args ...any) bool {
|
||||
combinedArgs := []any{allProcessBody, process1Body}
|
||||
combinedArgs = append(combinedArgs, args...)
|
||||
|
||||
return pushNode(internal.NewNode(deprecationTracker, types.NodeTypeSynchronizedAfterSuite, "", combinedArgs...))
|
||||
@@ -703,7 +703,7 @@ BeforeEach can take a func() body, or an interruptible func(SpecContext)/func(co
|
||||
You cannot nest any other Ginkgo nodes within a BeforeEach node's closure.
|
||||
You can learn more here: https://onsi.github.io/ginkgo/#extracting-common-setup-beforeeach
|
||||
*/
|
||||
func BeforeEach(args ...interface{}) bool {
|
||||
func BeforeEach(args ...any) bool {
|
||||
return pushNode(internal.NewNode(deprecationTracker, types.NodeTypeBeforeEach, "", args...))
|
||||
}
|
||||
|
||||
@@ -716,7 +716,7 @@ JustBeforeEach can take a func() body, or an interruptible func(SpecContext)/fun
|
||||
You cannot nest any other Ginkgo nodes within a JustBeforeEach node's closure.
|
||||
You can learn more and see some examples here: https://onsi.github.io/ginkgo/#separating-creation-and-configuration-justbeforeeach
|
||||
*/
|
||||
func JustBeforeEach(args ...interface{}) bool {
|
||||
func JustBeforeEach(args ...any) bool {
|
||||
return pushNode(internal.NewNode(deprecationTracker, types.NodeTypeJustBeforeEach, "", args...))
|
||||
}
|
||||
|
||||
@@ -731,7 +731,7 @@ AfterEach can take a func() body, or an interruptible func(SpecContext)/func(con
|
||||
You cannot nest any other Ginkgo nodes within an AfterEach node's closure.
|
||||
You can learn more here: https://onsi.github.io/ginkgo/#spec-cleanup-aftereach-and-defercleanup
|
||||
*/
|
||||
func AfterEach(args ...interface{}) bool {
|
||||
func AfterEach(args ...any) bool {
|
||||
return pushNode(internal.NewNode(deprecationTracker, types.NodeTypeAfterEach, "", args...))
|
||||
}
|
||||
|
||||
@@ -743,7 +743,7 @@ JustAfterEach can take a func() body, or an interruptible func(SpecContext)/func
|
||||
You cannot nest any other Ginkgo nodes within a JustAfterEach node's closure.
|
||||
You can learn more and see some examples here: https://onsi.github.io/ginkgo/#separating-diagnostics-collection-and-teardown-justaftereach
|
||||
*/
|
||||
func JustAfterEach(args ...interface{}) bool {
|
||||
func JustAfterEach(args ...any) bool {
|
||||
return pushNode(internal.NewNode(deprecationTracker, types.NodeTypeJustAfterEach, "", args...))
|
||||
}
|
||||
|
||||
@@ -758,7 +758,7 @@ You cannot nest any other Ginkgo nodes within a BeforeAll node's closure.
|
||||
You can learn more about Ordered Containers at: https://onsi.github.io/ginkgo/#ordered-containers
|
||||
And you can learn more about BeforeAll at: https://onsi.github.io/ginkgo/#setup-in-ordered-containers-beforeall-and-afterall
|
||||
*/
|
||||
func BeforeAll(args ...interface{}) bool {
|
||||
func BeforeAll(args ...any) bool {
|
||||
return pushNode(internal.NewNode(deprecationTracker, types.NodeTypeBeforeAll, "", args...))
|
||||
}
|
||||
|
||||
@@ -775,7 +775,7 @@ You cannot nest any other Ginkgo nodes within an AfterAll node's closure.
|
||||
You can learn more about Ordered Containers at: https://onsi.github.io/ginkgo/#ordered-containers
|
||||
And you can learn more about AfterAll at: https://onsi.github.io/ginkgo/#setup-in-ordered-containers-beforeall-and-afterall
|
||||
*/
|
||||
func AfterAll(args ...interface{}) bool {
|
||||
func AfterAll(args ...any) bool {
|
||||
return pushNode(internal.NewNode(deprecationTracker, types.NodeTypeAfterAll, "", args...))
|
||||
}
|
||||
|
||||
@@ -818,7 +818,7 @@ When DeferCleanup is called in BeforeSuite, SynchronizedBeforeSuite, AfterSuite,
|
||||
Note that DeferCleanup does not represent a node but rather dynamically generates the appropriate type of cleanup node based on the context in which it is called. As such you must call DeferCleanup within a Setup or Subject node, and not within a Container node.
|
||||
You can learn more about DeferCleanup here: https://onsi.github.io/ginkgo/#cleaning-up-our-cleanup-code-defercleanup
|
||||
*/
|
||||
func DeferCleanup(args ...interface{}) {
|
||||
func DeferCleanup(args ...any) {
|
||||
fail := func(message string, cl types.CodeLocation) {
|
||||
global.Failer.Fail(message, cl)
|
||||
}
|
||||
|
||||
8
vendor/github.com/onsi/ginkgo/v2/deprecated_dsl.go
generated
vendored
8
vendor/github.com/onsi/ginkgo/v2/deprecated_dsl.go
generated
vendored
@@ -118,9 +118,9 @@ Use Gomega's gmeasure package instead.
|
||||
You can learn more here: https://onsi.github.io/ginkgo/#benchmarking-code
|
||||
*/
|
||||
type Benchmarker interface {
|
||||
Time(name string, body func(), info ...interface{}) (elapsedTime time.Duration)
|
||||
RecordValue(name string, value float64, info ...interface{})
|
||||
RecordValueWithPrecision(name string, value float64, units string, precision int, info ...interface{})
|
||||
Time(name string, body func(), info ...any) (elapsedTime time.Duration)
|
||||
RecordValue(name string, value float64, info ...any)
|
||||
RecordValueWithPrecision(name string, value float64, units string, precision int, info ...any)
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -129,7 +129,7 @@ Deprecated: Measure() has been removed from Ginkgo 2.0
|
||||
Use Gomega's gmeasure package instead.
|
||||
You can learn more here: https://onsi.github.io/ginkgo/#benchmarking-code
|
||||
*/
|
||||
func Measure(_ ...interface{}) bool {
|
||||
func Measure(_ ...any) bool {
|
||||
deprecationTracker.TrackDeprecation(types.Deprecations.Measure(), types.NewCodeLocation(1))
|
||||
return true
|
||||
}
|
||||
|
||||
12
vendor/github.com/onsi/ginkgo/v2/formatter/formatter.go
generated
vendored
12
vendor/github.com/onsi/ginkgo/v2/formatter/formatter.go
generated
vendored
@@ -24,15 +24,15 @@ const (
|
||||
|
||||
var SingletonFormatter = New(ColorModeTerminal)
|
||||
|
||||
func F(format string, args ...interface{}) string {
|
||||
func F(format string, args ...any) string {
|
||||
return SingletonFormatter.F(format, args...)
|
||||
}
|
||||
|
||||
func Fi(indentation uint, format string, args ...interface{}) string {
|
||||
func Fi(indentation uint, format string, args ...any) string {
|
||||
return SingletonFormatter.Fi(indentation, format, args...)
|
||||
}
|
||||
|
||||
func Fiw(indentation uint, maxWidth uint, format string, args ...interface{}) string {
|
||||
func Fiw(indentation uint, maxWidth uint, format string, args ...any) string {
|
||||
return SingletonFormatter.Fiw(indentation, maxWidth, format, args...)
|
||||
}
|
||||
|
||||
@@ -115,15 +115,15 @@ func New(colorMode ColorMode) Formatter {
|
||||
return f
|
||||
}
|
||||
|
||||
func (f Formatter) F(format string, args ...interface{}) string {
|
||||
func (f Formatter) F(format string, args ...any) string {
|
||||
return f.Fi(0, format, args...)
|
||||
}
|
||||
|
||||
func (f Formatter) Fi(indentation uint, format string, args ...interface{}) string {
|
||||
func (f Formatter) Fi(indentation uint, format string, args ...any) string {
|
||||
return f.Fiw(indentation, 0, format, args...)
|
||||
}
|
||||
|
||||
func (f Formatter) Fiw(indentation uint, maxWidth uint, format string, args ...interface{}) string {
|
||||
func (f Formatter) Fiw(indentation uint, maxWidth uint, format string, args ...any) string {
|
||||
out := f.style(format)
|
||||
if len(args) > 0 {
|
||||
out = fmt.Sprintf(out, args...)
|
||||
|
||||
14
vendor/github.com/onsi/ginkgo/v2/ginkgo/build/build_command.go
generated
vendored
14
vendor/github.com/onsi/ginkgo/v2/ginkgo/build/build_command.go
generated
vendored
@@ -55,18 +55,22 @@ func buildSpecs(args []string, cliConfig types.CLIConfig, goFlagsConfig types.Go
|
||||
if suite.State.Is(internal.TestSuiteStateFailedToCompile) {
|
||||
fmt.Println(suite.CompilationError.Error())
|
||||
} else {
|
||||
if len(goFlagsConfig.O) == 0 {
|
||||
goFlagsConfig.O = path.Join(suite.Path, suite.PackageName+".test")
|
||||
} else {
|
||||
var testBinPath string
|
||||
if len(goFlagsConfig.O) != 0 {
|
||||
stat, err := os.Stat(goFlagsConfig.O)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
if stat.IsDir() {
|
||||
goFlagsConfig.O += "/" + suite.PackageName + ".test"
|
||||
testBinPath = goFlagsConfig.O + "/" + suite.PackageName + ".test"
|
||||
} else {
|
||||
testBinPath = goFlagsConfig.O
|
||||
}
|
||||
}
|
||||
fmt.Printf("Compiled %s\n", goFlagsConfig.O)
|
||||
if len(testBinPath) == 0 {
|
||||
testBinPath = path.Join(suite.Path, suite.PackageName+".test")
|
||||
}
|
||||
fmt.Printf("Compiled %s\n", testBinPath)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
6
vendor/github.com/onsi/ginkgo/v2/ginkgo/command/abort.go
generated
vendored
6
vendor/github.com/onsi/ginkgo/v2/ginkgo/command/abort.go
generated
vendored
@@ -12,7 +12,7 @@ func Abort(details AbortDetails) {
|
||||
panic(details)
|
||||
}
|
||||
|
||||
func AbortGracefullyWith(format string, args ...interface{}) {
|
||||
func AbortGracefullyWith(format string, args ...any) {
|
||||
Abort(AbortDetails{
|
||||
ExitCode: 0,
|
||||
Error: fmt.Errorf(format, args...),
|
||||
@@ -20,7 +20,7 @@ func AbortGracefullyWith(format string, args ...interface{}) {
|
||||
})
|
||||
}
|
||||
|
||||
func AbortWith(format string, args ...interface{}) {
|
||||
func AbortWith(format string, args ...any) {
|
||||
Abort(AbortDetails{
|
||||
ExitCode: 1,
|
||||
Error: fmt.Errorf(format, args...),
|
||||
@@ -28,7 +28,7 @@ func AbortWith(format string, args ...interface{}) {
|
||||
})
|
||||
}
|
||||
|
||||
func AbortWithUsage(format string, args ...interface{}) {
|
||||
func AbortWithUsage(format string, args ...any) {
|
||||
Abort(AbortDetails{
|
||||
ExitCode: 1,
|
||||
Error: fmt.Errorf(format, args...),
|
||||
|
||||
2
vendor/github.com/onsi/ginkgo/v2/ginkgo/command/program.go
generated
vendored
2
vendor/github.com/onsi/ginkgo/v2/ginkgo/command/program.go
generated
vendored
@@ -68,7 +68,6 @@ func (p Program) RunAndExit(osArgs []string) {
|
||||
fmt.Fprintln(p.ErrWriter, deprecationTracker.DeprecationsReport())
|
||||
}
|
||||
p.Exiter(exitCode)
|
||||
return
|
||||
}()
|
||||
|
||||
args, additionalArgs := []string{}, []string{}
|
||||
@@ -157,7 +156,6 @@ func (p Program) handleHelpRequestsAndExit(writer io.Writer, args []string) {
|
||||
p.EmitUsage(writer)
|
||||
Abort(AbortDetails{ExitCode: 1})
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func (p Program) EmitUsage(writer io.Writer) {
|
||||
|
||||
2
vendor/github.com/onsi/ginkgo/v2/ginkgo/internal/gocovmerge.go
generated
vendored
2
vendor/github.com/onsi/ginkgo/v2/ginkgo/internal/gocovmerge.go
generated
vendored
@@ -89,7 +89,7 @@ func mergeProfileBlock(p *cover.Profile, pb cover.ProfileBlock, startIndex int)
|
||||
}
|
||||
|
||||
i := 0
|
||||
if sortFunc(i) != true {
|
||||
if !sortFunc(i) {
|
||||
i = sort.Search(len(p.Blocks)-startIndex, sortFunc)
|
||||
}
|
||||
|
||||
|
||||
2
vendor/github.com/onsi/ginkgo/v2/ginkgo/run/run_command.go
generated
vendored
2
vendor/github.com/onsi/ginkgo/v2/ginkgo/run/run_command.go
generated
vendored
@@ -142,7 +142,7 @@ OUTER_LOOP:
|
||||
}
|
||||
|
||||
if !endTime.IsZero() {
|
||||
r.suiteConfig.Timeout = endTime.Sub(time.Now())
|
||||
r.suiteConfig.Timeout = time.Until(endTime)
|
||||
if r.suiteConfig.Timeout <= 0 {
|
||||
suites[suiteIdx].State = internal.TestSuiteStateFailedDueToTimeout
|
||||
opc.StopAndDrain()
|
||||
|
||||
3
vendor/github.com/onsi/ginkgo/v2/ginkgo_t_dsl.go
generated
vendored
3
vendor/github.com/onsi/ginkgo/v2/ginkgo_t_dsl.go
generated
vendored
@@ -1,6 +1,7 @@
|
||||
package ginkgo
|
||||
|
||||
import (
|
||||
"context"
|
||||
"testing"
|
||||
|
||||
"github.com/onsi/ginkgo/v2/internal/testingtproxy"
|
||||
@@ -48,6 +49,8 @@ The portion of the interface returned by GinkgoT() that maps onto methods in the
|
||||
*/
|
||||
type GinkgoTInterface interface {
|
||||
Cleanup(func())
|
||||
Chdir(dir string)
|
||||
Context() context.Context
|
||||
Setenv(kev, value string)
|
||||
Error(args ...any)
|
||||
Errorf(format string, args ...any)
|
||||
|
||||
2
vendor/github.com/onsi/ginkgo/v2/internal/failer.go
generated
vendored
2
vendor/github.com/onsi/ginkgo/v2/internal/failer.go
generated
vendored
@@ -32,7 +32,7 @@ func (f *Failer) GetFailure() types.Failure {
|
||||
return f.failure
|
||||
}
|
||||
|
||||
func (f *Failer) Panic(location types.CodeLocation, forwardedPanic interface{}) {
|
||||
func (f *Failer) Panic(location types.CodeLocation, forwardedPanic any) {
|
||||
f.lock.Lock()
|
||||
defer f.lock.Unlock()
|
||||
|
||||
|
||||
22
vendor/github.com/onsi/ginkgo/v2/internal/interrupt_handler/interrupt_handler.go
generated
vendored
22
vendor/github.com/onsi/ginkgo/v2/internal/interrupt_handler/interrupt_handler.go
generated
vendored
@@ -40,7 +40,7 @@ func (ic InterruptCause) String() string {
|
||||
}
|
||||
|
||||
type InterruptStatus struct {
|
||||
Channel chan interface{}
|
||||
Channel chan any
|
||||
Level InterruptLevel
|
||||
Cause InterruptCause
|
||||
}
|
||||
@@ -62,14 +62,14 @@ type InterruptHandlerInterface interface {
|
||||
}
|
||||
|
||||
type InterruptHandler struct {
|
||||
c chan interface{}
|
||||
c chan any
|
||||
lock *sync.Mutex
|
||||
level InterruptLevel
|
||||
cause InterruptCause
|
||||
client parallel_support.Client
|
||||
stop chan interface{}
|
||||
stop chan any
|
||||
signals []os.Signal
|
||||
requestAbortCheck chan interface{}
|
||||
requestAbortCheck chan any
|
||||
}
|
||||
|
||||
func NewInterruptHandler(client parallel_support.Client, signals ...os.Signal) *InterruptHandler {
|
||||
@@ -77,10 +77,10 @@ func NewInterruptHandler(client parallel_support.Client, signals ...os.Signal) *
|
||||
signals = []os.Signal{os.Interrupt, syscall.SIGTERM}
|
||||
}
|
||||
handler := &InterruptHandler{
|
||||
c: make(chan interface{}),
|
||||
c: make(chan any),
|
||||
lock: &sync.Mutex{},
|
||||
stop: make(chan interface{}),
|
||||
requestAbortCheck: make(chan interface{}),
|
||||
stop: make(chan any),
|
||||
requestAbortCheck: make(chan any),
|
||||
client: client,
|
||||
signals: signals,
|
||||
}
|
||||
@@ -98,9 +98,9 @@ func (handler *InterruptHandler) registerForInterrupts() {
|
||||
signal.Notify(signalChannel, handler.signals...)
|
||||
|
||||
// cross-process abort handling
|
||||
var abortChannel chan interface{}
|
||||
var abortChannel chan any
|
||||
if handler.client != nil {
|
||||
abortChannel = make(chan interface{})
|
||||
abortChannel = make(chan any)
|
||||
go func() {
|
||||
pollTicker := time.NewTicker(ABORT_POLLING_INTERVAL)
|
||||
for {
|
||||
@@ -125,7 +125,7 @@ func (handler *InterruptHandler) registerForInterrupts() {
|
||||
}()
|
||||
}
|
||||
|
||||
go func(abortChannel chan interface{}) {
|
||||
go func(abortChannel chan any) {
|
||||
var interruptCause InterruptCause
|
||||
for {
|
||||
select {
|
||||
@@ -151,7 +151,7 @@ func (handler *InterruptHandler) registerForInterrupts() {
|
||||
}
|
||||
if handler.level != oldLevel {
|
||||
close(handler.c)
|
||||
handler.c = make(chan interface{})
|
||||
handler.c = make(chan any)
|
||||
}
|
||||
handler.lock.Unlock()
|
||||
}
|
||||
|
||||
34
vendor/github.com/onsi/ginkgo/v2/internal/node.go
generated
vendored
34
vendor/github.com/onsi/ginkgo/v2/internal/node.go
generated
vendored
@@ -84,7 +84,7 @@ const SuppressProgressReporting = suppressProgressReporting(true)
|
||||
type FlakeAttempts uint
|
||||
type MustPassRepeatedly uint
|
||||
type Offset uint
|
||||
type Done chan<- interface{} // Deprecated Done Channel for asynchronous testing
|
||||
type Done chan<- any // Deprecated Done Channel for asynchronous testing
|
||||
type Labels []string
|
||||
type PollProgressInterval time.Duration
|
||||
type PollProgressAfter time.Duration
|
||||
@@ -110,9 +110,9 @@ func UnionOfLabels(labels ...Labels) Labels {
|
||||
return out
|
||||
}
|
||||
|
||||
func PartitionDecorations(args ...interface{}) ([]interface{}, []interface{}) {
|
||||
decorations := []interface{}{}
|
||||
remainingArgs := []interface{}{}
|
||||
func PartitionDecorations(args ...any) ([]any, []any) {
|
||||
decorations := []any{}
|
||||
remainingArgs := []any{}
|
||||
for _, arg := range args {
|
||||
if isDecoration(arg) {
|
||||
decorations = append(decorations, arg)
|
||||
@@ -123,7 +123,7 @@ func PartitionDecorations(args ...interface{}) ([]interface{}, []interface{}) {
|
||||
return decorations, remainingArgs
|
||||
}
|
||||
|
||||
func isDecoration(arg interface{}) bool {
|
||||
func isDecoration(arg any) bool {
|
||||
switch t := reflect.TypeOf(arg); {
|
||||
case t == nil:
|
||||
return false
|
||||
@@ -168,7 +168,7 @@ func isDecoration(arg interface{}) bool {
|
||||
}
|
||||
}
|
||||
|
||||
func isSliceOfDecorations(slice interface{}) bool {
|
||||
func isSliceOfDecorations(slice any) bool {
|
||||
vSlice := reflect.ValueOf(slice)
|
||||
if vSlice.Len() == 0 {
|
||||
return false
|
||||
@@ -184,7 +184,7 @@ func isSliceOfDecorations(slice interface{}) bool {
|
||||
var contextType = reflect.TypeOf(new(context.Context)).Elem()
|
||||
var specContextType = reflect.TypeOf(new(SpecContext)).Elem()
|
||||
|
||||
func NewNode(deprecationTracker *types.DeprecationTracker, nodeType types.NodeType, text string, args ...interface{}) (Node, []error) {
|
||||
func NewNode(deprecationTracker *types.DeprecationTracker, nodeType types.NodeType, text string, args ...any) (Node, []error) {
|
||||
baseOffset := 2
|
||||
node := Node{
|
||||
ID: UniqueNodeID(),
|
||||
@@ -207,7 +207,7 @@ func NewNode(deprecationTracker *types.DeprecationTracker, nodeType types.NodeTy
|
||||
|
||||
args = unrollInterfaceSlice(args)
|
||||
|
||||
remainingArgs := []interface{}{}
|
||||
remainingArgs := []any{}
|
||||
// First get the CodeLocation up-to-date
|
||||
for _, arg := range args {
|
||||
switch v := arg.(type) {
|
||||
@@ -223,7 +223,7 @@ func NewNode(deprecationTracker *types.DeprecationTracker, nodeType types.NodeTy
|
||||
labelsSeen := map[string]bool{}
|
||||
trackedFunctionError := false
|
||||
args = remainingArgs
|
||||
remainingArgs = []interface{}{}
|
||||
remainingArgs = []any{}
|
||||
// now process the rest of the args
|
||||
for _, arg := range args {
|
||||
switch t := reflect.TypeOf(arg); {
|
||||
@@ -451,7 +451,7 @@ func NewNode(deprecationTracker *types.DeprecationTracker, nodeType types.NodeTy
|
||||
|
||||
var doneType = reflect.TypeOf(make(Done))
|
||||
|
||||
func extractBodyFunction(deprecationTracker *types.DeprecationTracker, cl types.CodeLocation, arg interface{}) (func(SpecContext), bool) {
|
||||
func extractBodyFunction(deprecationTracker *types.DeprecationTracker, cl types.CodeLocation, arg any) (func(SpecContext), bool) {
|
||||
t := reflect.TypeOf(arg)
|
||||
if t.NumOut() > 0 || t.NumIn() > 1 {
|
||||
return nil, false
|
||||
@@ -477,7 +477,7 @@ func extractBodyFunction(deprecationTracker *types.DeprecationTracker, cl types.
|
||||
|
||||
var byteType = reflect.TypeOf([]byte{})
|
||||
|
||||
func extractSynchronizedBeforeSuiteProc1Body(arg interface{}) (func(SpecContext) []byte, bool) {
|
||||
func extractSynchronizedBeforeSuiteProc1Body(arg any) (func(SpecContext) []byte, bool) {
|
||||
t := reflect.TypeOf(arg)
|
||||
v := reflect.ValueOf(arg)
|
||||
|
||||
@@ -505,7 +505,7 @@ func extractSynchronizedBeforeSuiteProc1Body(arg interface{}) (func(SpecContext)
|
||||
}, hasContext
|
||||
}
|
||||
|
||||
func extractSynchronizedBeforeSuiteAllProcsBody(arg interface{}) (func(SpecContext, []byte), bool) {
|
||||
func extractSynchronizedBeforeSuiteAllProcsBody(arg any) (func(SpecContext, []byte), bool) {
|
||||
t := reflect.TypeOf(arg)
|
||||
v := reflect.ValueOf(arg)
|
||||
hasContext, hasByte := false, false
|
||||
@@ -536,11 +536,11 @@ func extractSynchronizedBeforeSuiteAllProcsBody(arg interface{}) (func(SpecConte
|
||||
|
||||
var errInterface = reflect.TypeOf((*error)(nil)).Elem()
|
||||
|
||||
func NewCleanupNode(deprecationTracker *types.DeprecationTracker, fail func(string, types.CodeLocation), args ...interface{}) (Node, []error) {
|
||||
func NewCleanupNode(deprecationTracker *types.DeprecationTracker, fail func(string, types.CodeLocation), args ...any) (Node, []error) {
|
||||
decorations, remainingArgs := PartitionDecorations(args...)
|
||||
baseOffset := 2
|
||||
cl := types.NewCodeLocation(baseOffset)
|
||||
finalArgs := []interface{}{}
|
||||
finalArgs := []any{}
|
||||
for _, arg := range decorations {
|
||||
switch t := reflect.TypeOf(arg); {
|
||||
case t == reflect.TypeOf(Offset(0)):
|
||||
@@ -920,12 +920,12 @@ func (n Nodes) GetMaxMustPassRepeatedly() int {
|
||||
return maxMustPassRepeatedly
|
||||
}
|
||||
|
||||
func unrollInterfaceSlice(args interface{}) []interface{} {
|
||||
func unrollInterfaceSlice(args any) []any {
|
||||
v := reflect.ValueOf(args)
|
||||
if v.Kind() != reflect.Slice {
|
||||
return []interface{}{args}
|
||||
return []any{args}
|
||||
}
|
||||
out := []interface{}{}
|
||||
out := []any{}
|
||||
for i := 0; i < v.Len(); i++ {
|
||||
el := reflect.ValueOf(v.Index(i).Interface())
|
||||
if el.Kind() == reflect.Slice && el.Type() != reflect.TypeOf(Labels{}) {
|
||||
|
||||
14
vendor/github.com/onsi/ginkgo/v2/internal/output_interceptor.go
generated
vendored
14
vendor/github.com/onsi/ginkgo/v2/internal/output_interceptor.go
generated
vendored
@@ -69,7 +69,7 @@ type pipePair struct {
|
||||
writer *os.File
|
||||
}
|
||||
|
||||
func startPipeFactory(pipeChannel chan pipePair, shutdown chan interface{}) {
|
||||
func startPipeFactory(pipeChannel chan pipePair, shutdown chan any) {
|
||||
for {
|
||||
//make the next pipe...
|
||||
pair := pipePair{}
|
||||
@@ -101,8 +101,8 @@ type genericOutputInterceptor struct {
|
||||
stderrClone *os.File
|
||||
pipe pipePair
|
||||
|
||||
shutdown chan interface{}
|
||||
emergencyBailout chan interface{}
|
||||
shutdown chan any
|
||||
emergencyBailout chan any
|
||||
pipeChannel chan pipePair
|
||||
interceptedContent chan string
|
||||
|
||||
@@ -139,7 +139,7 @@ func (interceptor *genericOutputInterceptor) ResumeIntercepting() {
|
||||
interceptor.intercepting = true
|
||||
if interceptor.stdoutClone == nil {
|
||||
interceptor.stdoutClone, interceptor.stderrClone = interceptor.implementation.CreateStdoutStderrClones()
|
||||
interceptor.shutdown = make(chan interface{})
|
||||
interceptor.shutdown = make(chan any)
|
||||
go startPipeFactory(interceptor.pipeChannel, interceptor.shutdown)
|
||||
}
|
||||
|
||||
@@ -147,13 +147,13 @@ func (interceptor *genericOutputInterceptor) ResumeIntercepting() {
|
||||
// we get the pipe from our pipe factory. it runs in the background so we can request the next pipe while the spec being intercepted is running
|
||||
interceptor.pipe = <-interceptor.pipeChannel
|
||||
|
||||
interceptor.emergencyBailout = make(chan interface{})
|
||||
interceptor.emergencyBailout = make(chan any)
|
||||
|
||||
//Spin up a goroutine to copy data from the pipe into a buffer, this is how we capture any output the user is emitting
|
||||
go func() {
|
||||
buffer := &bytes.Buffer{}
|
||||
destination := io.MultiWriter(buffer, interceptor.forwardTo)
|
||||
copyFinished := make(chan interface{})
|
||||
copyFinished := make(chan any)
|
||||
reader := interceptor.pipe.reader
|
||||
go func() {
|
||||
io.Copy(destination, reader)
|
||||
@@ -224,7 +224,7 @@ func NewOSGlobalReassigningOutputInterceptor() OutputInterceptor {
|
||||
return &genericOutputInterceptor{
|
||||
interceptedContent: make(chan string),
|
||||
pipeChannel: make(chan pipePair),
|
||||
shutdown: make(chan interface{}),
|
||||
shutdown: make(chan any),
|
||||
implementation: &osGlobalReassigningOutputInterceptorImpl{},
|
||||
}
|
||||
}
|
||||
|
||||
2
vendor/github.com/onsi/ginkgo/v2/internal/output_interceptor_unix.go
generated
vendored
2
vendor/github.com/onsi/ginkgo/v2/internal/output_interceptor_unix.go
generated
vendored
@@ -13,7 +13,7 @@ func NewOutputInterceptor() OutputInterceptor {
|
||||
return &genericOutputInterceptor{
|
||||
interceptedContent: make(chan string),
|
||||
pipeChannel: make(chan pipePair),
|
||||
shutdown: make(chan interface{}),
|
||||
shutdown: make(chan any),
|
||||
implementation: &dupSyscallOutputInterceptorImpl{},
|
||||
}
|
||||
}
|
||||
|
||||
2
vendor/github.com/onsi/ginkgo/v2/internal/parallel_support/client_server.go
generated
vendored
2
vendor/github.com/onsi/ginkgo/v2/internal/parallel_support/client_server.go
generated
vendored
@@ -30,7 +30,7 @@ type Server interface {
|
||||
Close()
|
||||
Address() string
|
||||
RegisterAlive(node int, alive func() bool)
|
||||
GetSuiteDone() chan interface{}
|
||||
GetSuiteDone() chan any
|
||||
GetOutputDestination() io.Writer
|
||||
SetOutputDestination(io.Writer)
|
||||
}
|
||||
|
||||
9
vendor/github.com/onsi/ginkgo/v2/internal/parallel_support/http_client.go
generated
vendored
9
vendor/github.com/onsi/ginkgo/v2/internal/parallel_support/http_client.go
generated
vendored
@@ -34,7 +34,7 @@ func (client *httpClient) Close() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (client *httpClient) post(path string, data interface{}) error {
|
||||
func (client *httpClient) post(path string, data any) error {
|
||||
var body io.Reader
|
||||
if data != nil {
|
||||
encoded, err := json.Marshal(data)
|
||||
@@ -54,7 +54,7 @@ func (client *httpClient) post(path string, data interface{}) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (client *httpClient) poll(path string, data interface{}) error {
|
||||
func (client *httpClient) poll(path string, data any) error {
|
||||
for {
|
||||
resp, err := http.Get(client.serverHost + path)
|
||||
if err != nil {
|
||||
@@ -153,10 +153,7 @@ func (client *httpClient) PostAbort() error {
|
||||
|
||||
func (client *httpClient) ShouldAbort() bool {
|
||||
err := client.poll("/abort", nil)
|
||||
if err == ErrorGone {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
return err == ErrorGone
|
||||
}
|
||||
|
||||
func (client *httpClient) Write(p []byte) (int, error) {
|
||||
|
||||
4
vendor/github.com/onsi/ginkgo/v2/internal/parallel_support/http_server.go
generated
vendored
4
vendor/github.com/onsi/ginkgo/v2/internal/parallel_support/http_server.go
generated
vendored
@@ -75,7 +75,7 @@ func (server *httpServer) Address() string {
|
||||
return "http://" + server.listener.Addr().String()
|
||||
}
|
||||
|
||||
func (server *httpServer) GetSuiteDone() chan interface{} {
|
||||
func (server *httpServer) GetSuiteDone() chan any {
|
||||
return server.handler.done
|
||||
}
|
||||
|
||||
@@ -96,7 +96,7 @@ func (server *httpServer) RegisterAlive(node int, alive func() bool) {
|
||||
//
|
||||
|
||||
// The server will forward all received messages to Ginkgo reporters registered with `RegisterReporters`
|
||||
func (server *httpServer) decode(writer http.ResponseWriter, request *http.Request, object interface{}) bool {
|
||||
func (server *httpServer) decode(writer http.ResponseWriter, request *http.Request, object any) bool {
|
||||
defer request.Body.Close()
|
||||
if json.NewDecoder(request.Body).Decode(object) != nil {
|
||||
writer.WriteHeader(http.StatusBadRequest)
|
||||
|
||||
2
vendor/github.com/onsi/ginkgo/v2/internal/parallel_support/rpc_client.go
generated
vendored
2
vendor/github.com/onsi/ginkgo/v2/internal/parallel_support/rpc_client.go
generated
vendored
@@ -35,7 +35,7 @@ func (client *rpcClient) Close() error {
|
||||
return client.client.Close()
|
||||
}
|
||||
|
||||
func (client *rpcClient) poll(method string, data interface{}) error {
|
||||
func (client *rpcClient) poll(method string, data any) error {
|
||||
for {
|
||||
err := client.client.Call(method, voidSender, data)
|
||||
if err == nil {
|
||||
|
||||
10
vendor/github.com/onsi/ginkgo/v2/internal/parallel_support/rpc_server.go
generated
vendored
10
vendor/github.com/onsi/ginkgo/v2/internal/parallel_support/rpc_server.go
generated
vendored
@@ -25,7 +25,7 @@ type RPCServer struct {
|
||||
handler *ServerHandler
|
||||
}
|
||||
|
||||
//Create a new server, automatically selecting a port
|
||||
// Create a new server, automatically selecting a port
|
||||
func newRPCServer(parallelTotal int, reporter reporters.Reporter) (*RPCServer, error) {
|
||||
listener, err := net.Listen("tcp", "127.0.0.1:0")
|
||||
if err != nil {
|
||||
@@ -37,7 +37,7 @@ func newRPCServer(parallelTotal int, reporter reporters.Reporter) (*RPCServer, e
|
||||
}, nil
|
||||
}
|
||||
|
||||
//Start the server. You don't need to `go s.Start()`, just `s.Start()`
|
||||
// Start the server. You don't need to `go s.Start()`, just `s.Start()`
|
||||
func (server *RPCServer) Start() {
|
||||
rpcServer := rpc.NewServer()
|
||||
rpcServer.RegisterName("Server", server.handler) //register the handler's methods as the server
|
||||
@@ -48,17 +48,17 @@ func (server *RPCServer) Start() {
|
||||
go httpServer.Serve(server.listener)
|
||||
}
|
||||
|
||||
//Stop the server
|
||||
// Stop the server
|
||||
func (server *RPCServer) Close() {
|
||||
server.listener.Close()
|
||||
}
|
||||
|
||||
//The address the server can be reached it. Pass this into the `ForwardingReporter`.
|
||||
// The address the server can be reached it. Pass this into the `ForwardingReporter`.
|
||||
func (server *RPCServer) Address() string {
|
||||
return server.listener.Addr().String()
|
||||
}
|
||||
|
||||
func (server *RPCServer) GetSuiteDone() chan interface{} {
|
||||
func (server *RPCServer) GetSuiteDone() chan any {
|
||||
return server.handler.done
|
||||
}
|
||||
|
||||
|
||||
4
vendor/github.com/onsi/ginkgo/v2/internal/parallel_support/server_handler.go
generated
vendored
4
vendor/github.com/onsi/ginkgo/v2/internal/parallel_support/server_handler.go
generated
vendored
@@ -18,7 +18,7 @@ var voidSender Void
|
||||
// It handles all the business logic to avoid duplication between the two servers
|
||||
|
||||
type ServerHandler struct {
|
||||
done chan interface{}
|
||||
done chan any
|
||||
outputDestination io.Writer
|
||||
reporter reporters.Reporter
|
||||
alives []func() bool
|
||||
@@ -46,7 +46,7 @@ func newServerHandler(parallelTotal int, reporter reporters.Reporter) *ServerHan
|
||||
|
||||
parallelTotal: parallelTotal,
|
||||
outputDestination: os.Stdout,
|
||||
done: make(chan interface{}),
|
||||
done: make(chan any),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
2
vendor/github.com/onsi/ginkgo/v2/internal/report_entry.go
generated
vendored
2
vendor/github.com/onsi/ginkgo/v2/internal/report_entry.go
generated
vendored
@@ -8,7 +8,7 @@ import (
|
||||
|
||||
type ReportEntry = types.ReportEntry
|
||||
|
||||
func NewReportEntry(name string, cl types.CodeLocation, args ...interface{}) (ReportEntry, error) {
|
||||
func NewReportEntry(name string, cl types.CodeLocation, args ...any) (ReportEntry, error) {
|
||||
out := ReportEntry{
|
||||
Visibility: types.ReportEntryVisibilityAlways,
|
||||
Name: name,
|
||||
|
||||
43
vendor/github.com/onsi/ginkgo/v2/internal/testingtproxy/testing_t_proxy.go
generated
vendored
43
vendor/github.com/onsi/ginkgo/v2/internal/testingtproxy/testing_t_proxy.go
generated
vendored
@@ -1,6 +1,7 @@
|
||||
package testingtproxy
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"io"
|
||||
"os"
|
||||
@@ -19,9 +20,9 @@ type addReportEntryFunc func(names string, args ...any)
|
||||
type ginkgoWriterInterface interface {
|
||||
io.Writer
|
||||
|
||||
Print(a ...interface{})
|
||||
Printf(format string, a ...interface{})
|
||||
Println(a ...interface{})
|
||||
Print(a ...any)
|
||||
Printf(format string, a ...any)
|
||||
Println(a ...any)
|
||||
}
|
||||
type ginkgoRecoverFunc func()
|
||||
type attachProgressReporterFunc func(func() string) func()
|
||||
@@ -80,11 +81,31 @@ func (t *ginkgoTestingTProxy) Setenv(key, value string) {
|
||||
}
|
||||
}
|
||||
|
||||
func (t *ginkgoTestingTProxy) Error(args ...interface{}) {
|
||||
func (t *ginkgoTestingTProxy) Chdir(dir string) {
|
||||
currentDir, err := os.Getwd()
|
||||
if err != nil {
|
||||
t.fail(fmt.Sprintf("Failed to get current directory: %v", err), 1)
|
||||
}
|
||||
|
||||
t.cleanup(os.Chdir, currentDir, internal.Offset(1))
|
||||
|
||||
err = os.Chdir(dir)
|
||||
if err != nil {
|
||||
t.fail(fmt.Sprintf("Failed to change directory: %v", err), 1)
|
||||
}
|
||||
}
|
||||
|
||||
func (t *ginkgoTestingTProxy) Context() context.Context {
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
t.cleanup(cancel, internal.Offset(1))
|
||||
return ctx
|
||||
}
|
||||
|
||||
func (t *ginkgoTestingTProxy) Error(args ...any) {
|
||||
t.fail(fmt.Sprintln(args...), t.offset)
|
||||
}
|
||||
|
||||
func (t *ginkgoTestingTProxy) Errorf(format string, args ...interface{}) {
|
||||
func (t *ginkgoTestingTProxy) Errorf(format string, args ...any) {
|
||||
t.fail(fmt.Sprintf(format, args...), t.offset)
|
||||
}
|
||||
|
||||
@@ -100,11 +121,11 @@ func (t *ginkgoTestingTProxy) Failed() bool {
|
||||
return t.report().Failed()
|
||||
}
|
||||
|
||||
func (t *ginkgoTestingTProxy) Fatal(args ...interface{}) {
|
||||
func (t *ginkgoTestingTProxy) Fatal(args ...any) {
|
||||
t.fail(fmt.Sprintln(args...), t.offset)
|
||||
}
|
||||
|
||||
func (t *ginkgoTestingTProxy) Fatalf(format string, args ...interface{}) {
|
||||
func (t *ginkgoTestingTProxy) Fatalf(format string, args ...any) {
|
||||
t.fail(fmt.Sprintf(format, args...), t.offset)
|
||||
}
|
||||
|
||||
@@ -112,11 +133,11 @@ func (t *ginkgoTestingTProxy) Helper() {
|
||||
types.MarkAsHelper(1)
|
||||
}
|
||||
|
||||
func (t *ginkgoTestingTProxy) Log(args ...interface{}) {
|
||||
func (t *ginkgoTestingTProxy) Log(args ...any) {
|
||||
fmt.Fprintln(t.writer, args...)
|
||||
}
|
||||
|
||||
func (t *ginkgoTestingTProxy) Logf(format string, args ...interface{}) {
|
||||
func (t *ginkgoTestingTProxy) Logf(format string, args ...any) {
|
||||
t.Log(fmt.Sprintf(format, args...))
|
||||
}
|
||||
|
||||
@@ -128,7 +149,7 @@ func (t *ginkgoTestingTProxy) Parallel() {
|
||||
// No-op
|
||||
}
|
||||
|
||||
func (t *ginkgoTestingTProxy) Skip(args ...interface{}) {
|
||||
func (t *ginkgoTestingTProxy) Skip(args ...any) {
|
||||
t.skip(fmt.Sprintln(args...), t.offset)
|
||||
}
|
||||
|
||||
@@ -136,7 +157,7 @@ func (t *ginkgoTestingTProxy) SkipNow() {
|
||||
t.skip("skip", t.offset)
|
||||
}
|
||||
|
||||
func (t *ginkgoTestingTProxy) Skipf(format string, args ...interface{}) {
|
||||
func (t *ginkgoTestingTProxy) Skipf(format string, args ...any) {
|
||||
t.skip(fmt.Sprintf(format, args...), t.offset)
|
||||
}
|
||||
|
||||
|
||||
6
vendor/github.com/onsi/ginkgo/v2/internal/writer.go
generated
vendored
6
vendor/github.com/onsi/ginkgo/v2/internal/writer.go
generated
vendored
@@ -121,15 +121,15 @@ func (w *Writer) ClearTeeWriters() {
|
||||
w.teeWriters = []io.Writer{}
|
||||
}
|
||||
|
||||
func (w *Writer) Print(a ...interface{}) {
|
||||
func (w *Writer) Print(a ...any) {
|
||||
fmt.Fprint(w, a...)
|
||||
}
|
||||
|
||||
func (w *Writer) Printf(format string, a ...interface{}) {
|
||||
func (w *Writer) Printf(format string, a ...any) {
|
||||
fmt.Fprintf(w, format, a...)
|
||||
}
|
||||
|
||||
func (w *Writer) Println(a ...interface{}) {
|
||||
func (w *Writer) Println(a ...any) {
|
||||
fmt.Fprintln(w, a...)
|
||||
}
|
||||
|
||||
|
||||
4
vendor/github.com/onsi/ginkgo/v2/reporters/default_reporter.go
generated
vendored
4
vendor/github.com/onsi/ginkgo/v2/reporters/default_reporter.go
generated
vendored
@@ -685,11 +685,11 @@ func (r *DefaultReporter) _emit(s string, block bool, isDelimiter bool) {
|
||||
}
|
||||
|
||||
/* Rendering text */
|
||||
func (r *DefaultReporter) f(format string, args ...interface{}) string {
|
||||
func (r *DefaultReporter) f(format string, args ...any) string {
|
||||
return r.formatter.F(format, args...)
|
||||
}
|
||||
|
||||
func (r *DefaultReporter) fi(indentation uint, format string, args ...interface{}) string {
|
||||
func (r *DefaultReporter) fi(indentation uint, format string, args ...any) string {
|
||||
return r.formatter.Fi(indentation, format, args...)
|
||||
}
|
||||
|
||||
|
||||
12
vendor/github.com/onsi/ginkgo/v2/reporting_dsl.go
generated
vendored
12
vendor/github.com/onsi/ginkgo/v2/reporting_dsl.go
generated
vendored
@@ -60,7 +60,7 @@ AddReportEntry() must be called within a Subject or Setup node - not in a Contai
|
||||
|
||||
You can learn more about Report Entries here: https://onsi.github.io/ginkgo/#attaching-data-to-reports
|
||||
*/
|
||||
func AddReportEntry(name string, args ...interface{}) {
|
||||
func AddReportEntry(name string, args ...any) {
|
||||
cl := types.NewCodeLocation(1)
|
||||
reportEntry, err := internal.NewReportEntry(name, cl, args...)
|
||||
if err != nil {
|
||||
@@ -89,7 +89,7 @@ You can learn more about ReportBeforeEach here: https://onsi.github.io/ginkgo/#g
|
||||
You can learn about interruptible nodes here: https://onsi.github.io/ginkgo/#spec-timeouts-and-interruptible-nodes
|
||||
*/
|
||||
func ReportBeforeEach(body any, args ...any) bool {
|
||||
combinedArgs := []interface{}{body}
|
||||
combinedArgs := []any{body}
|
||||
combinedArgs = append(combinedArgs, args...)
|
||||
|
||||
return pushNode(internal.NewNode(deprecationTracker, types.NodeTypeReportBeforeEach, "", combinedArgs...))
|
||||
@@ -113,7 +113,7 @@ You can learn more about ReportAfterEach here: https://onsi.github.io/ginkgo/#ge
|
||||
You can learn about interruptible nodes here: https://onsi.github.io/ginkgo/#spec-timeouts-and-interruptible-nodes
|
||||
*/
|
||||
func ReportAfterEach(body any, args ...any) bool {
|
||||
combinedArgs := []interface{}{body}
|
||||
combinedArgs := []any{body}
|
||||
combinedArgs = append(combinedArgs, args...)
|
||||
|
||||
return pushNode(internal.NewNode(deprecationTracker, types.NodeTypeReportAfterEach, "", combinedArgs...))
|
||||
@@ -143,7 +143,7 @@ You can learn more about Ginkgo's reporting infrastructure, including generating
|
||||
You can learn about interruptible nodes here: https://onsi.github.io/ginkgo/#spec-timeouts-and-interruptible-nodes
|
||||
*/
|
||||
func ReportBeforeSuite(body any, args ...any) bool {
|
||||
combinedArgs := []interface{}{body}
|
||||
combinedArgs := []any{body}
|
||||
combinedArgs = append(combinedArgs, args...)
|
||||
return pushNode(internal.NewNode(deprecationTracker, types.NodeTypeReportBeforeSuite, "", combinedArgs...))
|
||||
}
|
||||
@@ -174,8 +174,8 @@ You can learn more about Ginkgo's reporting infrastructure, including generating
|
||||
|
||||
You can learn about interruptible nodes here: https://onsi.github.io/ginkgo/#spec-timeouts-and-interruptible-nodes
|
||||
*/
|
||||
func ReportAfterSuite(text string, body any, args ...interface{}) bool {
|
||||
combinedArgs := []interface{}{body}
|
||||
func ReportAfterSuite(text string, body any, args ...any) bool {
|
||||
combinedArgs := []any{body}
|
||||
combinedArgs = append(combinedArgs, args...)
|
||||
return pushNode(internal.NewNode(deprecationTracker, types.NodeTypeReportAfterSuite, text, combinedArgs...))
|
||||
}
|
||||
|
||||
46
vendor/github.com/onsi/ginkgo/v2/table_dsl.go
generated
vendored
46
vendor/github.com/onsi/ginkgo/v2/table_dsl.go
generated
vendored
@@ -23,7 +23,7 @@ You can learn more about generating EntryDescriptions here: https://onsi.github.
|
||||
*/
|
||||
type EntryDescription string
|
||||
|
||||
func (ed EntryDescription) render(args ...interface{}) string {
|
||||
func (ed EntryDescription) render(args ...any) string {
|
||||
return fmt.Sprintf(string(ed), args...)
|
||||
}
|
||||
|
||||
@@ -44,7 +44,7 @@ For example:
|
||||
You can learn more about DescribeTable here: https://onsi.github.io/ginkgo/#table-specs
|
||||
And can explore some Table patterns here: https://onsi.github.io/ginkgo/#table-specs-patterns
|
||||
*/
|
||||
func DescribeTable(description string, args ...interface{}) bool {
|
||||
func DescribeTable(description string, args ...any) bool {
|
||||
GinkgoHelper()
|
||||
generateTable(description, false, args...)
|
||||
return true
|
||||
@@ -53,7 +53,7 @@ func DescribeTable(description string, args ...interface{}) bool {
|
||||
/*
|
||||
You can focus a table with `FDescribeTable`. This is equivalent to `FDescribe`.
|
||||
*/
|
||||
func FDescribeTable(description string, args ...interface{}) bool {
|
||||
func FDescribeTable(description string, args ...any) bool {
|
||||
GinkgoHelper()
|
||||
args = append(args, internal.Focus)
|
||||
generateTable(description, false, args...)
|
||||
@@ -63,7 +63,7 @@ func FDescribeTable(description string, args ...interface{}) bool {
|
||||
/*
|
||||
You can mark a table as pending with `PDescribeTable`. This is equivalent to `PDescribe`.
|
||||
*/
|
||||
func PDescribeTable(description string, args ...interface{}) bool {
|
||||
func PDescribeTable(description string, args ...any) bool {
|
||||
GinkgoHelper()
|
||||
args = append(args, internal.Pending)
|
||||
generateTable(description, false, args...)
|
||||
@@ -109,7 +109,7 @@ Note that you **must** place define an It inside the body function.
|
||||
You can learn more about DescribeTableSubtree here: https://onsi.github.io/ginkgo/#table-specs
|
||||
And can explore some Table patterns here: https://onsi.github.io/ginkgo/#table-specs-patterns
|
||||
*/
|
||||
func DescribeTableSubtree(description string, args ...interface{}) bool {
|
||||
func DescribeTableSubtree(description string, args ...any) bool {
|
||||
GinkgoHelper()
|
||||
generateTable(description, true, args...)
|
||||
return true
|
||||
@@ -118,7 +118,7 @@ func DescribeTableSubtree(description string, args ...interface{}) bool {
|
||||
/*
|
||||
You can focus a table with `FDescribeTableSubtree`. This is equivalent to `FDescribe`.
|
||||
*/
|
||||
func FDescribeTableSubtree(description string, args ...interface{}) bool {
|
||||
func FDescribeTableSubtree(description string, args ...any) bool {
|
||||
GinkgoHelper()
|
||||
args = append(args, internal.Focus)
|
||||
generateTable(description, true, args...)
|
||||
@@ -128,7 +128,7 @@ func FDescribeTableSubtree(description string, args ...interface{}) bool {
|
||||
/*
|
||||
You can mark a table as pending with `PDescribeTableSubtree`. This is equivalent to `PDescribe`.
|
||||
*/
|
||||
func PDescribeTableSubtree(description string, args ...interface{}) bool {
|
||||
func PDescribeTableSubtree(description string, args ...any) bool {
|
||||
GinkgoHelper()
|
||||
args = append(args, internal.Pending)
|
||||
generateTable(description, true, args...)
|
||||
@@ -144,9 +144,9 @@ var XDescribeTableSubtree = PDescribeTableSubtree
|
||||
TableEntry represents an entry in a table test. You generally use the `Entry` constructor.
|
||||
*/
|
||||
type TableEntry struct {
|
||||
description interface{}
|
||||
decorations []interface{}
|
||||
parameters []interface{}
|
||||
description any
|
||||
decorations []any
|
||||
parameters []any
|
||||
codeLocation types.CodeLocation
|
||||
}
|
||||
|
||||
@@ -162,7 +162,7 @@ If you want to generate interruptible specs simply write a Table function that a
|
||||
|
||||
You can learn more about Entry here: https://onsi.github.io/ginkgo/#table-specs
|
||||
*/
|
||||
func Entry(description interface{}, args ...interface{}) TableEntry {
|
||||
func Entry(description any, args ...any) TableEntry {
|
||||
GinkgoHelper()
|
||||
decorations, parameters := internal.PartitionDecorations(args...)
|
||||
return TableEntry{description: description, decorations: decorations, parameters: parameters, codeLocation: types.NewCodeLocation(0)}
|
||||
@@ -171,7 +171,7 @@ func Entry(description interface{}, args ...interface{}) TableEntry {
|
||||
/*
|
||||
You can focus a particular entry with FEntry. This is equivalent to FIt.
|
||||
*/
|
||||
func FEntry(description interface{}, args ...interface{}) TableEntry {
|
||||
func FEntry(description any, args ...any) TableEntry {
|
||||
GinkgoHelper()
|
||||
decorations, parameters := internal.PartitionDecorations(args...)
|
||||
decorations = append(decorations, internal.Focus)
|
||||
@@ -181,7 +181,7 @@ func FEntry(description interface{}, args ...interface{}) TableEntry {
|
||||
/*
|
||||
You can mark a particular entry as pending with PEntry. This is equivalent to PIt.
|
||||
*/
|
||||
func PEntry(description interface{}, args ...interface{}) TableEntry {
|
||||
func PEntry(description any, args ...any) TableEntry {
|
||||
GinkgoHelper()
|
||||
decorations, parameters := internal.PartitionDecorations(args...)
|
||||
decorations = append(decorations, internal.Pending)
|
||||
@@ -196,17 +196,17 @@ var XEntry = PEntry
|
||||
var contextType = reflect.TypeOf(new(context.Context)).Elem()
|
||||
var specContextType = reflect.TypeOf(new(SpecContext)).Elem()
|
||||
|
||||
func generateTable(description string, isSubtree bool, args ...interface{}) {
|
||||
func generateTable(description string, isSubtree bool, args ...any) {
|
||||
GinkgoHelper()
|
||||
cl := types.NewCodeLocation(0)
|
||||
containerNodeArgs := []interface{}{cl}
|
||||
containerNodeArgs := []any{cl}
|
||||
|
||||
entries := []TableEntry{}
|
||||
var internalBody interface{}
|
||||
var internalBody any
|
||||
var internalBodyType reflect.Type
|
||||
|
||||
var tableLevelEntryDescription interface{}
|
||||
tableLevelEntryDescription = func(args ...interface{}) string {
|
||||
var tableLevelEntryDescription any
|
||||
tableLevelEntryDescription = func(args ...any) string {
|
||||
out := []string{}
|
||||
for _, arg := range args {
|
||||
out = append(out, fmt.Sprint(arg))
|
||||
@@ -265,7 +265,7 @@ func generateTable(description string, isSubtree bool, args ...interface{}) {
|
||||
err = types.GinkgoErrors.InvalidEntryDescription(entry.codeLocation)
|
||||
}
|
||||
|
||||
internalNodeArgs := []interface{}{entry.codeLocation}
|
||||
internalNodeArgs := []any{entry.codeLocation}
|
||||
internalNodeArgs = append(internalNodeArgs, entry.decorations...)
|
||||
|
||||
hasContext := false
|
||||
@@ -290,7 +290,7 @@ func generateTable(description string, isSubtree bool, args ...interface{}) {
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
invokeFunction(internalBody, append([]interface{}{c}, entry.parameters...))
|
||||
invokeFunction(internalBody, append([]any{c}, entry.parameters...))
|
||||
})
|
||||
if isSubtree {
|
||||
exitIfErr(types.GinkgoErrors.ContextsCannotBeUsedInSubtreeTables(cl))
|
||||
@@ -316,7 +316,7 @@ func generateTable(description string, isSubtree bool, args ...interface{}) {
|
||||
pushNode(internal.NewNode(deprecationTracker, types.NodeTypeContainer, description, containerNodeArgs...))
|
||||
}
|
||||
|
||||
func invokeFunction(function interface{}, parameters []interface{}) []reflect.Value {
|
||||
func invokeFunction(function any, parameters []any) []reflect.Value {
|
||||
inValues := make([]reflect.Value, len(parameters))
|
||||
|
||||
funcType := reflect.TypeOf(function)
|
||||
@@ -339,7 +339,7 @@ func invokeFunction(function interface{}, parameters []interface{}) []reflect.Va
|
||||
return reflect.ValueOf(function).Call(inValues)
|
||||
}
|
||||
|
||||
func validateParameters(function interface{}, parameters []interface{}, kind string, cl types.CodeLocation, hasContext bool) error {
|
||||
func validateParameters(function any, parameters []any, kind string, cl types.CodeLocation, hasContext bool) error {
|
||||
funcType := reflect.TypeOf(function)
|
||||
limit := funcType.NumIn()
|
||||
offset := 0
|
||||
@@ -377,7 +377,7 @@ func validateParameters(function interface{}, parameters []interface{}, kind str
|
||||
return nil
|
||||
}
|
||||
|
||||
func computeValue(parameter interface{}, t reflect.Type) reflect.Value {
|
||||
func computeValue(parameter any, t reflect.Type) reflect.Value {
|
||||
if parameter == nil {
|
||||
return reflect.Zero(t)
|
||||
} else {
|
||||
|
||||
16
vendor/github.com/onsi/ginkgo/v2/types/config.go
generated
vendored
16
vendor/github.com/onsi/ginkgo/v2/types/config.go
generated
vendored
@@ -365,7 +365,7 @@ var ReporterConfigFlags = GinkgoFlags{
|
||||
func BuildTestSuiteFlagSet(suiteConfig *SuiteConfig, reporterConfig *ReporterConfig) (GinkgoFlagSet, error) {
|
||||
flags := SuiteConfigFlags.CopyAppend(ParallelConfigFlags...).CopyAppend(ReporterConfigFlags...)
|
||||
flags = flags.WithPrefix("ginkgo")
|
||||
bindings := map[string]interface{}{
|
||||
bindings := map[string]any{
|
||||
"S": suiteConfig,
|
||||
"R": reporterConfig,
|
||||
"D": &deprecatedConfig{},
|
||||
@@ -646,7 +646,7 @@ func GenerateGoTestCompileArgs(goFlagsConfig GoFlagsConfig, packageToBuild strin
|
||||
args := []string{"test", "-c", packageToBuild}
|
||||
goArgs, err := GenerateFlagArgs(
|
||||
GoBuildFlags,
|
||||
map[string]interface{}{
|
||||
map[string]any{
|
||||
"Go": &goFlagsConfig,
|
||||
},
|
||||
)
|
||||
@@ -665,7 +665,7 @@ func GenerateGinkgoTestRunArgs(suiteConfig SuiteConfig, reporterConfig ReporterC
|
||||
flags = flags.CopyAppend(ParallelConfigFlags.WithPrefix("ginkgo")...)
|
||||
flags = flags.CopyAppend(ReporterConfigFlags.WithPrefix("ginkgo")...)
|
||||
flags = flags.CopyAppend(GoRunFlags.WithPrefix("test")...)
|
||||
bindings := map[string]interface{}{
|
||||
bindings := map[string]any{
|
||||
"S": &suiteConfig,
|
||||
"R": &reporterConfig,
|
||||
"Go": &goFlagsConfig,
|
||||
@@ -677,7 +677,7 @@ func GenerateGinkgoTestRunArgs(suiteConfig SuiteConfig, reporterConfig ReporterC
|
||||
// GenerateGoTestRunArgs is used by the Ginkgo CLI to generate command line arguments to pass to the compiled non-Ginkgo test binary
|
||||
func GenerateGoTestRunArgs(goFlagsConfig GoFlagsConfig) ([]string, error) {
|
||||
flags := GoRunFlags.WithPrefix("test")
|
||||
bindings := map[string]interface{}{
|
||||
bindings := map[string]any{
|
||||
"Go": &goFlagsConfig,
|
||||
}
|
||||
|
||||
@@ -699,7 +699,7 @@ func BuildRunCommandFlagSet(suiteConfig *SuiteConfig, reporterConfig *ReporterCo
|
||||
flags = flags.CopyAppend(GoBuildFlags...)
|
||||
flags = flags.CopyAppend(GoRunFlags...)
|
||||
|
||||
bindings := map[string]interface{}{
|
||||
bindings := map[string]any{
|
||||
"S": suiteConfig,
|
||||
"R": reporterConfig,
|
||||
"C": cliConfig,
|
||||
@@ -720,7 +720,7 @@ func BuildWatchCommandFlagSet(suiteConfig *SuiteConfig, reporterConfig *Reporter
|
||||
flags = flags.CopyAppend(GoBuildFlags...)
|
||||
flags = flags.CopyAppend(GoRunFlags...)
|
||||
|
||||
bindings := map[string]interface{}{
|
||||
bindings := map[string]any{
|
||||
"S": suiteConfig,
|
||||
"R": reporterConfig,
|
||||
"C": cliConfig,
|
||||
@@ -736,7 +736,7 @@ func BuildBuildCommandFlagSet(cliConfig *CLIConfig, goFlagsConfig *GoFlagsConfig
|
||||
flags := GinkgoCLISharedFlags
|
||||
flags = flags.CopyAppend(GoBuildFlags...)
|
||||
|
||||
bindings := map[string]interface{}{
|
||||
bindings := map[string]any{
|
||||
"C": cliConfig,
|
||||
"Go": goFlagsConfig,
|
||||
"D": &deprecatedConfig{},
|
||||
@@ -760,7 +760,7 @@ func BuildBuildCommandFlagSet(cliConfig *CLIConfig, goFlagsConfig *GoFlagsConfig
|
||||
func BuildLabelsCommandFlagSet(cliConfig *CLIConfig) (GinkgoFlagSet, error) {
|
||||
flags := GinkgoCLISharedFlags.SubsetWithNames("r", "skip-package")
|
||||
|
||||
bindings := map[string]interface{}{
|
||||
bindings := map[string]any{
|
||||
"C": cliConfig,
|
||||
}
|
||||
|
||||
|
||||
2
vendor/github.com/onsi/ginkgo/v2/types/deprecated_types.go
generated
vendored
2
vendor/github.com/onsi/ginkgo/v2/types/deprecated_types.go
generated
vendored
@@ -113,7 +113,7 @@ type DeprecatedSpecFailure struct {
|
||||
|
||||
type DeprecatedSpecMeasurement struct {
|
||||
Name string
|
||||
Info interface{}
|
||||
Info any
|
||||
Order int
|
||||
|
||||
Results []float64
|
||||
|
||||
8
vendor/github.com/onsi/ginkgo/v2/types/errors.go
generated
vendored
8
vendor/github.com/onsi/ginkgo/v2/types/errors.go
generated
vendored
@@ -88,7 +88,7 @@ body of a {{bold}}Describe{{/}}, {{bold}}Context{{/}}, or {{bold}}When{{/}}.`, n
|
||||
}
|
||||
}
|
||||
|
||||
func (g ginkgoErrors) CaughtPanicDuringABuildPhase(caughtPanic interface{}, cl CodeLocation) error {
|
||||
func (g ginkgoErrors) CaughtPanicDuringABuildPhase(caughtPanic any, cl CodeLocation) error {
|
||||
return GinkgoError{
|
||||
Heading: "Assertion or Panic detected during tree construction",
|
||||
Message: formatter.F(
|
||||
@@ -189,7 +189,7 @@ func (g ginkgoErrors) InvalidDeclarationOfFlakeAttemptsAndMustPassRepeatedly(cl
|
||||
}
|
||||
}
|
||||
|
||||
func (g ginkgoErrors) UnknownDecorator(cl CodeLocation, nodeType NodeType, decorator interface{}) error {
|
||||
func (g ginkgoErrors) UnknownDecorator(cl CodeLocation, nodeType NodeType, decorator any) error {
|
||||
return GinkgoError{
|
||||
Heading: "Unknown Decorator",
|
||||
Message: formatter.F(`[%s] node was passed an unknown decorator: '%#v'`, nodeType, decorator),
|
||||
@@ -345,7 +345,7 @@ func (g ginkgoErrors) PushingCleanupInCleanupNode(cl CodeLocation) error {
|
||||
}
|
||||
|
||||
/* ReportEntry errors */
|
||||
func (g ginkgoErrors) TooManyReportEntryValues(cl CodeLocation, arg interface{}) error {
|
||||
func (g ginkgoErrors) TooManyReportEntryValues(cl CodeLocation, arg any) error {
|
||||
return GinkgoError{
|
||||
Heading: "Too Many ReportEntry Values",
|
||||
Message: formatter.F(`{{bold}}AddGinkgoReport{{/}} can only be given one value. Got unexpected value: %#v`, arg),
|
||||
@@ -539,7 +539,7 @@ func (g ginkgoErrors) SynchronizedBeforeSuiteDisappearedOnProc1() error {
|
||||
|
||||
/* Configuration errors */
|
||||
|
||||
func (g ginkgoErrors) UnknownTypePassedToRunSpecs(value interface{}) error {
|
||||
func (g ginkgoErrors) UnknownTypePassedToRunSpecs(value any) error {
|
||||
return GinkgoError{
|
||||
Heading: "Unknown Type passed to RunSpecs",
|
||||
Message: fmt.Sprintf("RunSpecs() accepts labels, and configuration of type types.SuiteConfig and/or types.ReporterConfig.\n You passed in: %v", value),
|
||||
|
||||
10
vendor/github.com/onsi/ginkgo/v2/types/flags.go
generated
vendored
10
vendor/github.com/onsi/ginkgo/v2/types/flags.go
generated
vendored
@@ -92,7 +92,7 @@ func (gfs GinkgoFlagSections) Lookup(key string) (GinkgoFlagSection, bool) {
|
||||
|
||||
type GinkgoFlagSet struct {
|
||||
flags GinkgoFlags
|
||||
bindings interface{}
|
||||
bindings any
|
||||
|
||||
sections GinkgoFlagSections
|
||||
extraGoFlagsSection GinkgoFlagSection
|
||||
@@ -101,7 +101,7 @@ type GinkgoFlagSet struct {
|
||||
}
|
||||
|
||||
// Call NewGinkgoFlagSet to create GinkgoFlagSet that creates and binds to it's own *flag.FlagSet
|
||||
func NewGinkgoFlagSet(flags GinkgoFlags, bindings interface{}, sections GinkgoFlagSections) (GinkgoFlagSet, error) {
|
||||
func NewGinkgoFlagSet(flags GinkgoFlags, bindings any, sections GinkgoFlagSections) (GinkgoFlagSet, error) {
|
||||
return bindFlagSet(GinkgoFlagSet{
|
||||
flags: flags,
|
||||
bindings: bindings,
|
||||
@@ -110,7 +110,7 @@ func NewGinkgoFlagSet(flags GinkgoFlags, bindings interface{}, sections GinkgoFl
|
||||
}
|
||||
|
||||
// Call NewGinkgoFlagSet to create GinkgoFlagSet that extends an existing *flag.FlagSet
|
||||
func NewAttachedGinkgoFlagSet(flagSet *flag.FlagSet, flags GinkgoFlags, bindings interface{}, sections GinkgoFlagSections, extraGoFlagsSection GinkgoFlagSection) (GinkgoFlagSet, error) {
|
||||
func NewAttachedGinkgoFlagSet(flagSet *flag.FlagSet, flags GinkgoFlags, bindings any, sections GinkgoFlagSections, extraGoFlagsSection GinkgoFlagSection) (GinkgoFlagSet, error) {
|
||||
return bindFlagSet(GinkgoFlagSet{
|
||||
flags: flags,
|
||||
bindings: bindings,
|
||||
@@ -335,7 +335,7 @@ func (f GinkgoFlagSet) substituteUsage() {
|
||||
fmt.Fprintln(f.flagSet.Output(), f.Usage())
|
||||
}
|
||||
|
||||
func valueAtKeyPath(root interface{}, keyPath string) (reflect.Value, bool) {
|
||||
func valueAtKeyPath(root any, keyPath string) (reflect.Value, bool) {
|
||||
if len(keyPath) == 0 {
|
||||
return reflect.Value{}, false
|
||||
}
|
||||
@@ -433,7 +433,7 @@ func (ssv stringSliceVar) Set(s string) error {
|
||||
}
|
||||
|
||||
// given a set of GinkgoFlags and bindings, generate flag arguments suitable to be passed to an application with that set of flags configured.
|
||||
func GenerateFlagArgs(flags GinkgoFlags, bindings interface{}) ([]string, error) {
|
||||
func GenerateFlagArgs(flags GinkgoFlags, bindings any) ([]string, error) {
|
||||
result := []string{}
|
||||
for _, flag := range flags {
|
||||
name := flag.ExportAs
|
||||
|
||||
2
vendor/github.com/onsi/ginkgo/v2/types/label_filter.go
generated
vendored
2
vendor/github.com/onsi/ginkgo/v2/types/label_filter.go
generated
vendored
@@ -343,7 +343,7 @@ func tokenize(input string) func() (*treeNode, error) {
|
||||
consumeUntil := func(cutset string) (string, int) {
|
||||
j := i
|
||||
for ; j < len(runes); j++ {
|
||||
if strings.IndexRune(cutset, runes[j]) >= 0 {
|
||||
if strings.ContainsRune(cutset, runes[j]) {
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
8
vendor/github.com/onsi/ginkgo/v2/types/report_entry.go
generated
vendored
8
vendor/github.com/onsi/ginkgo/v2/types/report_entry.go
generated
vendored
@@ -9,18 +9,18 @@ import (
|
||||
// ReportEntryValue wraps a report entry's value ensuring it can be encoded and decoded safely into reports
|
||||
// and across the network connection when running in parallel
|
||||
type ReportEntryValue struct {
|
||||
raw interface{} //unexported to prevent gob from freaking out about unregistered structs
|
||||
raw any //unexported to prevent gob from freaking out about unregistered structs
|
||||
AsJSON string
|
||||
Representation string
|
||||
}
|
||||
|
||||
func WrapEntryValue(value interface{}) ReportEntryValue {
|
||||
func WrapEntryValue(value any) ReportEntryValue {
|
||||
return ReportEntryValue{
|
||||
raw: value,
|
||||
}
|
||||
}
|
||||
|
||||
func (rev ReportEntryValue) GetRawValue() interface{} {
|
||||
func (rev ReportEntryValue) GetRawValue() any {
|
||||
return rev.raw
|
||||
}
|
||||
|
||||
@@ -118,7 +118,7 @@ func (entry ReportEntry) StringRepresentation() string {
|
||||
// If used from a rehydrated JSON file _or_ in a ReportAfterSuite when running in parallel this will be
|
||||
// a JSON-decoded {}interface. If you want to reconstitute your original object you can decode the entry.Value.AsJSON
|
||||
// field yourself.
|
||||
func (entry ReportEntry) GetRawValue() interface{} {
|
||||
func (entry ReportEntry) GetRawValue() any {
|
||||
return entry.Value.GetRawValue()
|
||||
}
|
||||
|
||||
|
||||
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.22.2"
|
||||
const VERSION = "2.23.0"
|
||||
|
||||
139
vendor/golang.org/x/tools/go/ast/inspector/inspector.go
generated
vendored
139
vendor/golang.org/x/tools/go/ast/inspector/inspector.go
generated
vendored
@@ -36,6 +36,9 @@ package inspector
|
||||
|
||||
import (
|
||||
"go/ast"
|
||||
_ "unsafe"
|
||||
|
||||
"golang.org/x/tools/internal/astutil/edge"
|
||||
)
|
||||
|
||||
// An Inspector provides methods for inspecting
|
||||
@@ -44,6 +47,24 @@ type Inspector struct {
|
||||
events []event
|
||||
}
|
||||
|
||||
//go:linkname events
|
||||
func events(in *Inspector) []event { return in.events }
|
||||
|
||||
func packEdgeKindAndIndex(ek edge.Kind, index int) int32 {
|
||||
return int32(uint32(index+1)<<7 | uint32(ek))
|
||||
}
|
||||
|
||||
// unpackEdgeKindAndIndex unpacks the edge kind and edge index (within
|
||||
// an []ast.Node slice) from the parent field of a pop event.
|
||||
//
|
||||
//go:linkname unpackEdgeKindAndIndex
|
||||
func unpackEdgeKindAndIndex(x int32) (edge.Kind, int) {
|
||||
// The "parent" field of a pop node holds the
|
||||
// edge Kind in the lower 7 bits and the index+1
|
||||
// in the upper 25.
|
||||
return edge.Kind(x & 0x7f), int(x>>7) - 1
|
||||
}
|
||||
|
||||
// New returns an Inspector for the specified syntax trees.
|
||||
func New(files []*ast.File) *Inspector {
|
||||
return &Inspector{traverse(files)}
|
||||
@@ -52,9 +73,10 @@ func New(files []*ast.File) *Inspector {
|
||||
// An event represents a push or a pop
|
||||
// of an ast.Node during a traversal.
|
||||
type event struct {
|
||||
node ast.Node
|
||||
typ uint64 // typeOf(node) on push event, or union of typ strictly between push and pop events on pop events
|
||||
index int // index of corresponding push or pop event
|
||||
node ast.Node
|
||||
typ uint64 // typeOf(node) on push event, or union of typ strictly between push and pop events on pop events
|
||||
index int32 // index of corresponding push or pop event
|
||||
parent int32 // index of parent's push node (push nodes only), or packed edge kind/index (pop nodes only)
|
||||
}
|
||||
|
||||
// TODO: Experiment with storing only the second word of event.node (unsafe.Pointer).
|
||||
@@ -83,7 +105,7 @@ func (in *Inspector) Preorder(types []ast.Node, f func(ast.Node)) {
|
||||
// })
|
||||
|
||||
mask := maskOf(types)
|
||||
for i := 0; i < len(in.events); {
|
||||
for i := int32(0); i < int32(len(in.events)); {
|
||||
ev := in.events[i]
|
||||
if ev.index > i {
|
||||
// push
|
||||
@@ -113,7 +135,7 @@ func (in *Inspector) Preorder(types []ast.Node, f func(ast.Node)) {
|
||||
// matches an element of the types slice.
|
||||
func (in *Inspector) Nodes(types []ast.Node, f func(n ast.Node, push bool) (proceed bool)) {
|
||||
mask := maskOf(types)
|
||||
for i := 0; i < len(in.events); {
|
||||
for i := int32(0); i < int32(len(in.events)); {
|
||||
ev := in.events[i]
|
||||
if ev.index > i {
|
||||
// push
|
||||
@@ -147,7 +169,7 @@ func (in *Inspector) Nodes(types []ast.Node, f func(n ast.Node, push bool) (proc
|
||||
func (in *Inspector) WithStack(types []ast.Node, f func(n ast.Node, push bool, stack []ast.Node) (proceed bool)) {
|
||||
mask := maskOf(types)
|
||||
var stack []ast.Node
|
||||
for i := 0; i < len(in.events); {
|
||||
for i := int32(0); i < int32(len(in.events)); {
|
||||
ev := in.events[i]
|
||||
if ev.index > i {
|
||||
// push
|
||||
@@ -189,43 +211,74 @@ func traverse(files []*ast.File) []event {
|
||||
extent += int(f.End() - f.Pos())
|
||||
}
|
||||
// This estimate is based on the net/http package.
|
||||
capacity := extent * 33 / 100
|
||||
if capacity > 1e6 {
|
||||
capacity = 1e6 // impose some reasonable maximum
|
||||
capacity := min(extent*33/100, 1e6) // impose some reasonable maximum (1M)
|
||||
|
||||
v := &visitor{
|
||||
events: make([]event, 0, capacity),
|
||||
stack: []item{{index: -1}}, // include an extra event so file nodes have a parent
|
||||
}
|
||||
events := make([]event, 0, capacity)
|
||||
|
||||
var stack []event
|
||||
stack = append(stack, event{}) // include an extra event so file nodes have a parent
|
||||
for _, f := range files {
|
||||
ast.Inspect(f, func(n ast.Node) bool {
|
||||
if n != nil {
|
||||
// push
|
||||
ev := event{
|
||||
node: n,
|
||||
typ: 0, // temporarily used to accumulate type bits of subtree
|
||||
index: len(events), // push event temporarily holds own index
|
||||
}
|
||||
stack = append(stack, ev)
|
||||
events = append(events, ev)
|
||||
} else {
|
||||
// pop
|
||||
top := len(stack) - 1
|
||||
ev := stack[top]
|
||||
typ := typeOf(ev.node)
|
||||
push := ev.index
|
||||
parent := top - 1
|
||||
|
||||
events[push].typ = typ // set type of push
|
||||
stack[parent].typ |= typ | ev.typ // parent's typ contains push and pop's typs.
|
||||
events[push].index = len(events) // make push refer to pop
|
||||
|
||||
stack = stack[:top]
|
||||
events = append(events, ev)
|
||||
}
|
||||
return true
|
||||
})
|
||||
for _, file := range files {
|
||||
walk(v, edge.Invalid, -1, file)
|
||||
}
|
||||
|
||||
return events
|
||||
return v.events
|
||||
}
|
||||
|
||||
type visitor struct {
|
||||
events []event
|
||||
stack []item
|
||||
}
|
||||
|
||||
type item struct {
|
||||
index int32 // index of current node's push event
|
||||
parentIndex int32 // index of parent node's push event
|
||||
typAccum uint64 // accumulated type bits of current node's descendents
|
||||
edgeKindAndIndex int32 // edge.Kind and index, bit packed
|
||||
}
|
||||
|
||||
func (v *visitor) push(ek edge.Kind, eindex int, node ast.Node) {
|
||||
var (
|
||||
index = int32(len(v.events))
|
||||
parentIndex = v.stack[len(v.stack)-1].index
|
||||
)
|
||||
v.events = append(v.events, event{
|
||||
node: node,
|
||||
parent: parentIndex,
|
||||
typ: typeOf(node),
|
||||
index: 0, // (pop index is set later by visitor.pop)
|
||||
})
|
||||
v.stack = append(v.stack, item{
|
||||
index: index,
|
||||
parentIndex: parentIndex,
|
||||
edgeKindAndIndex: packEdgeKindAndIndex(ek, eindex),
|
||||
})
|
||||
|
||||
// 2B nodes ought to be enough for anyone!
|
||||
if int32(len(v.events)) < 0 {
|
||||
panic("event index exceeded int32")
|
||||
}
|
||||
|
||||
// 32M elements in an []ast.Node ought to be enough for anyone!
|
||||
if ek2, eindex2 := unpackEdgeKindAndIndex(packEdgeKindAndIndex(ek, eindex)); ek2 != ek || eindex2 != eindex {
|
||||
panic("Node slice index exceeded uint25")
|
||||
}
|
||||
}
|
||||
|
||||
func (v *visitor) pop(node ast.Node) {
|
||||
top := len(v.stack) - 1
|
||||
current := v.stack[top]
|
||||
|
||||
push := &v.events[current.index]
|
||||
parent := &v.stack[top-1]
|
||||
|
||||
push.index = int32(len(v.events)) // make push event refer to pop
|
||||
parent.typAccum |= current.typAccum | push.typ // accumulate type bits into parent
|
||||
|
||||
v.stack = v.stack[:top]
|
||||
|
||||
v.events = append(v.events, event{
|
||||
node: node,
|
||||
typ: current.typAccum,
|
||||
index: current.index,
|
||||
parent: current.edgeKindAndIndex, // see [unpackEdgeKindAndIndex]
|
||||
})
|
||||
}
|
||||
|
||||
4
vendor/golang.org/x/tools/go/ast/inspector/iter.go
generated
vendored
4
vendor/golang.org/x/tools/go/ast/inspector/iter.go
generated
vendored
@@ -26,7 +26,7 @@ func (in *Inspector) PreorderSeq(types ...ast.Node) iter.Seq[ast.Node] {
|
||||
|
||||
return func(yield func(ast.Node) bool) {
|
||||
mask := maskOf(types)
|
||||
for i := 0; i < len(in.events); {
|
||||
for i := int32(0); i < int32(len(in.events)); {
|
||||
ev := in.events[i]
|
||||
if ev.index > i {
|
||||
// push
|
||||
@@ -63,7 +63,7 @@ func All[N interface {
|
||||
|
||||
mask := typeOf((N)(nil))
|
||||
return func(yield func(N) bool) {
|
||||
for i := 0; i < len(in.events); {
|
||||
for i := int32(0); i < int32(len(in.events)); {
|
||||
ev := in.events[i]
|
||||
if ev.index > i {
|
||||
// push
|
||||
|
||||
5
vendor/golang.org/x/tools/go/ast/inspector/typeof.go
generated
vendored
5
vendor/golang.org/x/tools/go/ast/inspector/typeof.go
generated
vendored
@@ -12,6 +12,8 @@ package inspector
|
||||
import (
|
||||
"go/ast"
|
||||
"math"
|
||||
|
||||
_ "unsafe"
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -215,8 +217,9 @@ func typeOf(n ast.Node) uint64 {
|
||||
return 0
|
||||
}
|
||||
|
||||
//go:linkname maskOf
|
||||
func maskOf(nodes []ast.Node) uint64 {
|
||||
if nodes == nil {
|
||||
if len(nodes) == 0 {
|
||||
return math.MaxUint64 // match all node types
|
||||
}
|
||||
var mask uint64
|
||||
|
||||
341
vendor/golang.org/x/tools/go/ast/inspector/walk.go
generated
vendored
Normal file
341
vendor/golang.org/x/tools/go/ast/inspector/walk.go
generated
vendored
Normal file
@@ -0,0 +1,341 @@
|
||||
// Copyright 2025 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 inspector
|
||||
|
||||
// This file is a fork of ast.Inspect to reduce unnecessary dynamic
|
||||
// calls and to gather edge information.
|
||||
//
|
||||
// Consistency with the original is ensured by TestInspectAllNodes.
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"go/ast"
|
||||
|
||||
"golang.org/x/tools/internal/astutil/edge"
|
||||
)
|
||||
|
||||
func walkList[N ast.Node](v *visitor, ek edge.Kind, list []N) {
|
||||
for i, node := range list {
|
||||
walk(v, ek, i, node)
|
||||
}
|
||||
}
|
||||
|
||||
func walk(v *visitor, ek edge.Kind, index int, node ast.Node) {
|
||||
v.push(ek, index, node)
|
||||
|
||||
// walk children
|
||||
// (the order of the cases matches the order
|
||||
// of the corresponding node types in ast.go)
|
||||
switch n := node.(type) {
|
||||
// Comments and fields
|
||||
case *ast.Comment:
|
||||
// nothing to do
|
||||
|
||||
case *ast.CommentGroup:
|
||||
walkList(v, edge.CommentGroup_List, n.List)
|
||||
|
||||
case *ast.Field:
|
||||
if n.Doc != nil {
|
||||
walk(v, edge.Field_Doc, -1, n.Doc)
|
||||
}
|
||||
walkList(v, edge.Field_Names, n.Names)
|
||||
if n.Type != nil {
|
||||
walk(v, edge.Field_Type, -1, n.Type)
|
||||
}
|
||||
if n.Tag != nil {
|
||||
walk(v, edge.Field_Tag, -1, n.Tag)
|
||||
}
|
||||
if n.Comment != nil {
|
||||
walk(v, edge.Field_Comment, -1, n.Comment)
|
||||
}
|
||||
|
||||
case *ast.FieldList:
|
||||
walkList(v, edge.FieldList_List, n.List)
|
||||
|
||||
// Expressions
|
||||
case *ast.BadExpr, *ast.Ident, *ast.BasicLit:
|
||||
// nothing to do
|
||||
|
||||
case *ast.Ellipsis:
|
||||
if n.Elt != nil {
|
||||
walk(v, edge.Ellipsis_Elt, -1, n.Elt)
|
||||
}
|
||||
|
||||
case *ast.FuncLit:
|
||||
walk(v, edge.FuncLit_Type, -1, n.Type)
|
||||
walk(v, edge.FuncLit_Body, -1, n.Body)
|
||||
|
||||
case *ast.CompositeLit:
|
||||
if n.Type != nil {
|
||||
walk(v, edge.CompositeLit_Type, -1, n.Type)
|
||||
}
|
||||
walkList(v, edge.CompositeLit_Elts, n.Elts)
|
||||
|
||||
case *ast.ParenExpr:
|
||||
walk(v, edge.ParenExpr_X, -1, n.X)
|
||||
|
||||
case *ast.SelectorExpr:
|
||||
walk(v, edge.SelectorExpr_X, -1, n.X)
|
||||
walk(v, edge.SelectorExpr_Sel, -1, n.Sel)
|
||||
|
||||
case *ast.IndexExpr:
|
||||
walk(v, edge.IndexExpr_X, -1, n.X)
|
||||
walk(v, edge.IndexExpr_Index, -1, n.Index)
|
||||
|
||||
case *ast.IndexListExpr:
|
||||
walk(v, edge.IndexListExpr_X, -1, n.X)
|
||||
walkList(v, edge.IndexListExpr_Indices, n.Indices)
|
||||
|
||||
case *ast.SliceExpr:
|
||||
walk(v, edge.SliceExpr_X, -1, n.X)
|
||||
if n.Low != nil {
|
||||
walk(v, edge.SliceExpr_Low, -1, n.Low)
|
||||
}
|
||||
if n.High != nil {
|
||||
walk(v, edge.SliceExpr_High, -1, n.High)
|
||||
}
|
||||
if n.Max != nil {
|
||||
walk(v, edge.SliceExpr_Max, -1, n.Max)
|
||||
}
|
||||
|
||||
case *ast.TypeAssertExpr:
|
||||
walk(v, edge.TypeAssertExpr_X, -1, n.X)
|
||||
if n.Type != nil {
|
||||
walk(v, edge.TypeAssertExpr_Type, -1, n.Type)
|
||||
}
|
||||
|
||||
case *ast.CallExpr:
|
||||
walk(v, edge.CallExpr_Fun, -1, n.Fun)
|
||||
walkList(v, edge.CallExpr_Args, n.Args)
|
||||
|
||||
case *ast.StarExpr:
|
||||
walk(v, edge.StarExpr_X, -1, n.X)
|
||||
|
||||
case *ast.UnaryExpr:
|
||||
walk(v, edge.UnaryExpr_X, -1, n.X)
|
||||
|
||||
case *ast.BinaryExpr:
|
||||
walk(v, edge.BinaryExpr_X, -1, n.X)
|
||||
walk(v, edge.BinaryExpr_Y, -1, n.Y)
|
||||
|
||||
case *ast.KeyValueExpr:
|
||||
walk(v, edge.KeyValueExpr_Key, -1, n.Key)
|
||||
walk(v, edge.KeyValueExpr_Value, -1, n.Value)
|
||||
|
||||
// Types
|
||||
case *ast.ArrayType:
|
||||
if n.Len != nil {
|
||||
walk(v, edge.ArrayType_Len, -1, n.Len)
|
||||
}
|
||||
walk(v, edge.ArrayType_Elt, -1, n.Elt)
|
||||
|
||||
case *ast.StructType:
|
||||
walk(v, edge.StructType_Fields, -1, n.Fields)
|
||||
|
||||
case *ast.FuncType:
|
||||
if n.TypeParams != nil {
|
||||
walk(v, edge.FuncType_TypeParams, -1, n.TypeParams)
|
||||
}
|
||||
if n.Params != nil {
|
||||
walk(v, edge.FuncType_Params, -1, n.Params)
|
||||
}
|
||||
if n.Results != nil {
|
||||
walk(v, edge.FuncType_Results, -1, n.Results)
|
||||
}
|
||||
|
||||
case *ast.InterfaceType:
|
||||
walk(v, edge.InterfaceType_Methods, -1, n.Methods)
|
||||
|
||||
case *ast.MapType:
|
||||
walk(v, edge.MapType_Key, -1, n.Key)
|
||||
walk(v, edge.MapType_Value, -1, n.Value)
|
||||
|
||||
case *ast.ChanType:
|
||||
walk(v, edge.ChanType_Value, -1, n.Value)
|
||||
|
||||
// Statements
|
||||
case *ast.BadStmt:
|
||||
// nothing to do
|
||||
|
||||
case *ast.DeclStmt:
|
||||
walk(v, edge.DeclStmt_Decl, -1, n.Decl)
|
||||
|
||||
case *ast.EmptyStmt:
|
||||
// nothing to do
|
||||
|
||||
case *ast.LabeledStmt:
|
||||
walk(v, edge.LabeledStmt_Label, -1, n.Label)
|
||||
walk(v, edge.LabeledStmt_Stmt, -1, n.Stmt)
|
||||
|
||||
case *ast.ExprStmt:
|
||||
walk(v, edge.ExprStmt_X, -1, n.X)
|
||||
|
||||
case *ast.SendStmt:
|
||||
walk(v, edge.SendStmt_Chan, -1, n.Chan)
|
||||
walk(v, edge.SendStmt_Value, -1, n.Value)
|
||||
|
||||
case *ast.IncDecStmt:
|
||||
walk(v, edge.IncDecStmt_X, -1, n.X)
|
||||
|
||||
case *ast.AssignStmt:
|
||||
walkList(v, edge.AssignStmt_Lhs, n.Lhs)
|
||||
walkList(v, edge.AssignStmt_Rhs, n.Rhs)
|
||||
|
||||
case *ast.GoStmt:
|
||||
walk(v, edge.GoStmt_Call, -1, n.Call)
|
||||
|
||||
case *ast.DeferStmt:
|
||||
walk(v, edge.DeferStmt_Call, -1, n.Call)
|
||||
|
||||
case *ast.ReturnStmt:
|
||||
walkList(v, edge.ReturnStmt_Results, n.Results)
|
||||
|
||||
case *ast.BranchStmt:
|
||||
if n.Label != nil {
|
||||
walk(v, edge.BranchStmt_Label, -1, n.Label)
|
||||
}
|
||||
|
||||
case *ast.BlockStmt:
|
||||
walkList(v, edge.BlockStmt_List, n.List)
|
||||
|
||||
case *ast.IfStmt:
|
||||
if n.Init != nil {
|
||||
walk(v, edge.IfStmt_Init, -1, n.Init)
|
||||
}
|
||||
walk(v, edge.IfStmt_Cond, -1, n.Cond)
|
||||
walk(v, edge.IfStmt_Body, -1, n.Body)
|
||||
if n.Else != nil {
|
||||
walk(v, edge.IfStmt_Else, -1, n.Else)
|
||||
}
|
||||
|
||||
case *ast.CaseClause:
|
||||
walkList(v, edge.CaseClause_List, n.List)
|
||||
walkList(v, edge.CaseClause_Body, n.Body)
|
||||
|
||||
case *ast.SwitchStmt:
|
||||
if n.Init != nil {
|
||||
walk(v, edge.SwitchStmt_Init, -1, n.Init)
|
||||
}
|
||||
if n.Tag != nil {
|
||||
walk(v, edge.SwitchStmt_Tag, -1, n.Tag)
|
||||
}
|
||||
walk(v, edge.SwitchStmt_Body, -1, n.Body)
|
||||
|
||||
case *ast.TypeSwitchStmt:
|
||||
if n.Init != nil {
|
||||
walk(v, edge.TypeSwitchStmt_Init, -1, n.Init)
|
||||
}
|
||||
walk(v, edge.TypeSwitchStmt_Assign, -1, n.Assign)
|
||||
walk(v, edge.TypeSwitchStmt_Body, -1, n.Body)
|
||||
|
||||
case *ast.CommClause:
|
||||
if n.Comm != nil {
|
||||
walk(v, edge.CommClause_Comm, -1, n.Comm)
|
||||
}
|
||||
walkList(v, edge.CommClause_Body, n.Body)
|
||||
|
||||
case *ast.SelectStmt:
|
||||
walk(v, edge.SelectStmt_Body, -1, n.Body)
|
||||
|
||||
case *ast.ForStmt:
|
||||
if n.Init != nil {
|
||||
walk(v, edge.ForStmt_Init, -1, n.Init)
|
||||
}
|
||||
if n.Cond != nil {
|
||||
walk(v, edge.ForStmt_Cond, -1, n.Cond)
|
||||
}
|
||||
if n.Post != nil {
|
||||
walk(v, edge.ForStmt_Post, -1, n.Post)
|
||||
}
|
||||
walk(v, edge.ForStmt_Body, -1, n.Body)
|
||||
|
||||
case *ast.RangeStmt:
|
||||
if n.Key != nil {
|
||||
walk(v, edge.RangeStmt_Key, -1, n.Key)
|
||||
}
|
||||
if n.Value != nil {
|
||||
walk(v, edge.RangeStmt_Value, -1, n.Value)
|
||||
}
|
||||
walk(v, edge.RangeStmt_X, -1, n.X)
|
||||
walk(v, edge.RangeStmt_Body, -1, n.Body)
|
||||
|
||||
// Declarations
|
||||
case *ast.ImportSpec:
|
||||
if n.Doc != nil {
|
||||
walk(v, edge.ImportSpec_Doc, -1, n.Doc)
|
||||
}
|
||||
if n.Name != nil {
|
||||
walk(v, edge.ImportSpec_Name, -1, n.Name)
|
||||
}
|
||||
walk(v, edge.ImportSpec_Path, -1, n.Path)
|
||||
if n.Comment != nil {
|
||||
walk(v, edge.ImportSpec_Comment, -1, n.Comment)
|
||||
}
|
||||
|
||||
case *ast.ValueSpec:
|
||||
if n.Doc != nil {
|
||||
walk(v, edge.ValueSpec_Doc, -1, n.Doc)
|
||||
}
|
||||
walkList(v, edge.ValueSpec_Names, n.Names)
|
||||
if n.Type != nil {
|
||||
walk(v, edge.ValueSpec_Type, -1, n.Type)
|
||||
}
|
||||
walkList(v, edge.ValueSpec_Values, n.Values)
|
||||
if n.Comment != nil {
|
||||
walk(v, edge.ValueSpec_Comment, -1, n.Comment)
|
||||
}
|
||||
|
||||
case *ast.TypeSpec:
|
||||
if n.Doc != nil {
|
||||
walk(v, edge.TypeSpec_Doc, -1, n.Doc)
|
||||
}
|
||||
walk(v, edge.TypeSpec_Name, -1, n.Name)
|
||||
if n.TypeParams != nil {
|
||||
walk(v, edge.TypeSpec_TypeParams, -1, n.TypeParams)
|
||||
}
|
||||
walk(v, edge.TypeSpec_Type, -1, n.Type)
|
||||
if n.Comment != nil {
|
||||
walk(v, edge.TypeSpec_Comment, -1, n.Comment)
|
||||
}
|
||||
|
||||
case *ast.BadDecl:
|
||||
// nothing to do
|
||||
|
||||
case *ast.GenDecl:
|
||||
if n.Doc != nil {
|
||||
walk(v, edge.GenDecl_Doc, -1, n.Doc)
|
||||
}
|
||||
walkList(v, edge.GenDecl_Specs, n.Specs)
|
||||
|
||||
case *ast.FuncDecl:
|
||||
if n.Doc != nil {
|
||||
walk(v, edge.FuncDecl_Doc, -1, n.Doc)
|
||||
}
|
||||
if n.Recv != nil {
|
||||
walk(v, edge.FuncDecl_Recv, -1, n.Recv)
|
||||
}
|
||||
walk(v, edge.FuncDecl_Name, -1, n.Name)
|
||||
walk(v, edge.FuncDecl_Type, -1, n.Type)
|
||||
if n.Body != nil {
|
||||
walk(v, edge.FuncDecl_Body, -1, n.Body)
|
||||
}
|
||||
|
||||
case *ast.File:
|
||||
if n.Doc != nil {
|
||||
walk(v, edge.File_Doc, -1, n.Doc)
|
||||
}
|
||||
walk(v, edge.File_Name, -1, n.Name)
|
||||
walkList(v, edge.File_Decls, n.Decls)
|
||||
// don't walk n.Comments - they have been
|
||||
// visited already through the individual
|
||||
// nodes
|
||||
|
||||
default:
|
||||
// (includes *ast.Package)
|
||||
panic(fmt.Sprintf("Walk: unexpected node type %T", n))
|
||||
}
|
||||
|
||||
v.pop(node)
|
||||
}
|
||||
5
vendor/golang.org/x/tools/go/packages/golist.go
generated
vendored
5
vendor/golang.org/x/tools/go/packages/golist.go
generated
vendored
@@ -322,6 +322,7 @@ type jsonPackage struct {
|
||||
ImportPath string
|
||||
Dir string
|
||||
Name string
|
||||
Target string
|
||||
Export string
|
||||
GoFiles []string
|
||||
CompiledGoFiles []string
|
||||
@@ -506,6 +507,7 @@ func (state *golistState) createDriverResponse(words ...string) (*DriverResponse
|
||||
Name: p.Name,
|
||||
ID: p.ImportPath,
|
||||
Dir: p.Dir,
|
||||
Target: p.Target,
|
||||
GoFiles: absJoin(p.Dir, p.GoFiles, p.CgoFiles),
|
||||
CompiledGoFiles: absJoin(p.Dir, p.CompiledGoFiles),
|
||||
OtherFiles: absJoin(p.Dir, otherFiles(p)...),
|
||||
@@ -811,6 +813,9 @@ func jsonFlag(cfg *Config, goVersion int) string {
|
||||
if cfg.Mode&NeedEmbedPatterns != 0 {
|
||||
addFields("EmbedPatterns")
|
||||
}
|
||||
if cfg.Mode&NeedTarget != 0 {
|
||||
addFields("Target")
|
||||
}
|
||||
return "-json=" + strings.Join(fields, ",")
|
||||
}
|
||||
|
||||
|
||||
1
vendor/golang.org/x/tools/go/packages/loadmode_string.go
generated
vendored
1
vendor/golang.org/x/tools/go/packages/loadmode_string.go
generated
vendored
@@ -27,6 +27,7 @@ var modes = [...]struct {
|
||||
{NeedModule, "NeedModule"},
|
||||
{NeedEmbedFiles, "NeedEmbedFiles"},
|
||||
{NeedEmbedPatterns, "NeedEmbedPatterns"},
|
||||
{NeedTarget, "NeedTarget"},
|
||||
}
|
||||
|
||||
func (mode LoadMode) String() string {
|
||||
|
||||
15
vendor/golang.org/x/tools/go/packages/packages.go
generated
vendored
15
vendor/golang.org/x/tools/go/packages/packages.go
generated
vendored
@@ -59,10 +59,10 @@ import (
|
||||
//
|
||||
// Unfortunately there are a number of open bugs related to
|
||||
// interactions among the LoadMode bits:
|
||||
// - https://github.com/golang/go/issues/56633
|
||||
// - https://github.com/golang/go/issues/56677
|
||||
// - https://github.com/golang/go/issues/58726
|
||||
// - https://github.com/golang/go/issues/63517
|
||||
// - https://go.dev/issue/56633
|
||||
// - https://go.dev/issue/56677
|
||||
// - https://go.dev/issue/58726
|
||||
// - https://go.dev/issue/63517
|
||||
type LoadMode int
|
||||
|
||||
const (
|
||||
@@ -118,6 +118,9 @@ const (
|
||||
// NeedEmbedPatterns adds EmbedPatterns.
|
||||
NeedEmbedPatterns
|
||||
|
||||
// NeedTarget adds Target.
|
||||
NeedTarget
|
||||
|
||||
// Be sure to update loadmode_string.go when adding new items!
|
||||
)
|
||||
|
||||
@@ -479,6 +482,10 @@ type Package struct {
|
||||
// information for the package as provided by the build system.
|
||||
ExportFile string
|
||||
|
||||
// Target is the absolute install path of the .a file, for libraries,
|
||||
// and of the executable file, for binaries.
|
||||
Target string
|
||||
|
||||
// Imports maps import paths appearing in the package's Go source files
|
||||
// to corresponding loaded Packages.
|
||||
Imports map[string]*Package
|
||||
|
||||
247
vendor/golang.org/x/tools/go/types/typeutil/map.go
generated
vendored
247
vendor/golang.org/x/tools/go/types/typeutil/map.go
generated
vendored
@@ -2,30 +2,35 @@
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
// Package typeutil defines various utilities for types, such as Map,
|
||||
// a mapping from types.Type to any values.
|
||||
package typeutil // import "golang.org/x/tools/go/types/typeutil"
|
||||
// Package typeutil defines various utilities for types, such as [Map],
|
||||
// a hash table that maps [types.Type] to any value.
|
||||
package typeutil
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
"go/types"
|
||||
"reflect"
|
||||
"hash/maphash"
|
||||
"unsafe"
|
||||
|
||||
"golang.org/x/tools/internal/typeparams"
|
||||
)
|
||||
|
||||
// Map is a hash-table-based mapping from types (types.Type) to
|
||||
// arbitrary any values. The concrete types that implement
|
||||
// arbitrary values. The concrete types that implement
|
||||
// the Type interface are pointers. Since they are not canonicalized,
|
||||
// == cannot be used to check for equivalence, and thus we cannot
|
||||
// simply use a Go map.
|
||||
//
|
||||
// Just as with map[K]V, a nil *Map is a valid empty map.
|
||||
//
|
||||
// Not thread-safe.
|
||||
// Read-only map operations ([Map.At], [Map.Len], and so on) may
|
||||
// safely be called concurrently.
|
||||
//
|
||||
// TODO(adonovan): deprecate in favor of https://go.dev/issues/69420
|
||||
// and 69559, if the latter proposals for a generic hash-map type and
|
||||
// a types.Hash function are accepted.
|
||||
type Map struct {
|
||||
hasher Hasher // shared by many Maps
|
||||
table map[uint32][]entry // maps hash to bucket; entry.key==nil means unused
|
||||
length int // number of map entries
|
||||
}
|
||||
@@ -36,35 +41,17 @@ type entry struct {
|
||||
value any
|
||||
}
|
||||
|
||||
// SetHasher sets the hasher used by Map.
|
||||
// SetHasher has no effect.
|
||||
//
|
||||
// All Hashers are functionally equivalent but contain internal state
|
||||
// used to cache the results of hashing previously seen types.
|
||||
//
|
||||
// A single Hasher created by MakeHasher() may be shared among many
|
||||
// Maps. This is recommended if the instances have many keys in
|
||||
// common, as it will amortize the cost of hash computation.
|
||||
//
|
||||
// A Hasher may grow without bound as new types are seen. Even when a
|
||||
// type is deleted from the map, the Hasher never shrinks, since other
|
||||
// types in the map may reference the deleted type indirectly.
|
||||
//
|
||||
// Hashers are not thread-safe, and read-only operations such as
|
||||
// Map.Lookup require updates to the hasher, so a full Mutex lock (not a
|
||||
// read-lock) is require around all Map operations if a shared
|
||||
// hasher is accessed from multiple threads.
|
||||
//
|
||||
// If SetHasher is not called, the Map will create a private hasher at
|
||||
// the first call to Insert.
|
||||
func (m *Map) SetHasher(hasher Hasher) {
|
||||
m.hasher = hasher
|
||||
}
|
||||
// It is a relic of an optimization that is no longer profitable. Do
|
||||
// not use [Hasher], [MakeHasher], or [SetHasher] in new code.
|
||||
func (m *Map) SetHasher(Hasher) {}
|
||||
|
||||
// Delete removes the entry with the given key, if any.
|
||||
// It returns true if the entry was found.
|
||||
func (m *Map) Delete(key types.Type) bool {
|
||||
if m != nil && m.table != nil {
|
||||
hash := m.hasher.Hash(key)
|
||||
hash := hash(key)
|
||||
bucket := m.table[hash]
|
||||
for i, e := range bucket {
|
||||
if e.key != nil && types.Identical(key, e.key) {
|
||||
@@ -83,7 +70,7 @@ func (m *Map) Delete(key types.Type) bool {
|
||||
// The result is nil if the entry is not present.
|
||||
func (m *Map) At(key types.Type) any {
|
||||
if m != nil && m.table != nil {
|
||||
for _, e := range m.table[m.hasher.Hash(key)] {
|
||||
for _, e := range m.table[hash(key)] {
|
||||
if e.key != nil && types.Identical(key, e.key) {
|
||||
return e.value
|
||||
}
|
||||
@@ -96,7 +83,7 @@ func (m *Map) At(key types.Type) any {
|
||||
// and returns the previous entry, if any.
|
||||
func (m *Map) Set(key types.Type, value any) (prev any) {
|
||||
if m.table != nil {
|
||||
hash := m.hasher.Hash(key)
|
||||
hash := hash(key)
|
||||
bucket := m.table[hash]
|
||||
var hole *entry
|
||||
for i, e := range bucket {
|
||||
@@ -115,10 +102,7 @@ func (m *Map) Set(key types.Type, value any) (prev any) {
|
||||
m.table[hash] = append(bucket, entry{key, value})
|
||||
}
|
||||
} else {
|
||||
if m.hasher.memo == nil {
|
||||
m.hasher = MakeHasher()
|
||||
}
|
||||
hash := m.hasher.Hash(key)
|
||||
hash := hash(key)
|
||||
m.table = map[uint32][]entry{hash: {entry{key, value}}}
|
||||
}
|
||||
|
||||
@@ -195,53 +179,35 @@ func (m *Map) KeysString() string {
|
||||
return m.toString(false)
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
// Hasher
|
||||
// -- Hasher --
|
||||
|
||||
// A Hasher maps each type to its hash value.
|
||||
// For efficiency, a hasher uses memoization; thus its memory
|
||||
// footprint grows monotonically over time.
|
||||
// Hashers are not thread-safe.
|
||||
// Hashers have reference semantics.
|
||||
// Call MakeHasher to create a Hasher.
|
||||
type Hasher struct {
|
||||
memo map[types.Type]uint32
|
||||
|
||||
// ptrMap records pointer identity.
|
||||
ptrMap map[any]uint32
|
||||
|
||||
// sigTParams holds type parameters from the signature being hashed.
|
||||
// Signatures are considered identical modulo renaming of type parameters, so
|
||||
// within the scope of a signature type the identity of the signature's type
|
||||
// parameters is just their index.
|
||||
//
|
||||
// Since the language does not currently support referring to uninstantiated
|
||||
// generic types or functions, and instantiated signatures do not have type
|
||||
// parameter lists, we should never encounter a second non-empty type
|
||||
// parameter list when hashing a generic signature.
|
||||
sigTParams *types.TypeParamList
|
||||
// hash returns the hash of type t.
|
||||
// TODO(adonovan): replace by types.Hash when Go proposal #69420 is accepted.
|
||||
func hash(t types.Type) uint32 {
|
||||
return theHasher.Hash(t)
|
||||
}
|
||||
|
||||
// MakeHasher returns a new Hasher instance.
|
||||
func MakeHasher() Hasher {
|
||||
return Hasher{
|
||||
memo: make(map[types.Type]uint32),
|
||||
ptrMap: make(map[any]uint32),
|
||||
sigTParams: nil,
|
||||
}
|
||||
}
|
||||
// A Hasher provides a [Hasher.Hash] method to map a type to its hash value.
|
||||
// Hashers are stateless, and all are equivalent.
|
||||
type Hasher struct{}
|
||||
|
||||
var theHasher Hasher
|
||||
|
||||
// MakeHasher returns Hasher{}.
|
||||
// Hashers are stateless; all are equivalent.
|
||||
func MakeHasher() Hasher { return theHasher }
|
||||
|
||||
// Hash computes a hash value for the given type t such that
|
||||
// Identical(t, t') => Hash(t) == Hash(t').
|
||||
func (h Hasher) Hash(t types.Type) uint32 {
|
||||
hash, ok := h.memo[t]
|
||||
if !ok {
|
||||
hash = h.hashFor(t)
|
||||
h.memo[t] = hash
|
||||
}
|
||||
return hash
|
||||
return hasher{inGenericSig: false}.hash(t)
|
||||
}
|
||||
|
||||
// hasher holds the state of a single Hash traversal: whether we are
|
||||
// inside the signature of a generic function; this is used to
|
||||
// optimize [hasher.hashTypeParam].
|
||||
type hasher struct{ inGenericSig bool }
|
||||
|
||||
// hashString computes the Fowler–Noll–Vo hash of s.
|
||||
func hashString(s string) uint32 {
|
||||
var h uint32
|
||||
@@ -252,21 +218,21 @@ func hashString(s string) uint32 {
|
||||
return h
|
||||
}
|
||||
|
||||
// hashFor computes the hash of t.
|
||||
func (h Hasher) hashFor(t types.Type) uint32 {
|
||||
// hash computes the hash of t.
|
||||
func (h hasher) hash(t types.Type) uint32 {
|
||||
// See Identical for rationale.
|
||||
switch t := t.(type) {
|
||||
case *types.Basic:
|
||||
return uint32(t.Kind())
|
||||
|
||||
case *types.Alias:
|
||||
return h.Hash(types.Unalias(t))
|
||||
return h.hash(types.Unalias(t))
|
||||
|
||||
case *types.Array:
|
||||
return 9043 + 2*uint32(t.Len()) + 3*h.Hash(t.Elem())
|
||||
return 9043 + 2*uint32(t.Len()) + 3*h.hash(t.Elem())
|
||||
|
||||
case *types.Slice:
|
||||
return 9049 + 2*h.Hash(t.Elem())
|
||||
return 9049 + 2*h.hash(t.Elem())
|
||||
|
||||
case *types.Struct:
|
||||
var hash uint32 = 9059
|
||||
@@ -277,12 +243,12 @@ func (h Hasher) hashFor(t types.Type) uint32 {
|
||||
}
|
||||
hash += hashString(t.Tag(i))
|
||||
hash += hashString(f.Name()) // (ignore f.Pkg)
|
||||
hash += h.Hash(f.Type())
|
||||
hash += h.hash(f.Type())
|
||||
}
|
||||
return hash
|
||||
|
||||
case *types.Pointer:
|
||||
return 9067 + 2*h.Hash(t.Elem())
|
||||
return 9067 + 2*h.hash(t.Elem())
|
||||
|
||||
case *types.Signature:
|
||||
var hash uint32 = 9091
|
||||
@@ -290,33 +256,14 @@ func (h Hasher) hashFor(t types.Type) uint32 {
|
||||
hash *= 8863
|
||||
}
|
||||
|
||||
// Use a separate hasher for types inside of the signature, where type
|
||||
// parameter identity is modified to be (index, constraint). We must use a
|
||||
// new memo for this hasher as type identity may be affected by this
|
||||
// masking. For example, in func[T any](*T), the identity of *T depends on
|
||||
// whether we are mapping the argument in isolation, or recursively as part
|
||||
// of hashing the signature.
|
||||
//
|
||||
// We should never encounter a generic signature while hashing another
|
||||
// generic signature, but defensively set sigTParams only if h.mask is
|
||||
// unset.
|
||||
tparams := t.TypeParams()
|
||||
if h.sigTParams == nil && tparams.Len() != 0 {
|
||||
h = Hasher{
|
||||
// There may be something more efficient than discarding the existing
|
||||
// memo, but it would require detecting whether types are 'tainted' by
|
||||
// references to type parameters.
|
||||
memo: make(map[types.Type]uint32),
|
||||
// Re-using ptrMap ensures that pointer identity is preserved in this
|
||||
// hasher.
|
||||
ptrMap: h.ptrMap,
|
||||
sigTParams: tparams,
|
||||
}
|
||||
}
|
||||
if n := tparams.Len(); n > 0 {
|
||||
h.inGenericSig = true // affects constraints, params, and results
|
||||
|
||||
for i := 0; i < tparams.Len(); i++ {
|
||||
tparam := tparams.At(i)
|
||||
hash += 7 * h.Hash(tparam.Constraint())
|
||||
for i := range n {
|
||||
tparam := tparams.At(i)
|
||||
hash += 7 * h.hash(tparam.Constraint())
|
||||
}
|
||||
}
|
||||
|
||||
return hash + 3*h.hashTuple(t.Params()) + 5*h.hashTuple(t.Results())
|
||||
@@ -350,17 +297,17 @@ func (h Hasher) hashFor(t types.Type) uint32 {
|
||||
return hash
|
||||
|
||||
case *types.Map:
|
||||
return 9109 + 2*h.Hash(t.Key()) + 3*h.Hash(t.Elem())
|
||||
return 9109 + 2*h.hash(t.Key()) + 3*h.hash(t.Elem())
|
||||
|
||||
case *types.Chan:
|
||||
return 9127 + 2*uint32(t.Dir()) + 3*h.Hash(t.Elem())
|
||||
return 9127 + 2*uint32(t.Dir()) + 3*h.hash(t.Elem())
|
||||
|
||||
case *types.Named:
|
||||
hash := h.hashPtr(t.Obj())
|
||||
hash := h.hashTypeName(t.Obj())
|
||||
targs := t.TypeArgs()
|
||||
for i := 0; i < targs.Len(); i++ {
|
||||
targ := targs.At(i)
|
||||
hash += 2 * h.Hash(targ)
|
||||
hash += 2 * h.hash(targ)
|
||||
}
|
||||
return hash
|
||||
|
||||
@@ -374,17 +321,17 @@ func (h Hasher) hashFor(t types.Type) uint32 {
|
||||
panic(fmt.Sprintf("%T: %v", t, t))
|
||||
}
|
||||
|
||||
func (h Hasher) hashTuple(tuple *types.Tuple) uint32 {
|
||||
func (h hasher) hashTuple(tuple *types.Tuple) uint32 {
|
||||
// See go/types.identicalTypes for rationale.
|
||||
n := tuple.Len()
|
||||
hash := 9137 + 2*uint32(n)
|
||||
for i := 0; i < n; i++ {
|
||||
hash += 3 * h.Hash(tuple.At(i).Type())
|
||||
for i := range n {
|
||||
hash += 3 * h.hash(tuple.At(i).Type())
|
||||
}
|
||||
return hash
|
||||
}
|
||||
|
||||
func (h Hasher) hashUnion(t *types.Union) uint32 {
|
||||
func (h hasher) hashUnion(t *types.Union) uint32 {
|
||||
// Hash type restrictions.
|
||||
terms, err := typeparams.UnionTermSet(t)
|
||||
// if err != nil t has invalid type restrictions. Fall back on a non-zero
|
||||
@@ -395,11 +342,11 @@ func (h Hasher) hashUnion(t *types.Union) uint32 {
|
||||
return h.hashTermSet(terms)
|
||||
}
|
||||
|
||||
func (h Hasher) hashTermSet(terms []*types.Term) uint32 {
|
||||
func (h hasher) hashTermSet(terms []*types.Term) uint32 {
|
||||
hash := 9157 + 2*uint32(len(terms))
|
||||
for _, term := range terms {
|
||||
// term order is not significant.
|
||||
termHash := h.Hash(term.Type())
|
||||
termHash := h.hash(term.Type())
|
||||
if term.Tilde() {
|
||||
termHash *= 9161
|
||||
}
|
||||
@@ -408,36 +355,42 @@ func (h Hasher) hashTermSet(terms []*types.Term) uint32 {
|
||||
return hash
|
||||
}
|
||||
|
||||
// hashTypeParam returns a hash of the type parameter t, with a hash value
|
||||
// depending on whether t is contained in h.sigTParams.
|
||||
//
|
||||
// If h.sigTParams is set and contains t, then we are in the process of hashing
|
||||
// a signature, and the hash value of t must depend only on t's index and
|
||||
// constraint: signatures are considered identical modulo type parameter
|
||||
// renaming. To avoid infinite recursion, we only hash the type parameter
|
||||
// index, and rely on types.Identical to handle signatures where constraints
|
||||
// are not identical.
|
||||
//
|
||||
// Otherwise the hash of t depends only on t's pointer identity.
|
||||
func (h Hasher) hashTypeParam(t *types.TypeParam) uint32 {
|
||||
if h.sigTParams != nil {
|
||||
i := t.Index()
|
||||
if i >= 0 && i < h.sigTParams.Len() && t == h.sigTParams.At(i) {
|
||||
return 9173 + 3*uint32(i)
|
||||
}
|
||||
// hashTypeParam returns the hash of a type parameter.
|
||||
func (h hasher) hashTypeParam(t *types.TypeParam) uint32 {
|
||||
// Within the signature of a generic function, TypeParams are
|
||||
// identical if they have the same index and constraint, so we
|
||||
// hash them based on index.
|
||||
//
|
||||
// When we are outside a generic function, free TypeParams are
|
||||
// identical iff they are the same object, so we can use a
|
||||
// more discriminating hash consistent with object identity.
|
||||
// This optimization saves [Map] about 4% when hashing all the
|
||||
// types.Info.Types in the forward closure of net/http.
|
||||
if !h.inGenericSig {
|
||||
// Optimization: outside a generic function signature,
|
||||
// use a more discrimating hash consistent with object identity.
|
||||
return h.hashTypeName(t.Obj())
|
||||
}
|
||||
return h.hashPtr(t.Obj())
|
||||
return 9173 + 3*uint32(t.Index())
|
||||
}
|
||||
|
||||
// hashPtr hashes the pointer identity of ptr. It uses h.ptrMap to ensure that
|
||||
// pointers values are not dependent on the GC.
|
||||
func (h Hasher) hashPtr(ptr any) uint32 {
|
||||
if hash, ok := h.ptrMap[ptr]; ok {
|
||||
return hash
|
||||
}
|
||||
hash := uint32(reflect.ValueOf(ptr).Pointer())
|
||||
h.ptrMap[ptr] = hash
|
||||
return hash
|
||||
var theSeed = maphash.MakeSeed()
|
||||
|
||||
// hashTypeName hashes the pointer of tname.
|
||||
func (hasher) hashTypeName(tname *types.TypeName) uint32 {
|
||||
// Since types.Identical uses == to compare TypeNames,
|
||||
// the Hash function uses maphash.Comparable.
|
||||
// TODO(adonovan): or will, when it becomes available in go1.24.
|
||||
// In the meantime we use the pointer's numeric value.
|
||||
//
|
||||
// hash := maphash.Comparable(theSeed, tname)
|
||||
//
|
||||
// (Another approach would be to hash the name and package
|
||||
// path, and whether or not it is a package-level typename. It
|
||||
// is rare for a package to define multiple local types with
|
||||
// the same name.)
|
||||
hash := uintptr(unsafe.Pointer(tname))
|
||||
return uint32(hash ^ (hash >> 32))
|
||||
}
|
||||
|
||||
// shallowHash computes a hash of t without looking at any of its
|
||||
@@ -454,7 +407,7 @@ func (h Hasher) hashPtr(ptr any) uint32 {
|
||||
// include m itself; there is no mention of the named type X that
|
||||
// might help us break the cycle.
|
||||
// (See comment in go/types.identical, case *Interface, for more.)
|
||||
func (h Hasher) shallowHash(t types.Type) uint32 {
|
||||
func (h hasher) shallowHash(t types.Type) uint32 {
|
||||
// t is the type of an interface method (Signature),
|
||||
// its params or results (Tuples), or their immediate
|
||||
// elements (mostly Slice, Pointer, Basic, Named),
|
||||
@@ -475,7 +428,7 @@ func (h Hasher) shallowHash(t types.Type) uint32 {
|
||||
case *types.Tuple:
|
||||
n := t.Len()
|
||||
hash := 9137 + 2*uint32(n)
|
||||
for i := 0; i < n; i++ {
|
||||
for i := range n {
|
||||
hash += 53471161 * h.shallowHash(t.At(i).Type())
|
||||
}
|
||||
return hash
|
||||
@@ -508,10 +461,10 @@ func (h Hasher) shallowHash(t types.Type) uint32 {
|
||||
return 9127
|
||||
|
||||
case *types.Named:
|
||||
return h.hashPtr(t.Obj())
|
||||
return h.hashTypeName(t.Obj())
|
||||
|
||||
case *types.TypeParam:
|
||||
return h.hashPtr(t.Obj())
|
||||
return h.hashTypeParam(t)
|
||||
}
|
||||
panic(fmt.Sprintf("shallowHash: %T: %v", t, t))
|
||||
}
|
||||
|
||||
295
vendor/golang.org/x/tools/internal/astutil/edge/edge.go
generated
vendored
Normal file
295
vendor/golang.org/x/tools/internal/astutil/edge/edge.go
generated
vendored
Normal file
@@ -0,0 +1,295 @@
|
||||
// Copyright 2025 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 edge defines identifiers for each field of an ast.Node
|
||||
// struct type that refers to another Node.
|
||||
package edge
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"go/ast"
|
||||
"reflect"
|
||||
)
|
||||
|
||||
// A Kind describes a field of an ast.Node struct.
|
||||
type Kind uint8
|
||||
|
||||
// String returns a description of the edge kind.
|
||||
func (k Kind) String() string {
|
||||
if k == Invalid {
|
||||
return "<invalid>"
|
||||
}
|
||||
info := fieldInfos[k]
|
||||
return fmt.Sprintf("%v.%s", info.nodeType.Elem().Name(), info.name)
|
||||
}
|
||||
|
||||
// NodeType returns the pointer-to-struct type of the ast.Node implementation.
|
||||
func (k Kind) NodeType() reflect.Type { return fieldInfos[k].nodeType }
|
||||
|
||||
// FieldName returns the name of the field.
|
||||
func (k Kind) FieldName() string { return fieldInfos[k].name }
|
||||
|
||||
// FieldType returns the declared type of the field.
|
||||
func (k Kind) FieldType() reflect.Type { return fieldInfos[k].fieldType }
|
||||
|
||||
// Get returns the direct child of n identified by (k, idx).
|
||||
// n's type must match k.NodeType().
|
||||
// idx must be a valid slice index, or -1 for a non-slice.
|
||||
func (k Kind) Get(n ast.Node, idx int) ast.Node {
|
||||
if k.NodeType() != reflect.TypeOf(n) {
|
||||
panic(fmt.Sprintf("%v.Get(%T): invalid node type", k, n))
|
||||
}
|
||||
v := reflect.ValueOf(n).Elem().Field(fieldInfos[k].index)
|
||||
if idx != -1 {
|
||||
v = v.Index(idx) // asserts valid index
|
||||
} else {
|
||||
// (The type assertion below asserts that v is not a slice.)
|
||||
}
|
||||
return v.Interface().(ast.Node) // may be nil
|
||||
}
|
||||
|
||||
const (
|
||||
Invalid Kind = iota // for nodes at the root of the traversal
|
||||
|
||||
// Kinds are sorted alphabetically.
|
||||
// Numbering is not stable.
|
||||
// Each is named Type_Field, where Type is the
|
||||
// ast.Node struct type and Field is the name of the field
|
||||
|
||||
ArrayType_Elt
|
||||
ArrayType_Len
|
||||
AssignStmt_Lhs
|
||||
AssignStmt_Rhs
|
||||
BinaryExpr_X
|
||||
BinaryExpr_Y
|
||||
BlockStmt_List
|
||||
BranchStmt_Label
|
||||
CallExpr_Args
|
||||
CallExpr_Fun
|
||||
CaseClause_Body
|
||||
CaseClause_List
|
||||
ChanType_Value
|
||||
CommClause_Body
|
||||
CommClause_Comm
|
||||
CommentGroup_List
|
||||
CompositeLit_Elts
|
||||
CompositeLit_Type
|
||||
DeclStmt_Decl
|
||||
DeferStmt_Call
|
||||
Ellipsis_Elt
|
||||
ExprStmt_X
|
||||
FieldList_List
|
||||
Field_Comment
|
||||
Field_Doc
|
||||
Field_Names
|
||||
Field_Tag
|
||||
Field_Type
|
||||
File_Decls
|
||||
File_Doc
|
||||
File_Name
|
||||
ForStmt_Body
|
||||
ForStmt_Cond
|
||||
ForStmt_Init
|
||||
ForStmt_Post
|
||||
FuncDecl_Body
|
||||
FuncDecl_Doc
|
||||
FuncDecl_Name
|
||||
FuncDecl_Recv
|
||||
FuncDecl_Type
|
||||
FuncLit_Body
|
||||
FuncLit_Type
|
||||
FuncType_Params
|
||||
FuncType_Results
|
||||
FuncType_TypeParams
|
||||
GenDecl_Doc
|
||||
GenDecl_Specs
|
||||
GoStmt_Call
|
||||
IfStmt_Body
|
||||
IfStmt_Cond
|
||||
IfStmt_Else
|
||||
IfStmt_Init
|
||||
ImportSpec_Comment
|
||||
ImportSpec_Doc
|
||||
ImportSpec_Name
|
||||
ImportSpec_Path
|
||||
IncDecStmt_X
|
||||
IndexExpr_Index
|
||||
IndexExpr_X
|
||||
IndexListExpr_Indices
|
||||
IndexListExpr_X
|
||||
InterfaceType_Methods
|
||||
KeyValueExpr_Key
|
||||
KeyValueExpr_Value
|
||||
LabeledStmt_Label
|
||||
LabeledStmt_Stmt
|
||||
MapType_Key
|
||||
MapType_Value
|
||||
ParenExpr_X
|
||||
RangeStmt_Body
|
||||
RangeStmt_Key
|
||||
RangeStmt_Value
|
||||
RangeStmt_X
|
||||
ReturnStmt_Results
|
||||
SelectStmt_Body
|
||||
SelectorExpr_Sel
|
||||
SelectorExpr_X
|
||||
SendStmt_Chan
|
||||
SendStmt_Value
|
||||
SliceExpr_High
|
||||
SliceExpr_Low
|
||||
SliceExpr_Max
|
||||
SliceExpr_X
|
||||
StarExpr_X
|
||||
StructType_Fields
|
||||
SwitchStmt_Body
|
||||
SwitchStmt_Init
|
||||
SwitchStmt_Tag
|
||||
TypeAssertExpr_Type
|
||||
TypeAssertExpr_X
|
||||
TypeSpec_Comment
|
||||
TypeSpec_Doc
|
||||
TypeSpec_Name
|
||||
TypeSpec_Type
|
||||
TypeSpec_TypeParams
|
||||
TypeSwitchStmt_Assign
|
||||
TypeSwitchStmt_Body
|
||||
TypeSwitchStmt_Init
|
||||
UnaryExpr_X
|
||||
ValueSpec_Comment
|
||||
ValueSpec_Doc
|
||||
ValueSpec_Names
|
||||
ValueSpec_Type
|
||||
ValueSpec_Values
|
||||
|
||||
maxKind
|
||||
)
|
||||
|
||||
// Assert that the encoding fits in 7 bits,
|
||||
// as the inspector relies on this.
|
||||
// (We are currently at 104.)
|
||||
var _ = [1 << 7]struct{}{}[maxKind]
|
||||
|
||||
type fieldInfo struct {
|
||||
nodeType reflect.Type // pointer-to-struct type of ast.Node implementation
|
||||
name string
|
||||
index int
|
||||
fieldType reflect.Type
|
||||
}
|
||||
|
||||
func info[N ast.Node](fieldName string) fieldInfo {
|
||||
nodePtrType := reflect.TypeFor[N]()
|
||||
f, ok := nodePtrType.Elem().FieldByName(fieldName)
|
||||
if !ok {
|
||||
panic(fieldName)
|
||||
}
|
||||
return fieldInfo{nodePtrType, fieldName, f.Index[0], f.Type}
|
||||
}
|
||||
|
||||
var fieldInfos = [...]fieldInfo{
|
||||
Invalid: {},
|
||||
ArrayType_Elt: info[*ast.ArrayType]("Elt"),
|
||||
ArrayType_Len: info[*ast.ArrayType]("Len"),
|
||||
AssignStmt_Lhs: info[*ast.AssignStmt]("Lhs"),
|
||||
AssignStmt_Rhs: info[*ast.AssignStmt]("Rhs"),
|
||||
BinaryExpr_X: info[*ast.BinaryExpr]("X"),
|
||||
BinaryExpr_Y: info[*ast.BinaryExpr]("Y"),
|
||||
BlockStmt_List: info[*ast.BlockStmt]("List"),
|
||||
BranchStmt_Label: info[*ast.BranchStmt]("Label"),
|
||||
CallExpr_Args: info[*ast.CallExpr]("Args"),
|
||||
CallExpr_Fun: info[*ast.CallExpr]("Fun"),
|
||||
CaseClause_Body: info[*ast.CaseClause]("Body"),
|
||||
CaseClause_List: info[*ast.CaseClause]("List"),
|
||||
ChanType_Value: info[*ast.ChanType]("Value"),
|
||||
CommClause_Body: info[*ast.CommClause]("Body"),
|
||||
CommClause_Comm: info[*ast.CommClause]("Comm"),
|
||||
CommentGroup_List: info[*ast.CommentGroup]("List"),
|
||||
CompositeLit_Elts: info[*ast.CompositeLit]("Elts"),
|
||||
CompositeLit_Type: info[*ast.CompositeLit]("Type"),
|
||||
DeclStmt_Decl: info[*ast.DeclStmt]("Decl"),
|
||||
DeferStmt_Call: info[*ast.DeferStmt]("Call"),
|
||||
Ellipsis_Elt: info[*ast.Ellipsis]("Elt"),
|
||||
ExprStmt_X: info[*ast.ExprStmt]("X"),
|
||||
FieldList_List: info[*ast.FieldList]("List"),
|
||||
Field_Comment: info[*ast.Field]("Comment"),
|
||||
Field_Doc: info[*ast.Field]("Doc"),
|
||||
Field_Names: info[*ast.Field]("Names"),
|
||||
Field_Tag: info[*ast.Field]("Tag"),
|
||||
Field_Type: info[*ast.Field]("Type"),
|
||||
File_Decls: info[*ast.File]("Decls"),
|
||||
File_Doc: info[*ast.File]("Doc"),
|
||||
File_Name: info[*ast.File]("Name"),
|
||||
ForStmt_Body: info[*ast.ForStmt]("Body"),
|
||||
ForStmt_Cond: info[*ast.ForStmt]("Cond"),
|
||||
ForStmt_Init: info[*ast.ForStmt]("Init"),
|
||||
ForStmt_Post: info[*ast.ForStmt]("Post"),
|
||||
FuncDecl_Body: info[*ast.FuncDecl]("Body"),
|
||||
FuncDecl_Doc: info[*ast.FuncDecl]("Doc"),
|
||||
FuncDecl_Name: info[*ast.FuncDecl]("Name"),
|
||||
FuncDecl_Recv: info[*ast.FuncDecl]("Recv"),
|
||||
FuncDecl_Type: info[*ast.FuncDecl]("Type"),
|
||||
FuncLit_Body: info[*ast.FuncLit]("Body"),
|
||||
FuncLit_Type: info[*ast.FuncLit]("Type"),
|
||||
FuncType_Params: info[*ast.FuncType]("Params"),
|
||||
FuncType_Results: info[*ast.FuncType]("Results"),
|
||||
FuncType_TypeParams: info[*ast.FuncType]("TypeParams"),
|
||||
GenDecl_Doc: info[*ast.GenDecl]("Doc"),
|
||||
GenDecl_Specs: info[*ast.GenDecl]("Specs"),
|
||||
GoStmt_Call: info[*ast.GoStmt]("Call"),
|
||||
IfStmt_Body: info[*ast.IfStmt]("Body"),
|
||||
IfStmt_Cond: info[*ast.IfStmt]("Cond"),
|
||||
IfStmt_Else: info[*ast.IfStmt]("Else"),
|
||||
IfStmt_Init: info[*ast.IfStmt]("Init"),
|
||||
ImportSpec_Comment: info[*ast.ImportSpec]("Comment"),
|
||||
ImportSpec_Doc: info[*ast.ImportSpec]("Doc"),
|
||||
ImportSpec_Name: info[*ast.ImportSpec]("Name"),
|
||||
ImportSpec_Path: info[*ast.ImportSpec]("Path"),
|
||||
IncDecStmt_X: info[*ast.IncDecStmt]("X"),
|
||||
IndexExpr_Index: info[*ast.IndexExpr]("Index"),
|
||||
IndexExpr_X: info[*ast.IndexExpr]("X"),
|
||||
IndexListExpr_Indices: info[*ast.IndexListExpr]("Indices"),
|
||||
IndexListExpr_X: info[*ast.IndexListExpr]("X"),
|
||||
InterfaceType_Methods: info[*ast.InterfaceType]("Methods"),
|
||||
KeyValueExpr_Key: info[*ast.KeyValueExpr]("Key"),
|
||||
KeyValueExpr_Value: info[*ast.KeyValueExpr]("Value"),
|
||||
LabeledStmt_Label: info[*ast.LabeledStmt]("Label"),
|
||||
LabeledStmt_Stmt: info[*ast.LabeledStmt]("Stmt"),
|
||||
MapType_Key: info[*ast.MapType]("Key"),
|
||||
MapType_Value: info[*ast.MapType]("Value"),
|
||||
ParenExpr_X: info[*ast.ParenExpr]("X"),
|
||||
RangeStmt_Body: info[*ast.RangeStmt]("Body"),
|
||||
RangeStmt_Key: info[*ast.RangeStmt]("Key"),
|
||||
RangeStmt_Value: info[*ast.RangeStmt]("Value"),
|
||||
RangeStmt_X: info[*ast.RangeStmt]("X"),
|
||||
ReturnStmt_Results: info[*ast.ReturnStmt]("Results"),
|
||||
SelectStmt_Body: info[*ast.SelectStmt]("Body"),
|
||||
SelectorExpr_Sel: info[*ast.SelectorExpr]("Sel"),
|
||||
SelectorExpr_X: info[*ast.SelectorExpr]("X"),
|
||||
SendStmt_Chan: info[*ast.SendStmt]("Chan"),
|
||||
SendStmt_Value: info[*ast.SendStmt]("Value"),
|
||||
SliceExpr_High: info[*ast.SliceExpr]("High"),
|
||||
SliceExpr_Low: info[*ast.SliceExpr]("Low"),
|
||||
SliceExpr_Max: info[*ast.SliceExpr]("Max"),
|
||||
SliceExpr_X: info[*ast.SliceExpr]("X"),
|
||||
StarExpr_X: info[*ast.StarExpr]("X"),
|
||||
StructType_Fields: info[*ast.StructType]("Fields"),
|
||||
SwitchStmt_Body: info[*ast.SwitchStmt]("Body"),
|
||||
SwitchStmt_Init: info[*ast.SwitchStmt]("Init"),
|
||||
SwitchStmt_Tag: info[*ast.SwitchStmt]("Tag"),
|
||||
TypeAssertExpr_Type: info[*ast.TypeAssertExpr]("Type"),
|
||||
TypeAssertExpr_X: info[*ast.TypeAssertExpr]("X"),
|
||||
TypeSpec_Comment: info[*ast.TypeSpec]("Comment"),
|
||||
TypeSpec_Doc: info[*ast.TypeSpec]("Doc"),
|
||||
TypeSpec_Name: info[*ast.TypeSpec]("Name"),
|
||||
TypeSpec_Type: info[*ast.TypeSpec]("Type"),
|
||||
TypeSpec_TypeParams: info[*ast.TypeSpec]("TypeParams"),
|
||||
TypeSwitchStmt_Assign: info[*ast.TypeSwitchStmt]("Assign"),
|
||||
TypeSwitchStmt_Body: info[*ast.TypeSwitchStmt]("Body"),
|
||||
TypeSwitchStmt_Init: info[*ast.TypeSwitchStmt]("Init"),
|
||||
UnaryExpr_X: info[*ast.UnaryExpr]("X"),
|
||||
ValueSpec_Comment: info[*ast.ValueSpec]("Comment"),
|
||||
ValueSpec_Doc: info[*ast.ValueSpec]("Doc"),
|
||||
ValueSpec_Names: info[*ast.ValueSpec]("Names"),
|
||||
ValueSpec_Type: info[*ast.ValueSpec]("Type"),
|
||||
ValueSpec_Values: info[*ast.ValueSpec]("Values"),
|
||||
}
|
||||
455
vendor/golang.org/x/tools/internal/gcimporter/exportdata.go
generated
vendored
455
vendor/golang.org/x/tools/internal/gcimporter/exportdata.go
generated
vendored
@@ -2,52 +2,183 @@
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
// This file is a copy of $GOROOT/src/go/internal/gcimporter/exportdata.go.
|
||||
|
||||
// This file implements FindExportData.
|
||||
// This file should be kept in sync with $GOROOT/src/internal/exportdata/exportdata.go.
|
||||
// This file also additionally implements FindExportData for gcexportdata.NewReader.
|
||||
|
||||
package gcimporter
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
"bytes"
|
||||
"errors"
|
||||
"fmt"
|
||||
"go/build"
|
||||
"io"
|
||||
"strconv"
|
||||
"os"
|
||||
"os/exec"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"sync"
|
||||
)
|
||||
|
||||
func readGopackHeader(r *bufio.Reader) (name string, size int64, err error) {
|
||||
// See $GOROOT/include/ar.h.
|
||||
hdr := make([]byte, 16+12+6+6+8+10+2)
|
||||
_, err = io.ReadFull(r, hdr)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
// leave for debugging
|
||||
if false {
|
||||
fmt.Printf("header: %s", hdr)
|
||||
}
|
||||
s := strings.TrimSpace(string(hdr[16+12+6+6+8:][:10]))
|
||||
length, err := strconv.Atoi(s)
|
||||
size = int64(length)
|
||||
if err != nil || hdr[len(hdr)-2] != '`' || hdr[len(hdr)-1] != '\n' {
|
||||
err = fmt.Errorf("invalid archive header")
|
||||
return
|
||||
}
|
||||
name = strings.TrimSpace(string(hdr[:16]))
|
||||
return
|
||||
}
|
||||
|
||||
// FindExportData positions the reader r at the beginning of the
|
||||
// export data section of an underlying cmd/compile created archive
|
||||
// file by reading from it. The reader must be positioned at the
|
||||
// start of the file before calling this function.
|
||||
// The size result is the length of the export data in bytes.
|
||||
// This returns the length of the export data in bytes.
|
||||
//
|
||||
// This function is needed by [gcexportdata.Read], which must
|
||||
// accept inputs produced by the last two releases of cmd/compile,
|
||||
// plus tip.
|
||||
func FindExportData(r *bufio.Reader) (size int64, err error) {
|
||||
arsize, err := FindPackageDefinition(r)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
size = int64(arsize)
|
||||
|
||||
objapi, headers, err := ReadObjectHeaders(r)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
size -= int64(len(objapi))
|
||||
for _, h := range headers {
|
||||
size -= int64(len(h))
|
||||
}
|
||||
|
||||
// Check for the binary export data section header "$$B\n".
|
||||
// TODO(taking): Unify with ReadExportDataHeader so that it stops at the 'u' instead of reading
|
||||
line, err := r.ReadSlice('\n')
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
hdr := string(line)
|
||||
if hdr != "$$B\n" {
|
||||
err = fmt.Errorf("unknown export data header: %q", hdr)
|
||||
return
|
||||
}
|
||||
size -= int64(len(hdr))
|
||||
|
||||
// For files with a binary export data header "$$B\n",
|
||||
// these are always terminated by an end-of-section marker "\n$$\n".
|
||||
// So the last bytes must always be this constant.
|
||||
//
|
||||
// The end-of-section marker is not a part of the export data itself.
|
||||
// Do not include these in size.
|
||||
//
|
||||
// It would be nice to have sanity check that the final bytes after
|
||||
// the export data are indeed the end-of-section marker. The split
|
||||
// of gcexportdata.NewReader and gcexportdata.Read make checking this
|
||||
// ugly so gcimporter gives up enforcing this. The compiler and go/types
|
||||
// importer do enforce this, which seems good enough.
|
||||
const endofsection = "\n$$\n"
|
||||
size -= int64(len(endofsection))
|
||||
|
||||
if size < 0 {
|
||||
err = fmt.Errorf("invalid size (%d) in the archive file: %d bytes remain without section headers (recompile package)", arsize, size)
|
||||
return
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// ReadUnified reads the contents of the unified export data from a reader r
|
||||
// that contains the contents of a GC-created archive file.
|
||||
//
|
||||
// On success, the reader will be positioned after the end-of-section marker "\n$$\n".
|
||||
//
|
||||
// Supported GC-created archive files have 4 layers of nesting:
|
||||
// - An archive file containing a package definition file.
|
||||
// - The package definition file contains headers followed by a data section.
|
||||
// Headers are lines (≤ 4kb) that do not start with "$$".
|
||||
// - The data section starts with "$$B\n" followed by export data followed
|
||||
// by an end of section marker "\n$$\n". (The section start "$$\n" is no
|
||||
// longer supported.)
|
||||
// - The export data starts with a format byte ('u') followed by the <data> in
|
||||
// the given format. (See ReadExportDataHeader for older formats.)
|
||||
//
|
||||
// Putting this together, the bytes in a GC-created archive files are expected
|
||||
// to look like the following.
|
||||
// See cmd/internal/archive for more details on ar file headers.
|
||||
//
|
||||
// | <!arch>\n | ar file signature
|
||||
// | __.PKGDEF...size...\n | ar header for __.PKGDEF including size.
|
||||
// | go object <...>\n | objabi header
|
||||
// | <optional headers>\n | other headers such as build id
|
||||
// | $$B\n | binary format marker
|
||||
// | u<data>\n | unified export <data>
|
||||
// | $$\n | end-of-section marker
|
||||
// | [optional padding] | padding byte (0x0A) if size is odd
|
||||
// | [ar file header] | other ar files
|
||||
// | [ar file data] |
|
||||
func ReadUnified(r *bufio.Reader) (data []byte, err error) {
|
||||
// We historically guaranteed headers at the default buffer size (4096) work.
|
||||
// This ensures we can use ReadSlice throughout.
|
||||
const minBufferSize = 4096
|
||||
r = bufio.NewReaderSize(r, minBufferSize)
|
||||
|
||||
size, err := FindPackageDefinition(r)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
n := size
|
||||
|
||||
objapi, headers, err := ReadObjectHeaders(r)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
n -= len(objapi)
|
||||
for _, h := range headers {
|
||||
n -= len(h)
|
||||
}
|
||||
|
||||
hdrlen, err := ReadExportDataHeader(r)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
n -= hdrlen
|
||||
|
||||
// size also includes the end of section marker. Remove that many bytes from the end.
|
||||
const marker = "\n$$\n"
|
||||
n -= len(marker)
|
||||
|
||||
if n < 0 {
|
||||
err = fmt.Errorf("invalid size (%d) in the archive file: %d bytes remain without section headers (recompile package)", size, n)
|
||||
return
|
||||
}
|
||||
|
||||
// Read n bytes from buf.
|
||||
data = make([]byte, n)
|
||||
_, err = io.ReadFull(r, data)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
// Check for marker at the end.
|
||||
var suffix [len(marker)]byte
|
||||
_, err = io.ReadFull(r, suffix[:])
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
if s := string(suffix[:]); s != marker {
|
||||
err = fmt.Errorf("read %q instead of end-of-section marker (%q)", s, marker)
|
||||
return
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// FindPackageDefinition positions the reader r at the beginning of a package
|
||||
// definition file ("__.PKGDEF") within a GC-created archive by reading
|
||||
// from it, and returns the size of the package definition file in the archive.
|
||||
//
|
||||
// The reader must be positioned at the start of the archive file before calling
|
||||
// this function, and "__.PKGDEF" is assumed to be the first file in the archive.
|
||||
//
|
||||
// See cmd/internal/archive for details on the archive format.
|
||||
func FindPackageDefinition(r *bufio.Reader) (size int, err error) {
|
||||
// Uses ReadSlice to limit risk of malformed inputs.
|
||||
|
||||
// Read first line to make sure this is an object file.
|
||||
line, err := r.ReadSlice('\n')
|
||||
if err != nil {
|
||||
@@ -61,56 +192,230 @@ func FindExportData(r *bufio.Reader) (size int64, err error) {
|
||||
return
|
||||
}
|
||||
|
||||
// Archive file. Scan to __.PKGDEF.
|
||||
var name string
|
||||
if name, size, err = readGopackHeader(r); err != nil {
|
||||
return
|
||||
}
|
||||
arsize := size
|
||||
|
||||
// First entry should be __.PKGDEF.
|
||||
if name != "__.PKGDEF" {
|
||||
err = fmt.Errorf("go archive is missing __.PKGDEF")
|
||||
return
|
||||
}
|
||||
|
||||
// Read first line of __.PKGDEF data, so that line
|
||||
// is once again the first line of the input.
|
||||
if line, err = r.ReadSlice('\n'); err != nil {
|
||||
err = fmt.Errorf("can't find export data (%v)", err)
|
||||
return
|
||||
}
|
||||
size -= int64(len(line))
|
||||
|
||||
// Now at __.PKGDEF in archive or still at beginning of file.
|
||||
// Either way, line should begin with "go object ".
|
||||
if !strings.HasPrefix(string(line), "go object ") {
|
||||
err = fmt.Errorf("not a Go object file")
|
||||
return
|
||||
}
|
||||
|
||||
// Skip over object headers to get to the export data section header "$$B\n".
|
||||
// Object headers are lines that do not start with '$'.
|
||||
for line[0] != '$' {
|
||||
if line, err = r.ReadSlice('\n'); err != nil {
|
||||
err = fmt.Errorf("can't find export data (%v)", err)
|
||||
return
|
||||
}
|
||||
size -= int64(len(line))
|
||||
}
|
||||
|
||||
// Check for the binary export data section header "$$B\n".
|
||||
hdr := string(line)
|
||||
if hdr != "$$B\n" {
|
||||
err = fmt.Errorf("unknown export data header: %q", hdr)
|
||||
return
|
||||
}
|
||||
// TODO(taking): Remove end-of-section marker "\n$$\n" from size.
|
||||
|
||||
if size < 0 {
|
||||
err = fmt.Errorf("invalid size (%d) in the archive file: %d bytes remain without section headers (recompile package)", arsize, size)
|
||||
// package export block should be first
|
||||
size = readArchiveHeader(r, "__.PKGDEF")
|
||||
if size <= 0 {
|
||||
err = fmt.Errorf("not a package file")
|
||||
return
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// ReadObjectHeaders reads object headers from the reader. Object headers are
|
||||
// lines that do not start with an end-of-section marker "$$". The first header
|
||||
// is the objabi header. On success, the reader will be positioned at the beginning
|
||||
// of the end-of-section marker.
|
||||
//
|
||||
// It returns an error if any header does not fit in r.Size() bytes.
|
||||
func ReadObjectHeaders(r *bufio.Reader) (objapi string, headers []string, err error) {
|
||||
// line is a temporary buffer for headers.
|
||||
// Use bounded reads (ReadSlice, Peek) to limit risk of malformed inputs.
|
||||
var line []byte
|
||||
|
||||
// objapi header should be the first line
|
||||
if line, err = r.ReadSlice('\n'); err != nil {
|
||||
err = fmt.Errorf("can't find export data (%v)", err)
|
||||
return
|
||||
}
|
||||
objapi = string(line)
|
||||
|
||||
// objapi header begins with "go object ".
|
||||
if !strings.HasPrefix(objapi, "go object ") {
|
||||
err = fmt.Errorf("not a go object file: %s", objapi)
|
||||
return
|
||||
}
|
||||
|
||||
// process remaining object header lines
|
||||
for {
|
||||
// check for an end of section marker "$$"
|
||||
line, err = r.Peek(2)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
if string(line) == "$$" {
|
||||
return // stop
|
||||
}
|
||||
|
||||
// read next header
|
||||
line, err = r.ReadSlice('\n')
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
headers = append(headers, string(line))
|
||||
}
|
||||
}
|
||||
|
||||
// ReadExportDataHeader reads the export data header and format from r.
|
||||
// It returns the number of bytes read, or an error if the format is no longer
|
||||
// supported or it failed to read.
|
||||
//
|
||||
// The only currently supported format is binary export data in the
|
||||
// unified export format.
|
||||
func ReadExportDataHeader(r *bufio.Reader) (n int, err error) {
|
||||
// Read export data header.
|
||||
line, err := r.ReadSlice('\n')
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
hdr := string(line)
|
||||
switch hdr {
|
||||
case "$$\n":
|
||||
err = fmt.Errorf("old textual export format no longer supported (recompile package)")
|
||||
return
|
||||
|
||||
case "$$B\n":
|
||||
var format byte
|
||||
format, err = r.ReadByte()
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
// The unified export format starts with a 'u'.
|
||||
switch format {
|
||||
case 'u':
|
||||
default:
|
||||
// Older no longer supported export formats include:
|
||||
// indexed export format which started with an 'i'; and
|
||||
// the older binary export format which started with a 'c',
|
||||
// 'd', or 'v' (from "version").
|
||||
err = fmt.Errorf("binary export format %q is no longer supported (recompile package)", format)
|
||||
return
|
||||
}
|
||||
|
||||
default:
|
||||
err = fmt.Errorf("unknown export data header: %q", hdr)
|
||||
return
|
||||
}
|
||||
|
||||
n = len(hdr) + 1 // + 1 is for 'u'
|
||||
return
|
||||
}
|
||||
|
||||
// FindPkg returns the filename and unique package id for an import
|
||||
// path based on package information provided by build.Import (using
|
||||
// the build.Default build.Context). A relative srcDir is interpreted
|
||||
// relative to the current working directory.
|
||||
//
|
||||
// FindPkg is only used in tests within x/tools.
|
||||
func FindPkg(path, srcDir string) (filename, id string, err error) {
|
||||
// TODO(taking): Move internal/exportdata.FindPkg into its own file,
|
||||
// and then this copy into a _test package.
|
||||
if path == "" {
|
||||
return "", "", errors.New("path is empty")
|
||||
}
|
||||
|
||||
var noext string
|
||||
switch {
|
||||
default:
|
||||
// "x" -> "$GOPATH/pkg/$GOOS_$GOARCH/x.ext", "x"
|
||||
// Don't require the source files to be present.
|
||||
if abs, err := filepath.Abs(srcDir); err == nil { // see issue 14282
|
||||
srcDir = abs
|
||||
}
|
||||
var bp *build.Package
|
||||
bp, err = build.Import(path, srcDir, build.FindOnly|build.AllowBinary)
|
||||
if bp.PkgObj == "" {
|
||||
if bp.Goroot && bp.Dir != "" {
|
||||
filename, err = lookupGorootExport(bp.Dir)
|
||||
if err == nil {
|
||||
_, err = os.Stat(filename)
|
||||
}
|
||||
if err == nil {
|
||||
return filename, bp.ImportPath, nil
|
||||
}
|
||||
}
|
||||
goto notfound
|
||||
} else {
|
||||
noext = strings.TrimSuffix(bp.PkgObj, ".a")
|
||||
}
|
||||
id = bp.ImportPath
|
||||
|
||||
case build.IsLocalImport(path):
|
||||
// "./x" -> "/this/directory/x.ext", "/this/directory/x"
|
||||
noext = filepath.Join(srcDir, path)
|
||||
id = noext
|
||||
|
||||
case filepath.IsAbs(path):
|
||||
// for completeness only - go/build.Import
|
||||
// does not support absolute imports
|
||||
// "/x" -> "/x.ext", "/x"
|
||||
noext = path
|
||||
id = path
|
||||
}
|
||||
|
||||
if false { // for debugging
|
||||
if path != id {
|
||||
fmt.Printf("%s -> %s\n", path, id)
|
||||
}
|
||||
}
|
||||
|
||||
// try extensions
|
||||
for _, ext := range pkgExts {
|
||||
filename = noext + ext
|
||||
f, statErr := os.Stat(filename)
|
||||
if statErr == nil && !f.IsDir() {
|
||||
return filename, id, nil
|
||||
}
|
||||
if err == nil {
|
||||
err = statErr
|
||||
}
|
||||
}
|
||||
|
||||
notfound:
|
||||
if err == nil {
|
||||
return "", path, fmt.Errorf("can't find import: %q", path)
|
||||
}
|
||||
return "", path, fmt.Errorf("can't find import: %q: %w", path, err)
|
||||
}
|
||||
|
||||
var pkgExts = [...]string{".a", ".o"} // a file from the build cache will have no extension
|
||||
|
||||
var exportMap sync.Map // package dir → func() (string, error)
|
||||
|
||||
// lookupGorootExport returns the location of the export data
|
||||
// (normally found in the build cache, but located in GOROOT/pkg
|
||||
// in prior Go releases) for the package located in pkgDir.
|
||||
//
|
||||
// (We use the package's directory instead of its import path
|
||||
// mainly to simplify handling of the packages in src/vendor
|
||||
// and cmd/vendor.)
|
||||
//
|
||||
// lookupGorootExport is only used in tests within x/tools.
|
||||
func lookupGorootExport(pkgDir string) (string, error) {
|
||||
f, ok := exportMap.Load(pkgDir)
|
||||
if !ok {
|
||||
var (
|
||||
listOnce sync.Once
|
||||
exportPath string
|
||||
err error
|
||||
)
|
||||
f, _ = exportMap.LoadOrStore(pkgDir, func() (string, error) {
|
||||
listOnce.Do(func() {
|
||||
cmd := exec.Command(filepath.Join(build.Default.GOROOT, "bin", "go"), "list", "-export", "-f", "{{.Export}}", pkgDir)
|
||||
cmd.Dir = build.Default.GOROOT
|
||||
cmd.Env = append(os.Environ(), "PWD="+cmd.Dir, "GOROOT="+build.Default.GOROOT)
|
||||
var output []byte
|
||||
output, err = cmd.Output()
|
||||
if err != nil {
|
||||
if ee, ok := err.(*exec.ExitError); ok && len(ee.Stderr) > 0 {
|
||||
err = errors.New(string(ee.Stderr))
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
exports := strings.Split(string(bytes.TrimSpace(output)), "\n")
|
||||
if len(exports) != 1 {
|
||||
err = fmt.Errorf("go list reported %d exports; expected 1", len(exports))
|
||||
return
|
||||
}
|
||||
|
||||
exportPath = exports[0]
|
||||
})
|
||||
|
||||
return exportPath, err
|
||||
})
|
||||
}
|
||||
|
||||
return f.(func() (string, error))()
|
||||
}
|
||||
|
||||
179
vendor/golang.org/x/tools/internal/gcimporter/gcimporter.go
generated
vendored
179
vendor/golang.org/x/tools/internal/gcimporter/gcimporter.go
generated
vendored
@@ -23,17 +23,11 @@ package gcimporter // import "golang.org/x/tools/internal/gcimporter"
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
"bytes"
|
||||
"fmt"
|
||||
"go/build"
|
||||
"go/token"
|
||||
"go/types"
|
||||
"io"
|
||||
"os"
|
||||
"os/exec"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"sync"
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -45,127 +39,14 @@ const (
|
||||
trace = false
|
||||
)
|
||||
|
||||
var exportMap sync.Map // package dir → func() (string, bool)
|
||||
|
||||
// lookupGorootExport returns the location of the export data
|
||||
// (normally found in the build cache, but located in GOROOT/pkg
|
||||
// in prior Go releases) for the package located in pkgDir.
|
||||
//
|
||||
// (We use the package's directory instead of its import path
|
||||
// mainly to simplify handling of the packages in src/vendor
|
||||
// and cmd/vendor.)
|
||||
func lookupGorootExport(pkgDir string) (string, bool) {
|
||||
f, ok := exportMap.Load(pkgDir)
|
||||
if !ok {
|
||||
var (
|
||||
listOnce sync.Once
|
||||
exportPath string
|
||||
)
|
||||
f, _ = exportMap.LoadOrStore(pkgDir, func() (string, bool) {
|
||||
listOnce.Do(func() {
|
||||
cmd := exec.Command("go", "list", "-export", "-f", "{{.Export}}", pkgDir)
|
||||
cmd.Dir = build.Default.GOROOT
|
||||
var output []byte
|
||||
output, err := cmd.Output()
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
exports := strings.Split(string(bytes.TrimSpace(output)), "\n")
|
||||
if len(exports) != 1 {
|
||||
return
|
||||
}
|
||||
|
||||
exportPath = exports[0]
|
||||
})
|
||||
|
||||
return exportPath, exportPath != ""
|
||||
})
|
||||
}
|
||||
|
||||
return f.(func() (string, bool))()
|
||||
}
|
||||
|
||||
var pkgExts = [...]string{".a", ".o"}
|
||||
|
||||
// FindPkg returns the filename and unique package id for an import
|
||||
// path based on package information provided by build.Import (using
|
||||
// the build.Default build.Context). A relative srcDir is interpreted
|
||||
// relative to the current working directory.
|
||||
// If no file was found, an empty filename is returned.
|
||||
func FindPkg(path, srcDir string) (filename, id string) {
|
||||
if path == "" {
|
||||
return
|
||||
}
|
||||
|
||||
var noext string
|
||||
switch {
|
||||
default:
|
||||
// "x" -> "$GOPATH/pkg/$GOOS_$GOARCH/x.ext", "x"
|
||||
// Don't require the source files to be present.
|
||||
if abs, err := filepath.Abs(srcDir); err == nil { // see issue 14282
|
||||
srcDir = abs
|
||||
}
|
||||
bp, _ := build.Import(path, srcDir, build.FindOnly|build.AllowBinary)
|
||||
if bp.PkgObj == "" {
|
||||
var ok bool
|
||||
if bp.Goroot && bp.Dir != "" {
|
||||
filename, ok = lookupGorootExport(bp.Dir)
|
||||
}
|
||||
if !ok {
|
||||
id = path // make sure we have an id to print in error message
|
||||
return
|
||||
}
|
||||
} else {
|
||||
noext = strings.TrimSuffix(bp.PkgObj, ".a")
|
||||
id = bp.ImportPath
|
||||
}
|
||||
|
||||
case build.IsLocalImport(path):
|
||||
// "./x" -> "/this/directory/x.ext", "/this/directory/x"
|
||||
noext = filepath.Join(srcDir, path)
|
||||
id = noext
|
||||
|
||||
case filepath.IsAbs(path):
|
||||
// for completeness only - go/build.Import
|
||||
// does not support absolute imports
|
||||
// "/x" -> "/x.ext", "/x"
|
||||
noext = path
|
||||
id = path
|
||||
}
|
||||
|
||||
if false { // for debugging
|
||||
if path != id {
|
||||
fmt.Printf("%s -> %s\n", path, id)
|
||||
}
|
||||
}
|
||||
|
||||
if filename != "" {
|
||||
if f, err := os.Stat(filename); err == nil && !f.IsDir() {
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
// try extensions
|
||||
for _, ext := range pkgExts {
|
||||
filename = noext + ext
|
||||
if f, err := os.Stat(filename); err == nil && !f.IsDir() {
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
filename = "" // not found
|
||||
return
|
||||
}
|
||||
|
||||
// Import imports a gc-generated package given its import path and srcDir, adds
|
||||
// the corresponding package object to the packages map, and returns the object.
|
||||
// The packages map must contain all packages already imported.
|
||||
//
|
||||
// TODO(taking): Import is only used in tests. Move to gcimporter_test.
|
||||
func Import(packages map[string]*types.Package, path, srcDir string, lookup func(path string) (io.ReadCloser, error)) (pkg *types.Package, err error) {
|
||||
// Import is only used in tests.
|
||||
func Import(fset *token.FileSet, packages map[string]*types.Package, path, srcDir string, lookup func(path string) (io.ReadCloser, error)) (pkg *types.Package, err error) {
|
||||
var rc io.ReadCloser
|
||||
var filename, id string
|
||||
var id string
|
||||
if lookup != nil {
|
||||
// With custom lookup specified, assume that caller has
|
||||
// converted path to a canonical import path for use in the map.
|
||||
@@ -184,12 +65,13 @@ func Import(packages map[string]*types.Package, path, srcDir string, lookup func
|
||||
}
|
||||
rc = f
|
||||
} else {
|
||||
filename, id = FindPkg(path, srcDir)
|
||||
var filename string
|
||||
filename, id, err = FindPkg(path, srcDir)
|
||||
if filename == "" {
|
||||
if path == "unsafe" {
|
||||
return types.Unsafe, nil
|
||||
}
|
||||
return nil, fmt.Errorf("can't find import: %q", id)
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// no need to re-import if the package was imported completely before
|
||||
@@ -212,54 +94,15 @@ func Import(packages map[string]*types.Package, path, srcDir string, lookup func
|
||||
}
|
||||
defer rc.Close()
|
||||
|
||||
var size int64
|
||||
buf := bufio.NewReader(rc)
|
||||
if size, err = FindExportData(buf); err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
var data []byte
|
||||
data, err = io.ReadAll(buf)
|
||||
data, err := ReadUnified(buf)
|
||||
if err != nil {
|
||||
err = fmt.Errorf("import %q: %v", path, err)
|
||||
return
|
||||
}
|
||||
if len(data) == 0 {
|
||||
return nil, fmt.Errorf("no data to load a package from for path %s", id)
|
||||
}
|
||||
|
||||
// TODO(gri): allow clients of go/importer to provide a FileSet.
|
||||
// Or, define a new standard go/types/gcexportdata package.
|
||||
fset := token.NewFileSet()
|
||||
// unified: emitted by cmd/compile since go1.20.
|
||||
_, pkg, err = UImportData(fset, packages, data, id)
|
||||
|
||||
// Select appropriate importer.
|
||||
switch data[0] {
|
||||
case 'v', 'c', 'd':
|
||||
// binary: emitted by cmd/compile till go1.10; obsolete.
|
||||
return nil, fmt.Errorf("binary (%c) import format is no longer supported", data[0])
|
||||
|
||||
case 'i':
|
||||
// indexed: emitted by cmd/compile till go1.19;
|
||||
// now used only for serializing go/types.
|
||||
// See https://github.com/golang/go/issues/69491.
|
||||
_, pkg, err := IImportData(fset, packages, data[1:], id)
|
||||
return pkg, err
|
||||
|
||||
case 'u':
|
||||
// unified: emitted by cmd/compile since go1.20.
|
||||
_, pkg, err := UImportData(fset, packages, data[1:size], id)
|
||||
return pkg, err
|
||||
|
||||
default:
|
||||
l := len(data)
|
||||
if l > 10 {
|
||||
l = 10
|
||||
}
|
||||
return nil, fmt.Errorf("unexpected export data with prefix %q for path %s", string(data[:l]), id)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
type byPath []*types.Package
|
||||
|
||||
func (a byPath) Len() int { return len(a) }
|
||||
func (a byPath) Swap(i, j int) { a[i], a[j] = a[j], a[i] }
|
||||
func (a byPath) Less(i, j int) bool { return a[i].Path() < a[j].Path() }
|
||||
|
||||
12
vendor/golang.org/x/tools/internal/gcimporter/iimport.go
generated
vendored
12
vendor/golang.org/x/tools/internal/gcimporter/iimport.go
generated
vendored
@@ -5,8 +5,6 @@
|
||||
// Indexed package import.
|
||||
// See iexport.go for the export data format.
|
||||
|
||||
// This file is a copy of $GOROOT/src/go/internal/gcimporter/iimport.go.
|
||||
|
||||
package gcimporter
|
||||
|
||||
import (
|
||||
@@ -673,7 +671,9 @@ func (r *importReader) obj(name string) {
|
||||
case varTag:
|
||||
typ := r.typ()
|
||||
|
||||
r.declare(types.NewVar(pos, r.currPkg, name, typ))
|
||||
v := types.NewVar(pos, r.currPkg, name, typ)
|
||||
typesinternal.SetVarKind(v, typesinternal.PackageVar)
|
||||
r.declare(v)
|
||||
|
||||
default:
|
||||
errorf("unexpected tag: %v", tag)
|
||||
@@ -1111,3 +1111,9 @@ func (r *importReader) byte() byte {
|
||||
}
|
||||
return x
|
||||
}
|
||||
|
||||
type byPath []*types.Package
|
||||
|
||||
func (a byPath) Len() int { return len(a) }
|
||||
func (a byPath) Swap(i, j int) { a[i], a[j] = a[j], a[i] }
|
||||
func (a byPath) Less(i, j int) bool { return a[i].Path() < a[j].Path() }
|
||||
|
||||
30
vendor/golang.org/x/tools/internal/gcimporter/support.go
generated
vendored
Normal file
30
vendor/golang.org/x/tools/internal/gcimporter/support.go
generated
vendored
Normal file
@@ -0,0 +1,30 @@
|
||||
// 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 gcimporter
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
"io"
|
||||
"strconv"
|
||||
"strings"
|
||||
)
|
||||
|
||||
// Copy of $GOROOT/src/cmd/internal/archive.ReadHeader.
|
||||
func readArchiveHeader(b *bufio.Reader, name string) int {
|
||||
// architecture-independent object file output
|
||||
const HeaderSize = 60
|
||||
|
||||
var buf [HeaderSize]byte
|
||||
if _, err := io.ReadFull(b, buf[:]); err != nil {
|
||||
return -1
|
||||
}
|
||||
aname := strings.Trim(string(buf[0:16]), " ")
|
||||
if !strings.HasPrefix(aname, name) {
|
||||
return -1
|
||||
}
|
||||
asize := strings.Trim(string(buf[48:58]), " ")
|
||||
i, _ := strconv.Atoi(asize)
|
||||
return i
|
||||
}
|
||||
15
vendor/golang.org/x/tools/internal/gcimporter/ureader_yes.go
generated
vendored
15
vendor/golang.org/x/tools/internal/gcimporter/ureader_yes.go
generated
vendored
@@ -11,10 +11,10 @@ import (
|
||||
"go/token"
|
||||
"go/types"
|
||||
"sort"
|
||||
"strings"
|
||||
|
||||
"golang.org/x/tools/internal/aliases"
|
||||
"golang.org/x/tools/internal/pkgbits"
|
||||
"golang.org/x/tools/internal/typesinternal"
|
||||
)
|
||||
|
||||
// A pkgReader holds the shared state for reading a unified IR package
|
||||
@@ -71,7 +71,6 @@ func UImportData(fset *token.FileSet, imports map[string]*types.Package, data []
|
||||
}
|
||||
|
||||
s := string(data)
|
||||
s = s[:strings.LastIndex(s, "\n$$\n")]
|
||||
input := pkgbits.NewPkgDecoder(path, s)
|
||||
pkg = readUnifiedPackage(fset, nil, imports, input)
|
||||
return
|
||||
@@ -266,7 +265,12 @@ func (pr *pkgReader) pkgIdx(idx pkgbits.Index) *types.Package {
|
||||
func (r *reader) doPkg() *types.Package {
|
||||
path := r.String()
|
||||
switch path {
|
||||
case "":
|
||||
// cmd/compile emits path="main" for main packages because
|
||||
// that's the linker symbol prefix it used; but we need
|
||||
// the package's path as it would be reported by go list,
|
||||
// hence "main" below.
|
||||
// See test at go/packages.TestMainPackagePathInModeTypes.
|
||||
case "", "main":
|
||||
path = r.p.PkgPath()
|
||||
case "builtin":
|
||||
return nil // universe
|
||||
@@ -569,6 +573,7 @@ func (pr *pkgReader) objIdx(idx pkgbits.Index) (*types.Package, string) {
|
||||
sig := fn.Type().(*types.Signature)
|
||||
|
||||
recv := types.NewVar(fn.Pos(), fn.Pkg(), "", named)
|
||||
typesinternal.SetVarKind(recv, typesinternal.RecvVar)
|
||||
methods[i] = types.NewFunc(fn.Pos(), fn.Pkg(), fn.Name(), types.NewSignature(recv, sig.Params(), sig.Results(), sig.Variadic()))
|
||||
}
|
||||
|
||||
@@ -616,7 +621,9 @@ func (pr *pkgReader) objIdx(idx pkgbits.Index) (*types.Package, string) {
|
||||
case pkgbits.ObjVar:
|
||||
pos := r.pos()
|
||||
typ := r.typ()
|
||||
declare(types.NewVar(pos, objPkg, objName, typ))
|
||||
v := types.NewVar(pos, objPkg, objName, typ)
|
||||
typesinternal.SetVarKind(v, typesinternal.PackageVar)
|
||||
declare(v)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
42
vendor/golang.org/x/tools/internal/gocommand/invoke.go
generated
vendored
42
vendor/golang.org/x/tools/internal/gocommand/invoke.go
generated
vendored
@@ -28,7 +28,7 @@ import (
|
||||
"golang.org/x/tools/internal/event/label"
|
||||
)
|
||||
|
||||
// An Runner will run go command invocations and serialize
|
||||
// A Runner will run go command invocations and serialize
|
||||
// them if it sees a concurrency error.
|
||||
type Runner struct {
|
||||
// once guards the runner initialization.
|
||||
@@ -179,7 +179,7 @@ type Invocation struct {
|
||||
CleanEnv bool
|
||||
Env []string
|
||||
WorkingDir string
|
||||
Logf func(format string, args ...interface{})
|
||||
Logf func(format string, args ...any)
|
||||
}
|
||||
|
||||
// Postcondition: both error results have same nilness.
|
||||
@@ -388,7 +388,9 @@ func runCmdContext(ctx context.Context, cmd *exec.Cmd) (err error) {
|
||||
case err := <-resChan:
|
||||
return err
|
||||
case <-timer.C:
|
||||
HandleHangingGoCommand(startTime, cmd)
|
||||
// HandleHangingGoCommand terminates this process.
|
||||
// Pass off resChan in case we can collect the command error.
|
||||
handleHangingGoCommand(startTime, cmd, resChan)
|
||||
case <-ctx.Done():
|
||||
}
|
||||
} else {
|
||||
@@ -413,8 +415,6 @@ func runCmdContext(ctx context.Context, cmd *exec.Cmd) (err error) {
|
||||
}
|
||||
|
||||
// Didn't shut down in response to interrupt. Kill it hard.
|
||||
// TODO(rfindley): per advice from bcmills@, it may be better to send SIGQUIT
|
||||
// on certain platforms, such as unix.
|
||||
if err := cmd.Process.Kill(); err != nil && !errors.Is(err, os.ErrProcessDone) && debug {
|
||||
log.Printf("error killing the Go command: %v", err)
|
||||
}
|
||||
@@ -422,15 +422,17 @@ func runCmdContext(ctx context.Context, cmd *exec.Cmd) (err error) {
|
||||
return <-resChan
|
||||
}
|
||||
|
||||
func HandleHangingGoCommand(start time.Time, cmd *exec.Cmd) {
|
||||
// handleHangingGoCommand outputs debugging information to help diagnose the
|
||||
// cause of a hanging Go command, and then exits with log.Fatalf.
|
||||
func handleHangingGoCommand(start time.Time, cmd *exec.Cmd, resChan chan error) {
|
||||
switch runtime.GOOS {
|
||||
case "linux", "darwin", "freebsd", "netbsd":
|
||||
case "linux", "darwin", "freebsd", "netbsd", "openbsd":
|
||||
fmt.Fprintln(os.Stderr, `DETECTED A HANGING GO COMMAND
|
||||
|
||||
The gopls test runner has detected a hanging go command. In order to debug
|
||||
this, the output of ps and lsof/fstat is printed below.
|
||||
The gopls test runner has detected a hanging go command. In order to debug
|
||||
this, the output of ps and lsof/fstat is printed below.
|
||||
|
||||
See golang/go#54461 for more details.`)
|
||||
See golang/go#54461 for more details.`)
|
||||
|
||||
fmt.Fprintln(os.Stderr, "\nps axo ppid,pid,command:")
|
||||
fmt.Fprintln(os.Stderr, "-------------------------")
|
||||
@@ -438,7 +440,7 @@ See golang/go#54461 for more details.`)
|
||||
psCmd.Stdout = os.Stderr
|
||||
psCmd.Stderr = os.Stderr
|
||||
if err := psCmd.Run(); err != nil {
|
||||
panic(fmt.Sprintf("running ps: %v", err))
|
||||
log.Printf("Handling hanging Go command: running ps: %v", err)
|
||||
}
|
||||
|
||||
listFiles := "lsof"
|
||||
@@ -452,10 +454,24 @@ See golang/go#54461 for more details.`)
|
||||
listFilesCmd.Stdout = os.Stderr
|
||||
listFilesCmd.Stderr = os.Stderr
|
||||
if err := listFilesCmd.Run(); err != nil {
|
||||
panic(fmt.Sprintf("running %s: %v", listFiles, err))
|
||||
log.Printf("Handling hanging Go command: running %s: %v", listFiles, err)
|
||||
}
|
||||
// Try to extract information about the slow go process by issuing a SIGQUIT.
|
||||
if err := cmd.Process.Signal(sigStuckProcess); err == nil {
|
||||
select {
|
||||
case err := <-resChan:
|
||||
stderr := "not a bytes.Buffer"
|
||||
if buf, _ := cmd.Stderr.(*bytes.Buffer); buf != nil {
|
||||
stderr = buf.String()
|
||||
}
|
||||
log.Printf("Quit hanging go command:\n\terr:%v\n\tstderr:\n%v\n\n", err, stderr)
|
||||
case <-time.After(5 * time.Second):
|
||||
}
|
||||
} else {
|
||||
log.Printf("Sending signal %d to hanging go command: %v", sigStuckProcess, err)
|
||||
}
|
||||
}
|
||||
panic(fmt.Sprintf("detected hanging go command (golang/go#54461); waited %s\n\tcommand:%s\n\tpid:%d", time.Since(start), cmd, cmd.Process.Pid))
|
||||
log.Fatalf("detected hanging go command (golang/go#54461); waited %s\n\tcommand:%s\n\tpid:%d", time.Since(start), cmd, cmd.Process.Pid)
|
||||
}
|
||||
|
||||
func cmdDebugStr(cmd *exec.Cmd) string {
|
||||
|
||||
13
vendor/golang.org/x/tools/internal/gocommand/invoke_notunix.go
generated
vendored
Normal file
13
vendor/golang.org/x/tools/internal/gocommand/invoke_notunix.go
generated
vendored
Normal file
@@ -0,0 +1,13 @@
|
||||
// Copyright 2025 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.
|
||||
|
||||
//go:build !unix
|
||||
|
||||
package gocommand
|
||||
|
||||
import "os"
|
||||
|
||||
// sigStuckProcess is the signal to send to kill a hanging subprocess.
|
||||
// On Unix we send SIGQUIT, but on non-Unix we only have os.Kill.
|
||||
var sigStuckProcess = os.Kill
|
||||
13
vendor/golang.org/x/tools/internal/gocommand/invoke_unix.go
generated
vendored
Normal file
13
vendor/golang.org/x/tools/internal/gocommand/invoke_unix.go
generated
vendored
Normal file
@@ -0,0 +1,13 @@
|
||||
// Copyright 2025 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.
|
||||
|
||||
//go:build unix
|
||||
|
||||
package gocommand
|
||||
|
||||
import "syscall"
|
||||
|
||||
// Sigstuckprocess is the signal to send to kill a hanging subprocess.
|
||||
// Send SIGQUIT to get a stack trace.
|
||||
var sigStuckProcess = syscall.SIGQUIT
|
||||
15
vendor/golang.org/x/tools/internal/imports/fix.go
generated
vendored
15
vendor/golang.org/x/tools/internal/imports/fix.go
generated
vendored
@@ -780,7 +780,7 @@ func GetAllCandidates(ctx context.Context, wrapped func(ImportFix), searchPrefix
|
||||
return true
|
||||
},
|
||||
dirFound: func(pkg *pkg) bool {
|
||||
if !canUse(filename, pkg.dir) {
|
||||
if !CanUse(filename, pkg.dir) {
|
||||
return false
|
||||
}
|
||||
// Try the assumed package name first, then a simpler path match
|
||||
@@ -815,7 +815,7 @@ func GetImportPaths(ctx context.Context, wrapped func(ImportFix), searchPrefix,
|
||||
return true
|
||||
},
|
||||
dirFound: func(pkg *pkg) bool {
|
||||
if !canUse(filename, pkg.dir) {
|
||||
if !CanUse(filename, pkg.dir) {
|
||||
return false
|
||||
}
|
||||
return strings.HasPrefix(pkg.importPathShort, searchPrefix)
|
||||
@@ -927,7 +927,7 @@ type ProcessEnv struct {
|
||||
WorkingDir string
|
||||
|
||||
// If Logf is non-nil, debug logging is enabled through this function.
|
||||
Logf func(format string, args ...interface{})
|
||||
Logf func(format string, args ...any)
|
||||
|
||||
// If set, ModCache holds a shared cache of directory info to use across
|
||||
// multiple ProcessEnvs.
|
||||
@@ -1132,6 +1132,9 @@ func addStdlibCandidates(pass *pass, refs References) error {
|
||||
// but we have no way of figuring out what the user is using
|
||||
// TODO: investigate using the toolchain version to disambiguate in the stdlib
|
||||
add("math/rand/v2")
|
||||
// math/rand has an overlapping API
|
||||
// TestIssue66407 fails without this
|
||||
add("math/rand")
|
||||
continue
|
||||
}
|
||||
for importPath := range stdlib.PackageSymbols {
|
||||
@@ -1736,7 +1739,7 @@ func (s *symbolSearcher) searchOne(ctx context.Context, c pkgDistance, symbols m
|
||||
// searching for "client.New")
|
||||
func pkgIsCandidate(filename string, refs References, pkg *pkg) bool {
|
||||
// Check "internal" and "vendor" visibility:
|
||||
if !canUse(filename, pkg.dir) {
|
||||
if !CanUse(filename, pkg.dir) {
|
||||
return false
|
||||
}
|
||||
|
||||
@@ -1759,9 +1762,9 @@ func pkgIsCandidate(filename string, refs References, pkg *pkg) bool {
|
||||
return false
|
||||
}
|
||||
|
||||
// canUse reports whether the package in dir is usable from filename,
|
||||
// CanUse reports whether the package in dir is usable from filename,
|
||||
// respecting the Go "internal" and "vendor" visibility rules.
|
||||
func canUse(filename, dir string) bool {
|
||||
func CanUse(filename, dir string) bool {
|
||||
// Fast path check, before any allocations. If it doesn't contain vendor
|
||||
// or internal, it's not tricky:
|
||||
// Note that this can false-negative on directories like "notinternal",
|
||||
|
||||
2
vendor/golang.org/x/tools/internal/imports/source_env.go
generated
vendored
2
vendor/golang.org/x/tools/internal/imports/source_env.go
generated
vendored
@@ -67,7 +67,7 @@ func (s *ProcessEnvSource) ResolveReferences(ctx context.Context, filename strin
|
||||
// same package name. Don't try to import ourselves.
|
||||
return false
|
||||
}
|
||||
if !canUse(filename, pkg.dir) {
|
||||
if !CanUse(filename, pkg.dir) {
|
||||
return false
|
||||
}
|
||||
mu.Lock()
|
||||
|
||||
48
vendor/golang.org/x/tools/internal/modindex/index.go
generated
vendored
48
vendor/golang.org/x/tools/internal/modindex/index.go
generated
vendored
@@ -17,6 +17,7 @@ import (
|
||||
"path/filepath"
|
||||
"strconv"
|
||||
"strings"
|
||||
"testing"
|
||||
"time"
|
||||
)
|
||||
|
||||
@@ -85,6 +86,28 @@ type Entry struct {
|
||||
Names []string // exported names and information
|
||||
}
|
||||
|
||||
// IndexDir is where the module index is stored.
|
||||
var IndexDir string
|
||||
|
||||
// Set IndexDir
|
||||
func init() {
|
||||
var dir string
|
||||
var err error
|
||||
if testing.Testing() {
|
||||
dir = os.TempDir()
|
||||
} else {
|
||||
dir, err = os.UserCacheDir()
|
||||
// shouldn't happen, but TempDir is better than
|
||||
// creating ./go/imports
|
||||
if err != nil {
|
||||
dir = os.TempDir()
|
||||
}
|
||||
}
|
||||
dir = filepath.Join(dir, "go", "imports")
|
||||
os.MkdirAll(dir, 0777)
|
||||
IndexDir = dir
|
||||
}
|
||||
|
||||
// ReadIndex reads the latest version of the on-disk index
|
||||
// for the cache directory cd.
|
||||
// It returns (nil, nil) if there is no index, but returns
|
||||
@@ -95,10 +118,7 @@ func ReadIndex(cachedir string) (*Index, error) {
|
||||
return nil, err
|
||||
}
|
||||
cd := Abspath(cachedir)
|
||||
dir, err := IndexDir()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
dir := IndexDir
|
||||
base := indexNameBase(cd)
|
||||
iname := filepath.Join(dir, base)
|
||||
buf, err := os.ReadFile(iname)
|
||||
@@ -185,12 +205,8 @@ func readIndexFrom(cd Abspath, bx io.Reader) (*Index, error) {
|
||||
|
||||
// write the index as a text file
|
||||
func writeIndex(cachedir Abspath, ix *Index) error {
|
||||
dir, err := IndexDir()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
ipat := fmt.Sprintf("index-%d-*", CurrentVersion)
|
||||
fd, err := os.CreateTemp(dir, ipat)
|
||||
fd, err := os.CreateTemp(IndexDir, ipat)
|
||||
if err != nil {
|
||||
return err // can this happen?
|
||||
}
|
||||
@@ -201,7 +217,7 @@ func writeIndex(cachedir Abspath, ix *Index) error {
|
||||
content := fd.Name()
|
||||
content = filepath.Base(content)
|
||||
base := indexNameBase(cachedir)
|
||||
nm := filepath.Join(dir, base)
|
||||
nm := filepath.Join(IndexDir, base)
|
||||
err = os.WriteFile(nm, []byte(content), 0666)
|
||||
if err != nil {
|
||||
return err
|
||||
@@ -241,18 +257,6 @@ func writeIndexToFile(x *Index, fd *os.File) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// tests can override this
|
||||
var IndexDir = indexDir
|
||||
|
||||
// IndexDir computes the directory containing the index
|
||||
func indexDir() (string, error) {
|
||||
dir, err := os.UserCacheDir()
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("cannot open UserCacheDir, %w", err)
|
||||
}
|
||||
return filepath.Join(dir, "go", "imports"), nil
|
||||
}
|
||||
|
||||
// return the base name of the file containing the name of the current index
|
||||
func indexNameBase(cachedir Abspath) string {
|
||||
// crc64 is a way to convert path names into 16 hex digits.
|
||||
|
||||
35
vendor/golang.org/x/tools/internal/modindex/lookup.go
generated
vendored
35
vendor/golang.org/x/tools/internal/modindex/lookup.go
generated
vendored
@@ -16,6 +16,7 @@ type Candidate struct {
|
||||
Dir string
|
||||
ImportPath string
|
||||
Type LexType
|
||||
Deprecated bool
|
||||
// information for Funcs
|
||||
Results int16 // how many results
|
||||
Sig []Field // arg names and types
|
||||
@@ -34,6 +35,36 @@ const (
|
||||
Func
|
||||
)
|
||||
|
||||
// LookupAll only returns those Candidates whose import path
|
||||
// finds all the nms.
|
||||
func (ix *Index) LookupAll(pkg 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(pkg, 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(pkg, name string, prefix bool) []Candidate {
|
||||
@@ -79,8 +110,9 @@ func (ix *Index) Lookup(pkg, name string, prefix bool) []Candidate {
|
||||
Dir: string(e.Dir),
|
||||
ImportPath: e.ImportPath,
|
||||
Type: asLexType(flds[1][0]),
|
||||
Deprecated: len(flds[1]) > 1 && flds[1][1] == 'D',
|
||||
}
|
||||
if flds[1] == "F" {
|
||||
if px.Type == Func {
|
||||
n, err := strconv.Atoi(flds[2])
|
||||
if err != nil {
|
||||
continue // should never happen
|
||||
@@ -111,6 +143,7 @@ func toFields(sig []string) []Field {
|
||||
}
|
||||
|
||||
// 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
|
||||
|
||||
47
vendor/golang.org/x/tools/internal/modindex/symbols.go
generated
vendored
47
vendor/golang.org/x/tools/internal/modindex/symbols.go
generated
vendored
@@ -12,6 +12,7 @@ import (
|
||||
"go/types"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"runtime"
|
||||
"slices"
|
||||
"strings"
|
||||
|
||||
@@ -19,29 +20,30 @@ import (
|
||||
)
|
||||
|
||||
// The name of a symbol contains information about the symbol:
|
||||
// <name> T for types
|
||||
// <name> C for consts
|
||||
// <name> V for vars
|
||||
// <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
|
||||
// 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
|
||||
kind string // T, C, V, or F, follwed by D if deprecated
|
||||
sig string // signature information, for F
|
||||
}
|
||||
|
||||
// find the symbols for the best directories
|
||||
func getSymbols(cd Abspath, dirs map[string][]*directory) {
|
||||
var g errgroup.Group
|
||||
g.SetLimit(-1) // maybe throttle this some day
|
||||
g.SetLimit(max(2, runtime.GOMAXPROCS(0)/2))
|
||||
for _, vv := range dirs {
|
||||
// throttling some day?
|
||||
d := vv[0]
|
||||
g.Go(func() error {
|
||||
thedir := filepath.Join(string(cd), string(d.path))
|
||||
mode := parser.SkipObjectResolution
|
||||
mode := parser.SkipObjectResolution | parser.ParseComments
|
||||
|
||||
fi, err := os.ReadDir(thedir)
|
||||
if err != nil {
|
||||
@@ -84,6 +86,9 @@ func getFileExports(f *ast.File) []symbol {
|
||||
// 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.
|
||||
@@ -107,7 +112,7 @@ func getFileExports(f *ast.File) []symbol {
|
||||
// print struct tags. So for this to happen the type of a formal parameter
|
||||
// has to be a explict 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 not ignore such pathologies
|
||||
// a waste of effort, but let's remember the possibility
|
||||
if strings.Contains(tp, "$") {
|
||||
continue
|
||||
}
|
||||
@@ -127,12 +132,16 @@ func getFileExports(f *ast.File) []symbol {
|
||||
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 {
|
||||
@@ -141,8 +150,12 @@ func getFileExports(f *ast.File) []symbol {
|
||||
}
|
||||
}
|
||||
case token.TYPE:
|
||||
tp := "T"
|
||||
if depr {
|
||||
tp += "D"
|
||||
}
|
||||
for _, sp := range decl.Specs {
|
||||
if s := newsym(pkg, sp.(*ast.TypeSpec).Name.Name, "T", ""); s != nil {
|
||||
if s := newsym(pkg, sp.(*ast.TypeSpec).Name.Name, tp, ""); s != nil {
|
||||
ans = append(ans, *s)
|
||||
}
|
||||
}
|
||||
@@ -160,6 +173,22 @@ func newsym(pkg, name, kind, sig string) *symbol {
|
||||
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
|
||||
lines := strings.Split(doc.Text(), "\n\n")
|
||||
for _, line := range lines {
|
||||
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
|
||||
|
||||
4
vendor/golang.org/x/tools/internal/packagesinternal/packages.go
generated
vendored
4
vendor/golang.org/x/tools/internal/packagesinternal/packages.go
generated
vendored
@@ -5,7 +5,7 @@
|
||||
// Package packagesinternal exposes internal-only fields from go/packages.
|
||||
package packagesinternal
|
||||
|
||||
var GetDepsErrors = func(p interface{}) []*PackageError { return nil }
|
||||
var GetDepsErrors = func(p any) []*PackageError { return nil }
|
||||
|
||||
type PackageError struct {
|
||||
ImportStack []string // shortest path from package named on command line to this one
|
||||
@@ -16,5 +16,5 @@ type PackageError struct {
|
||||
var TypecheckCgo int
|
||||
var DepsErrors int // must be set as a LoadMode to call GetDepsErrors
|
||||
|
||||
var SetModFlag = func(config interface{}, value string) {}
|
||||
var SetModFlag = func(config any, value string) {}
|
||||
var SetModFile = func(config interface{}, value string) {}
|
||||
|
||||
219
vendor/golang.org/x/tools/internal/stdlib/manifest.go
generated
vendored
219
vendor/golang.org/x/tools/internal/stdlib/manifest.go
generated
vendored
@@ -268,6 +268,8 @@ var PackageSymbols = map[string][]Symbol{
|
||||
{"ErrTooLarge", Var, 0},
|
||||
{"Fields", Func, 0},
|
||||
{"FieldsFunc", Func, 0},
|
||||
{"FieldsFuncSeq", Func, 24},
|
||||
{"FieldsSeq", Func, 24},
|
||||
{"HasPrefix", Func, 0},
|
||||
{"HasSuffix", Func, 0},
|
||||
{"Index", Func, 0},
|
||||
@@ -280,6 +282,7 @@ var PackageSymbols = map[string][]Symbol{
|
||||
{"LastIndexAny", Func, 0},
|
||||
{"LastIndexByte", Func, 5},
|
||||
{"LastIndexFunc", Func, 0},
|
||||
{"Lines", Func, 24},
|
||||
{"Map", Func, 0},
|
||||
{"MinRead", Const, 0},
|
||||
{"NewBuffer", Func, 0},
|
||||
@@ -293,7 +296,9 @@ var PackageSymbols = map[string][]Symbol{
|
||||
{"Split", Func, 0},
|
||||
{"SplitAfter", Func, 0},
|
||||
{"SplitAfterN", Func, 0},
|
||||
{"SplitAfterSeq", Func, 24},
|
||||
{"SplitN", Func, 0},
|
||||
{"SplitSeq", Func, 24},
|
||||
{"Title", Func, 0},
|
||||
{"ToLower", Func, 0},
|
||||
{"ToLowerSpecial", Func, 0},
|
||||
@@ -535,6 +540,7 @@ var PackageSymbols = map[string][]Symbol{
|
||||
{"NewCTR", Func, 0},
|
||||
{"NewGCM", Func, 2},
|
||||
{"NewGCMWithNonceSize", Func, 5},
|
||||
{"NewGCMWithRandomNonce", Func, 24},
|
||||
{"NewGCMWithTagSize", Func, 11},
|
||||
{"NewOFB", Func, 0},
|
||||
{"Stream", Type, 0},
|
||||
@@ -673,6 +679,14 @@ var PackageSymbols = map[string][]Symbol{
|
||||
{"Unmarshal", Func, 0},
|
||||
{"UnmarshalCompressed", Func, 15},
|
||||
},
|
||||
"crypto/fips140": {
|
||||
{"Enabled", Func, 24},
|
||||
},
|
||||
"crypto/hkdf": {
|
||||
{"Expand", Func, 24},
|
||||
{"Extract", Func, 24},
|
||||
{"Key", Func, 24},
|
||||
},
|
||||
"crypto/hmac": {
|
||||
{"Equal", Func, 1},
|
||||
{"New", Func, 0},
|
||||
@@ -683,11 +697,43 @@ var PackageSymbols = map[string][]Symbol{
|
||||
{"Size", Const, 0},
|
||||
{"Sum", Func, 2},
|
||||
},
|
||||
"crypto/mlkem": {
|
||||
{"(*DecapsulationKey1024).Bytes", Method, 24},
|
||||
{"(*DecapsulationKey1024).Decapsulate", Method, 24},
|
||||
{"(*DecapsulationKey1024).EncapsulationKey", Method, 24},
|
||||
{"(*DecapsulationKey768).Bytes", Method, 24},
|
||||
{"(*DecapsulationKey768).Decapsulate", Method, 24},
|
||||
{"(*DecapsulationKey768).EncapsulationKey", Method, 24},
|
||||
{"(*EncapsulationKey1024).Bytes", Method, 24},
|
||||
{"(*EncapsulationKey1024).Encapsulate", Method, 24},
|
||||
{"(*EncapsulationKey768).Bytes", Method, 24},
|
||||
{"(*EncapsulationKey768).Encapsulate", Method, 24},
|
||||
{"CiphertextSize1024", Const, 24},
|
||||
{"CiphertextSize768", Const, 24},
|
||||
{"DecapsulationKey1024", Type, 24},
|
||||
{"DecapsulationKey768", Type, 24},
|
||||
{"EncapsulationKey1024", Type, 24},
|
||||
{"EncapsulationKey768", Type, 24},
|
||||
{"EncapsulationKeySize1024", Const, 24},
|
||||
{"EncapsulationKeySize768", Const, 24},
|
||||
{"GenerateKey1024", Func, 24},
|
||||
{"GenerateKey768", Func, 24},
|
||||
{"NewDecapsulationKey1024", Func, 24},
|
||||
{"NewDecapsulationKey768", Func, 24},
|
||||
{"NewEncapsulationKey1024", Func, 24},
|
||||
{"NewEncapsulationKey768", Func, 24},
|
||||
{"SeedSize", Const, 24},
|
||||
{"SharedKeySize", Const, 24},
|
||||
},
|
||||
"crypto/pbkdf2": {
|
||||
{"Key", Func, 24},
|
||||
},
|
||||
"crypto/rand": {
|
||||
{"Int", Func, 0},
|
||||
{"Prime", Func, 0},
|
||||
{"Read", Func, 0},
|
||||
{"Reader", Var, 0},
|
||||
{"Text", Func, 24},
|
||||
},
|
||||
"crypto/rc4": {
|
||||
{"(*Cipher).Reset", Method, 0},
|
||||
@@ -766,6 +812,39 @@ var PackageSymbols = map[string][]Symbol{
|
||||
{"Sum224", Func, 2},
|
||||
{"Sum256", Func, 2},
|
||||
},
|
||||
"crypto/sha3": {
|
||||
{"(*SHA3).AppendBinary", Method, 24},
|
||||
{"(*SHA3).BlockSize", Method, 24},
|
||||
{"(*SHA3).MarshalBinary", Method, 24},
|
||||
{"(*SHA3).Reset", Method, 24},
|
||||
{"(*SHA3).Size", Method, 24},
|
||||
{"(*SHA3).Sum", Method, 24},
|
||||
{"(*SHA3).UnmarshalBinary", Method, 24},
|
||||
{"(*SHA3).Write", Method, 24},
|
||||
{"(*SHAKE).AppendBinary", Method, 24},
|
||||
{"(*SHAKE).BlockSize", Method, 24},
|
||||
{"(*SHAKE).MarshalBinary", Method, 24},
|
||||
{"(*SHAKE).Read", Method, 24},
|
||||
{"(*SHAKE).Reset", Method, 24},
|
||||
{"(*SHAKE).UnmarshalBinary", Method, 24},
|
||||
{"(*SHAKE).Write", Method, 24},
|
||||
{"New224", Func, 24},
|
||||
{"New256", Func, 24},
|
||||
{"New384", Func, 24},
|
||||
{"New512", Func, 24},
|
||||
{"NewCSHAKE128", Func, 24},
|
||||
{"NewCSHAKE256", Func, 24},
|
||||
{"NewSHAKE128", Func, 24},
|
||||
{"NewSHAKE256", Func, 24},
|
||||
{"SHA3", Type, 24},
|
||||
{"SHAKE", Type, 24},
|
||||
{"Sum224", Func, 24},
|
||||
{"Sum256", Func, 24},
|
||||
{"Sum384", Func, 24},
|
||||
{"Sum512", Func, 24},
|
||||
{"SumSHAKE128", Func, 24},
|
||||
{"SumSHAKE256", Func, 24},
|
||||
},
|
||||
"crypto/sha512": {
|
||||
{"BlockSize", Const, 0},
|
||||
{"New", Func, 0},
|
||||
@@ -788,6 +867,7 @@ var PackageSymbols = map[string][]Symbol{
|
||||
{"ConstantTimeEq", Func, 0},
|
||||
{"ConstantTimeLessOrEq", Func, 2},
|
||||
{"ConstantTimeSelect", Func, 0},
|
||||
{"WithDataIndependentTiming", Func, 24},
|
||||
{"XORBytes", Func, 20},
|
||||
},
|
||||
"crypto/tls": {
|
||||
@@ -864,6 +944,7 @@ var PackageSymbols = map[string][]Symbol{
|
||||
{"ClientHelloInfo", Type, 4},
|
||||
{"ClientHelloInfo.CipherSuites", Field, 4},
|
||||
{"ClientHelloInfo.Conn", Field, 8},
|
||||
{"ClientHelloInfo.Extensions", Field, 24},
|
||||
{"ClientHelloInfo.ServerName", Field, 4},
|
||||
{"ClientHelloInfo.SignatureSchemes", Field, 8},
|
||||
{"ClientHelloInfo.SupportedCurves", Field, 4},
|
||||
@@ -881,6 +962,7 @@ var PackageSymbols = map[string][]Symbol{
|
||||
{"Config.CurvePreferences", Field, 3},
|
||||
{"Config.DynamicRecordSizingDisabled", Field, 7},
|
||||
{"Config.EncryptedClientHelloConfigList", Field, 23},
|
||||
{"Config.EncryptedClientHelloKeys", Field, 24},
|
||||
{"Config.EncryptedClientHelloRejectionVerify", Field, 23},
|
||||
{"Config.GetCertificate", Field, 4},
|
||||
{"Config.GetClientCertificate", Field, 8},
|
||||
@@ -934,6 +1016,10 @@ var PackageSymbols = map[string][]Symbol{
|
||||
{"ECHRejectionError", Type, 23},
|
||||
{"ECHRejectionError.RetryConfigList", Field, 23},
|
||||
{"Ed25519", Const, 13},
|
||||
{"EncryptedClientHelloKey", Type, 24},
|
||||
{"EncryptedClientHelloKey.Config", Field, 24},
|
||||
{"EncryptedClientHelloKey.PrivateKey", Field, 24},
|
||||
{"EncryptedClientHelloKey.SendAsRetry", Field, 24},
|
||||
{"InsecureCipherSuites", Func, 14},
|
||||
{"Listen", Func, 0},
|
||||
{"LoadX509KeyPair", Func, 0},
|
||||
@@ -1032,6 +1118,7 @@ var PackageSymbols = map[string][]Symbol{
|
||||
{"VersionTLS12", Const, 2},
|
||||
{"VersionTLS13", Const, 12},
|
||||
{"X25519", Const, 8},
|
||||
{"X25519MLKEM768", Const, 24},
|
||||
{"X509KeyPair", Func, 0},
|
||||
},
|
||||
"crypto/x509": {
|
||||
@@ -1056,6 +1143,8 @@ var PackageSymbols = map[string][]Symbol{
|
||||
{"(ConstraintViolationError).Error", Method, 0},
|
||||
{"(HostnameError).Error", Method, 0},
|
||||
{"(InsecureAlgorithmError).Error", Method, 6},
|
||||
{"(OID).AppendBinary", Method, 24},
|
||||
{"(OID).AppendText", Method, 24},
|
||||
{"(OID).Equal", Method, 22},
|
||||
{"(OID).EqualASN1OID", Method, 22},
|
||||
{"(OID).MarshalBinary", Method, 23},
|
||||
@@ -1084,6 +1173,10 @@ var PackageSymbols = map[string][]Symbol{
|
||||
{"Certificate.Extensions", Field, 2},
|
||||
{"Certificate.ExtraExtensions", Field, 2},
|
||||
{"Certificate.IPAddresses", Field, 1},
|
||||
{"Certificate.InhibitAnyPolicy", Field, 24},
|
||||
{"Certificate.InhibitAnyPolicyZero", Field, 24},
|
||||
{"Certificate.InhibitPolicyMapping", Field, 24},
|
||||
{"Certificate.InhibitPolicyMappingZero", Field, 24},
|
||||
{"Certificate.IsCA", Field, 0},
|
||||
{"Certificate.Issuer", Field, 0},
|
||||
{"Certificate.IssuingCertificateURL", Field, 2},
|
||||
@@ -1100,6 +1193,7 @@ var PackageSymbols = map[string][]Symbol{
|
||||
{"Certificate.PermittedURIDomains", Field, 10},
|
||||
{"Certificate.Policies", Field, 22},
|
||||
{"Certificate.PolicyIdentifiers", Field, 0},
|
||||
{"Certificate.PolicyMappings", Field, 24},
|
||||
{"Certificate.PublicKey", Field, 0},
|
||||
{"Certificate.PublicKeyAlgorithm", Field, 0},
|
||||
{"Certificate.Raw", Field, 0},
|
||||
@@ -1107,6 +1201,8 @@ var PackageSymbols = map[string][]Symbol{
|
||||
{"Certificate.RawSubject", Field, 0},
|
||||
{"Certificate.RawSubjectPublicKeyInfo", Field, 0},
|
||||
{"Certificate.RawTBSCertificate", Field, 0},
|
||||
{"Certificate.RequireExplicitPolicy", Field, 24},
|
||||
{"Certificate.RequireExplicitPolicyZero", Field, 24},
|
||||
{"Certificate.SerialNumber", Field, 0},
|
||||
{"Certificate.Signature", Field, 0},
|
||||
{"Certificate.SignatureAlgorithm", Field, 0},
|
||||
@@ -1198,6 +1294,7 @@ var PackageSymbols = map[string][]Symbol{
|
||||
{"NameConstraintsWithoutSANs", Const, 10},
|
||||
{"NameMismatch", Const, 8},
|
||||
{"NewCertPool", Func, 0},
|
||||
{"NoValidChains", Const, 24},
|
||||
{"NotAuthorizedToSign", Const, 0},
|
||||
{"OID", Type, 22},
|
||||
{"OIDFromInts", Func, 22},
|
||||
@@ -1219,6 +1316,9 @@ var PackageSymbols = map[string][]Symbol{
|
||||
{"ParsePKCS8PrivateKey", Func, 0},
|
||||
{"ParsePKIXPublicKey", Func, 0},
|
||||
{"ParseRevocationList", Func, 19},
|
||||
{"PolicyMapping", Type, 24},
|
||||
{"PolicyMapping.IssuerDomainPolicy", Field, 24},
|
||||
{"PolicyMapping.SubjectDomainPolicy", Field, 24},
|
||||
{"PublicKeyAlgorithm", Type, 0},
|
||||
{"PureEd25519", Const, 13},
|
||||
{"RSA", Const, 0},
|
||||
@@ -1265,6 +1365,7 @@ var PackageSymbols = map[string][]Symbol{
|
||||
{"UnknownPublicKeyAlgorithm", Const, 0},
|
||||
{"UnknownSignatureAlgorithm", Const, 0},
|
||||
{"VerifyOptions", Type, 0},
|
||||
{"VerifyOptions.CertificatePolicies", Field, 24},
|
||||
{"VerifyOptions.CurrentTime", Field, 0},
|
||||
{"VerifyOptions.DNSName", Field, 0},
|
||||
{"VerifyOptions.Intermediates", Field, 0},
|
||||
@@ -1975,6 +2076,8 @@ var PackageSymbols = map[string][]Symbol{
|
||||
{"(*File).DynString", Method, 1},
|
||||
{"(*File).DynValue", Method, 21},
|
||||
{"(*File).DynamicSymbols", Method, 4},
|
||||
{"(*File).DynamicVersionNeeds", Method, 24},
|
||||
{"(*File).DynamicVersions", Method, 24},
|
||||
{"(*File).ImportedLibraries", Method, 0},
|
||||
{"(*File).ImportedSymbols", Method, 0},
|
||||
{"(*File).Section", Method, 0},
|
||||
@@ -2240,6 +2343,19 @@ var PackageSymbols = map[string][]Symbol{
|
||||
{"DynFlag", Type, 0},
|
||||
{"DynFlag1", Type, 21},
|
||||
{"DynTag", Type, 0},
|
||||
{"DynamicVersion", Type, 24},
|
||||
{"DynamicVersion.Deps", Field, 24},
|
||||
{"DynamicVersion.Flags", Field, 24},
|
||||
{"DynamicVersion.Index", Field, 24},
|
||||
{"DynamicVersion.Name", Field, 24},
|
||||
{"DynamicVersionDep", Type, 24},
|
||||
{"DynamicVersionDep.Dep", Field, 24},
|
||||
{"DynamicVersionDep.Flags", Field, 24},
|
||||
{"DynamicVersionDep.Index", Field, 24},
|
||||
{"DynamicVersionFlag", Type, 24},
|
||||
{"DynamicVersionNeed", Type, 24},
|
||||
{"DynamicVersionNeed.Name", Field, 24},
|
||||
{"DynamicVersionNeed.Needs", Field, 24},
|
||||
{"EI_ABIVERSION", Const, 0},
|
||||
{"EI_CLASS", Const, 0},
|
||||
{"EI_DATA", Const, 0},
|
||||
@@ -3726,8 +3842,19 @@ var PackageSymbols = map[string][]Symbol{
|
||||
{"Symbol.Size", Field, 0},
|
||||
{"Symbol.Value", Field, 0},
|
||||
{"Symbol.Version", Field, 13},
|
||||
{"Symbol.VersionIndex", Field, 24},
|
||||
{"Symbol.VersionScope", Field, 24},
|
||||
{"SymbolVersionScope", Type, 24},
|
||||
{"Type", Type, 0},
|
||||
{"VER_FLG_BASE", Const, 24},
|
||||
{"VER_FLG_INFO", Const, 24},
|
||||
{"VER_FLG_WEAK", Const, 24},
|
||||
{"Version", Type, 0},
|
||||
{"VersionScopeGlobal", Const, 24},
|
||||
{"VersionScopeHidden", Const, 24},
|
||||
{"VersionScopeLocal", Const, 24},
|
||||
{"VersionScopeNone", Const, 24},
|
||||
{"VersionScopeSpecific", Const, 24},
|
||||
},
|
||||
"debug/gosym": {
|
||||
{"(*DecodingError).Error", Method, 0},
|
||||
@@ -4453,8 +4580,10 @@ var PackageSymbols = map[string][]Symbol{
|
||||
{"FS", Type, 16},
|
||||
},
|
||||
"encoding": {
|
||||
{"BinaryAppender", Type, 24},
|
||||
{"BinaryMarshaler", Type, 2},
|
||||
{"BinaryUnmarshaler", Type, 2},
|
||||
{"TextAppender", Type, 24},
|
||||
{"TextMarshaler", Type, 2},
|
||||
{"TextUnmarshaler", Type, 2},
|
||||
},
|
||||
@@ -5984,13 +6113,16 @@ var PackageSymbols = map[string][]Symbol{
|
||||
{"(*Interface).Complete", Method, 5},
|
||||
{"(*Interface).Embedded", Method, 5},
|
||||
{"(*Interface).EmbeddedType", Method, 11},
|
||||
{"(*Interface).EmbeddedTypes", Method, 24},
|
||||
{"(*Interface).Empty", Method, 5},
|
||||
{"(*Interface).ExplicitMethod", Method, 5},
|
||||
{"(*Interface).ExplicitMethods", Method, 24},
|
||||
{"(*Interface).IsComparable", Method, 18},
|
||||
{"(*Interface).IsImplicit", Method, 18},
|
||||
{"(*Interface).IsMethodSet", Method, 18},
|
||||
{"(*Interface).MarkImplicit", Method, 18},
|
||||
{"(*Interface).Method", Method, 5},
|
||||
{"(*Interface).Methods", Method, 24},
|
||||
{"(*Interface).NumEmbeddeds", Method, 5},
|
||||
{"(*Interface).NumExplicitMethods", Method, 5},
|
||||
{"(*Interface).NumMethods", Method, 5},
|
||||
@@ -6011,9 +6143,11 @@ var PackageSymbols = map[string][]Symbol{
|
||||
{"(*MethodSet).At", Method, 5},
|
||||
{"(*MethodSet).Len", Method, 5},
|
||||
{"(*MethodSet).Lookup", Method, 5},
|
||||
{"(*MethodSet).Methods", Method, 24},
|
||||
{"(*MethodSet).String", Method, 5},
|
||||
{"(*Named).AddMethod", Method, 5},
|
||||
{"(*Named).Method", Method, 5},
|
||||
{"(*Named).Methods", Method, 24},
|
||||
{"(*Named).NumMethods", Method, 5},
|
||||
{"(*Named).Obj", Method, 5},
|
||||
{"(*Named).Origin", Method, 18},
|
||||
@@ -6054,6 +6188,7 @@ var PackageSymbols = map[string][]Symbol{
|
||||
{"(*Pointer).String", Method, 5},
|
||||
{"(*Pointer).Underlying", Method, 5},
|
||||
{"(*Scope).Child", Method, 5},
|
||||
{"(*Scope).Children", Method, 24},
|
||||
{"(*Scope).Contains", Method, 5},
|
||||
{"(*Scope).End", Method, 5},
|
||||
{"(*Scope).Innermost", Method, 5},
|
||||
@@ -6089,6 +6224,7 @@ var PackageSymbols = map[string][]Symbol{
|
||||
{"(*StdSizes).Offsetsof", Method, 5},
|
||||
{"(*StdSizes).Sizeof", Method, 5},
|
||||
{"(*Struct).Field", Method, 5},
|
||||
{"(*Struct).Fields", Method, 24},
|
||||
{"(*Struct).NumFields", Method, 5},
|
||||
{"(*Struct).String", Method, 5},
|
||||
{"(*Struct).Tag", Method, 5},
|
||||
@@ -6100,8 +6236,10 @@ var PackageSymbols = map[string][]Symbol{
|
||||
{"(*Tuple).Len", Method, 5},
|
||||
{"(*Tuple).String", Method, 5},
|
||||
{"(*Tuple).Underlying", Method, 5},
|
||||
{"(*Tuple).Variables", Method, 24},
|
||||
{"(*TypeList).At", Method, 18},
|
||||
{"(*TypeList).Len", Method, 18},
|
||||
{"(*TypeList).Types", Method, 24},
|
||||
{"(*TypeName).Exported", Method, 5},
|
||||
{"(*TypeName).Id", Method, 5},
|
||||
{"(*TypeName).IsAlias", Method, 9},
|
||||
@@ -6119,9 +6257,11 @@ var PackageSymbols = map[string][]Symbol{
|
||||
{"(*TypeParam).Underlying", Method, 18},
|
||||
{"(*TypeParamList).At", Method, 18},
|
||||
{"(*TypeParamList).Len", Method, 18},
|
||||
{"(*TypeParamList).TypeParams", Method, 24},
|
||||
{"(*Union).Len", Method, 18},
|
||||
{"(*Union).String", Method, 18},
|
||||
{"(*Union).Term", Method, 18},
|
||||
{"(*Union).Terms", Method, 24},
|
||||
{"(*Union).Underlying", Method, 18},
|
||||
{"(*Var).Anonymous", Method, 5},
|
||||
{"(*Var).Embedded", Method, 11},
|
||||
@@ -6392,10 +6532,12 @@ var PackageSymbols = map[string][]Symbol{
|
||||
{"(*Hash).WriteByte", Method, 14},
|
||||
{"(*Hash).WriteString", Method, 14},
|
||||
{"Bytes", Func, 19},
|
||||
{"Comparable", Func, 24},
|
||||
{"Hash", Type, 14},
|
||||
{"MakeSeed", Func, 14},
|
||||
{"Seed", Type, 14},
|
||||
{"String", Func, 19},
|
||||
{"WriteComparable", Func, 24},
|
||||
},
|
||||
"html": {
|
||||
{"EscapeString", Func, 0},
|
||||
@@ -7082,6 +7224,7 @@ var PackageSymbols = map[string][]Symbol{
|
||||
{"(*JSONHandler).WithGroup", Method, 21},
|
||||
{"(*Level).UnmarshalJSON", Method, 21},
|
||||
{"(*Level).UnmarshalText", Method, 21},
|
||||
{"(*LevelVar).AppendText", Method, 24},
|
||||
{"(*LevelVar).Level", Method, 21},
|
||||
{"(*LevelVar).MarshalText", Method, 21},
|
||||
{"(*LevelVar).Set", Method, 21},
|
||||
@@ -7110,6 +7253,7 @@ var PackageSymbols = map[string][]Symbol{
|
||||
{"(Attr).Equal", Method, 21},
|
||||
{"(Attr).String", Method, 21},
|
||||
{"(Kind).String", Method, 21},
|
||||
{"(Level).AppendText", Method, 24},
|
||||
{"(Level).Level", Method, 21},
|
||||
{"(Level).MarshalJSON", Method, 21},
|
||||
{"(Level).MarshalText", Method, 21},
|
||||
@@ -7140,6 +7284,7 @@ var PackageSymbols = map[string][]Symbol{
|
||||
{"Debug", Func, 21},
|
||||
{"DebugContext", Func, 21},
|
||||
{"Default", Func, 21},
|
||||
{"DiscardHandler", Var, 24},
|
||||
{"Duration", Func, 21},
|
||||
{"DurationValue", Func, 21},
|
||||
{"Error", Func, 21},
|
||||
@@ -7375,6 +7520,7 @@ var PackageSymbols = map[string][]Symbol{
|
||||
{"(*Float).Acc", Method, 5},
|
||||
{"(*Float).Add", Method, 5},
|
||||
{"(*Float).Append", Method, 5},
|
||||
{"(*Float).AppendText", Method, 24},
|
||||
{"(*Float).Cmp", Method, 5},
|
||||
{"(*Float).Copy", Method, 5},
|
||||
{"(*Float).Float32", Method, 5},
|
||||
@@ -7421,6 +7567,7 @@ var PackageSymbols = map[string][]Symbol{
|
||||
{"(*Int).And", Method, 0},
|
||||
{"(*Int).AndNot", Method, 0},
|
||||
{"(*Int).Append", Method, 6},
|
||||
{"(*Int).AppendText", Method, 24},
|
||||
{"(*Int).Binomial", Method, 0},
|
||||
{"(*Int).Bit", Method, 0},
|
||||
{"(*Int).BitLen", Method, 0},
|
||||
@@ -7477,6 +7624,7 @@ var PackageSymbols = map[string][]Symbol{
|
||||
{"(*Int).Xor", Method, 0},
|
||||
{"(*Rat).Abs", Method, 0},
|
||||
{"(*Rat).Add", Method, 0},
|
||||
{"(*Rat).AppendText", Method, 24},
|
||||
{"(*Rat).Cmp", Method, 0},
|
||||
{"(*Rat).Denom", Method, 0},
|
||||
{"(*Rat).Float32", Method, 4},
|
||||
@@ -7659,11 +7807,13 @@ var PackageSymbols = map[string][]Symbol{
|
||||
{"Zipf", Type, 0},
|
||||
},
|
||||
"math/rand/v2": {
|
||||
{"(*ChaCha8).AppendBinary", Method, 24},
|
||||
{"(*ChaCha8).MarshalBinary", Method, 22},
|
||||
{"(*ChaCha8).Read", Method, 23},
|
||||
{"(*ChaCha8).Seed", Method, 22},
|
||||
{"(*ChaCha8).Uint64", Method, 22},
|
||||
{"(*ChaCha8).UnmarshalBinary", Method, 22},
|
||||
{"(*PCG).AppendBinary", Method, 24},
|
||||
{"(*PCG).MarshalBinary", Method, 22},
|
||||
{"(*PCG).Seed", Method, 22},
|
||||
{"(*PCG).Uint64", Method, 22},
|
||||
@@ -7931,6 +8081,7 @@ var PackageSymbols = map[string][]Symbol{
|
||||
{"(*UnixListener).SyscallConn", Method, 10},
|
||||
{"(Flags).String", Method, 0},
|
||||
{"(HardwareAddr).String", Method, 0},
|
||||
{"(IP).AppendText", Method, 24},
|
||||
{"(IP).DefaultMask", Method, 0},
|
||||
{"(IP).Equal", Method, 0},
|
||||
{"(IP).IsGlobalUnicast", Method, 0},
|
||||
@@ -8131,6 +8282,9 @@ var PackageSymbols = map[string][]Symbol{
|
||||
{"(*MaxBytesError).Error", Method, 19},
|
||||
{"(*ProtocolError).Error", Method, 0},
|
||||
{"(*ProtocolError).Is", Method, 21},
|
||||
{"(*Protocols).SetHTTP1", Method, 24},
|
||||
{"(*Protocols).SetHTTP2", Method, 24},
|
||||
{"(*Protocols).SetUnencryptedHTTP2", Method, 24},
|
||||
{"(*Request).AddCookie", Method, 0},
|
||||
{"(*Request).BasicAuth", Method, 4},
|
||||
{"(*Request).Clone", Method, 13},
|
||||
@@ -8190,6 +8344,10 @@ var PackageSymbols = map[string][]Symbol{
|
||||
{"(Header).Values", Method, 14},
|
||||
{"(Header).Write", Method, 0},
|
||||
{"(Header).WriteSubset", Method, 0},
|
||||
{"(Protocols).HTTP1", Method, 24},
|
||||
{"(Protocols).HTTP2", Method, 24},
|
||||
{"(Protocols).String", Method, 24},
|
||||
{"(Protocols).UnencryptedHTTP2", Method, 24},
|
||||
{"AllowQuerySemicolons", Func, 17},
|
||||
{"CanonicalHeaderKey", Func, 0},
|
||||
{"Client", Type, 0},
|
||||
@@ -8252,6 +8410,18 @@ var PackageSymbols = map[string][]Symbol{
|
||||
{"FileSystem", Type, 0},
|
||||
{"Flusher", Type, 0},
|
||||
{"Get", Func, 0},
|
||||
{"HTTP2Config", Type, 24},
|
||||
{"HTTP2Config.CountError", Field, 24},
|
||||
{"HTTP2Config.MaxConcurrentStreams", Field, 24},
|
||||
{"HTTP2Config.MaxDecoderHeaderTableSize", Field, 24},
|
||||
{"HTTP2Config.MaxEncoderHeaderTableSize", Field, 24},
|
||||
{"HTTP2Config.MaxReadFrameSize", Field, 24},
|
||||
{"HTTP2Config.MaxReceiveBufferPerConnection", Field, 24},
|
||||
{"HTTP2Config.MaxReceiveBufferPerStream", Field, 24},
|
||||
{"HTTP2Config.PermitProhibitedCipherSuites", Field, 24},
|
||||
{"HTTP2Config.PingTimeout", Field, 24},
|
||||
{"HTTP2Config.SendPingTimeout", Field, 24},
|
||||
{"HTTP2Config.WriteByteTimeout", Field, 24},
|
||||
{"Handle", Func, 0},
|
||||
{"HandleFunc", Func, 0},
|
||||
{"Handler", Type, 0},
|
||||
@@ -8292,6 +8462,7 @@ var PackageSymbols = map[string][]Symbol{
|
||||
{"PostForm", Func, 0},
|
||||
{"ProtocolError", Type, 0},
|
||||
{"ProtocolError.ErrorString", Field, 0},
|
||||
{"Protocols", Type, 24},
|
||||
{"ProxyFromEnvironment", Func, 0},
|
||||
{"ProxyURL", Func, 0},
|
||||
{"PushOptions", Type, 8},
|
||||
@@ -8361,9 +8532,11 @@ var PackageSymbols = map[string][]Symbol{
|
||||
{"Server.ConnState", Field, 3},
|
||||
{"Server.DisableGeneralOptionsHandler", Field, 20},
|
||||
{"Server.ErrorLog", Field, 3},
|
||||
{"Server.HTTP2", Field, 24},
|
||||
{"Server.Handler", Field, 0},
|
||||
{"Server.IdleTimeout", Field, 8},
|
||||
{"Server.MaxHeaderBytes", Field, 0},
|
||||
{"Server.Protocols", Field, 24},
|
||||
{"Server.ReadHeaderTimeout", Field, 8},
|
||||
{"Server.ReadTimeout", Field, 0},
|
||||
{"Server.TLSConfig", Field, 0},
|
||||
@@ -8453,12 +8626,14 @@ var PackageSymbols = map[string][]Symbol{
|
||||
{"Transport.ExpectContinueTimeout", Field, 6},
|
||||
{"Transport.ForceAttemptHTTP2", Field, 13},
|
||||
{"Transport.GetProxyConnectHeader", Field, 16},
|
||||
{"Transport.HTTP2", Field, 24},
|
||||
{"Transport.IdleConnTimeout", Field, 7},
|
||||
{"Transport.MaxConnsPerHost", Field, 11},
|
||||
{"Transport.MaxIdleConns", Field, 7},
|
||||
{"Transport.MaxIdleConnsPerHost", Field, 0},
|
||||
{"Transport.MaxResponseHeaderBytes", Field, 7},
|
||||
{"Transport.OnProxyConnectResponse", Field, 20},
|
||||
{"Transport.Protocols", Field, 24},
|
||||
{"Transport.Proxy", Field, 0},
|
||||
{"Transport.ProxyConnectHeader", Field, 8},
|
||||
{"Transport.ReadBufferSize", Field, 13},
|
||||
@@ -8646,6 +8821,8 @@ var PackageSymbols = map[string][]Symbol{
|
||||
{"(*AddrPort).UnmarshalText", Method, 18},
|
||||
{"(*Prefix).UnmarshalBinary", Method, 18},
|
||||
{"(*Prefix).UnmarshalText", Method, 18},
|
||||
{"(Addr).AppendBinary", Method, 24},
|
||||
{"(Addr).AppendText", Method, 24},
|
||||
{"(Addr).AppendTo", Method, 18},
|
||||
{"(Addr).As16", Method, 18},
|
||||
{"(Addr).As4", Method, 18},
|
||||
@@ -8676,6 +8853,8 @@ var PackageSymbols = map[string][]Symbol{
|
||||
{"(Addr).WithZone", Method, 18},
|
||||
{"(Addr).Zone", Method, 18},
|
||||
{"(AddrPort).Addr", Method, 18},
|
||||
{"(AddrPort).AppendBinary", Method, 24},
|
||||
{"(AddrPort).AppendText", Method, 24},
|
||||
{"(AddrPort).AppendTo", Method, 18},
|
||||
{"(AddrPort).Compare", Method, 22},
|
||||
{"(AddrPort).IsValid", Method, 18},
|
||||
@@ -8684,6 +8863,8 @@ var PackageSymbols = map[string][]Symbol{
|
||||
{"(AddrPort).Port", Method, 18},
|
||||
{"(AddrPort).String", Method, 18},
|
||||
{"(Prefix).Addr", Method, 18},
|
||||
{"(Prefix).AppendBinary", Method, 24},
|
||||
{"(Prefix).AppendText", Method, 24},
|
||||
{"(Prefix).AppendTo", Method, 18},
|
||||
{"(Prefix).Bits", Method, 18},
|
||||
{"(Prefix).Contains", Method, 18},
|
||||
@@ -8868,6 +9049,7 @@ var PackageSymbols = map[string][]Symbol{
|
||||
{"(*Error).Temporary", Method, 6},
|
||||
{"(*Error).Timeout", Method, 6},
|
||||
{"(*Error).Unwrap", Method, 13},
|
||||
{"(*URL).AppendBinary", Method, 24},
|
||||
{"(*URL).EscapedFragment", Method, 15},
|
||||
{"(*URL).EscapedPath", Method, 5},
|
||||
{"(*URL).Hostname", Method, 8},
|
||||
@@ -8967,6 +9149,17 @@ var PackageSymbols = map[string][]Symbol{
|
||||
{"(*ProcessState).SysUsage", Method, 0},
|
||||
{"(*ProcessState).SystemTime", Method, 0},
|
||||
{"(*ProcessState).UserTime", Method, 0},
|
||||
{"(*Root).Close", Method, 24},
|
||||
{"(*Root).Create", Method, 24},
|
||||
{"(*Root).FS", Method, 24},
|
||||
{"(*Root).Lstat", Method, 24},
|
||||
{"(*Root).Mkdir", Method, 24},
|
||||
{"(*Root).Name", Method, 24},
|
||||
{"(*Root).Open", Method, 24},
|
||||
{"(*Root).OpenFile", Method, 24},
|
||||
{"(*Root).OpenRoot", Method, 24},
|
||||
{"(*Root).Remove", Method, 24},
|
||||
{"(*Root).Stat", Method, 24},
|
||||
{"(*SyscallError).Error", Method, 0},
|
||||
{"(*SyscallError).Timeout", Method, 10},
|
||||
{"(*SyscallError).Unwrap", Method, 13},
|
||||
@@ -9060,6 +9253,8 @@ var PackageSymbols = map[string][]Symbol{
|
||||
{"O_WRONLY", Const, 0},
|
||||
{"Open", Func, 0},
|
||||
{"OpenFile", Func, 0},
|
||||
{"OpenInRoot", Func, 24},
|
||||
{"OpenRoot", Func, 24},
|
||||
{"PathError", Type, 0},
|
||||
{"PathError.Err", Field, 0},
|
||||
{"PathError.Op", Field, 0},
|
||||
@@ -9081,6 +9276,7 @@ var PackageSymbols = map[string][]Symbol{
|
||||
{"Remove", Func, 0},
|
||||
{"RemoveAll", Func, 0},
|
||||
{"Rename", Func, 0},
|
||||
{"Root", Type, 24},
|
||||
{"SEEK_CUR", Const, 0},
|
||||
{"SEEK_END", Const, 0},
|
||||
{"SEEK_SET", Const, 0},
|
||||
@@ -9422,6 +9618,7 @@ var PackageSymbols = map[string][]Symbol{
|
||||
{"Zero", Func, 0},
|
||||
},
|
||||
"regexp": {
|
||||
{"(*Regexp).AppendText", Method, 24},
|
||||
{"(*Regexp).Copy", Method, 6},
|
||||
{"(*Regexp).Expand", Method, 0},
|
||||
{"(*Regexp).ExpandString", Method, 0},
|
||||
@@ -9602,6 +9799,8 @@ var PackageSymbols = map[string][]Symbol{
|
||||
{"(*StackRecord).Stack", Method, 0},
|
||||
{"(*TypeAssertionError).Error", Method, 0},
|
||||
{"(*TypeAssertionError).RuntimeError", Method, 0},
|
||||
{"(Cleanup).Stop", Method, 24},
|
||||
{"AddCleanup", Func, 24},
|
||||
{"BlockProfile", Func, 1},
|
||||
{"BlockProfileRecord", Type, 1},
|
||||
{"BlockProfileRecord.Count", Field, 1},
|
||||
@@ -9612,6 +9811,7 @@ var PackageSymbols = map[string][]Symbol{
|
||||
{"Caller", Func, 0},
|
||||
{"Callers", Func, 0},
|
||||
{"CallersFrames", Func, 7},
|
||||
{"Cleanup", Type, 24},
|
||||
{"Compiler", Const, 0},
|
||||
{"Error", Type, 0},
|
||||
{"Frame", Type, 7},
|
||||
@@ -9974,6 +10174,8 @@ var PackageSymbols = map[string][]Symbol{
|
||||
{"EqualFold", Func, 0},
|
||||
{"Fields", Func, 0},
|
||||
{"FieldsFunc", Func, 0},
|
||||
{"FieldsFuncSeq", Func, 24},
|
||||
{"FieldsSeq", Func, 24},
|
||||
{"HasPrefix", Func, 0},
|
||||
{"HasSuffix", Func, 0},
|
||||
{"Index", Func, 0},
|
||||
@@ -9986,6 +10188,7 @@ var PackageSymbols = map[string][]Symbol{
|
||||
{"LastIndexAny", Func, 0},
|
||||
{"LastIndexByte", Func, 5},
|
||||
{"LastIndexFunc", Func, 0},
|
||||
{"Lines", Func, 24},
|
||||
{"Map", Func, 0},
|
||||
{"NewReader", Func, 0},
|
||||
{"NewReplacer", Func, 0},
|
||||
@@ -9997,7 +10200,9 @@ var PackageSymbols = map[string][]Symbol{
|
||||
{"Split", Func, 0},
|
||||
{"SplitAfter", Func, 0},
|
||||
{"SplitAfterN", Func, 0},
|
||||
{"SplitAfterSeq", Func, 24},
|
||||
{"SplitN", Func, 0},
|
||||
{"SplitSeq", Func, 24},
|
||||
{"Title", Func, 0},
|
||||
{"ToLower", Func, 0},
|
||||
{"ToLowerSpecial", Func, 0},
|
||||
@@ -16413,7 +16618,9 @@ var PackageSymbols = map[string][]Symbol{
|
||||
{"ValueOf", Func, 0},
|
||||
},
|
||||
"testing": {
|
||||
{"(*B).Chdir", Method, 24},
|
||||
{"(*B).Cleanup", Method, 14},
|
||||
{"(*B).Context", Method, 24},
|
||||
{"(*B).Elapsed", Method, 20},
|
||||
{"(*B).Error", Method, 0},
|
||||
{"(*B).Errorf", Method, 0},
|
||||
@@ -16425,6 +16632,7 @@ var PackageSymbols = map[string][]Symbol{
|
||||
{"(*B).Helper", Method, 9},
|
||||
{"(*B).Log", Method, 0},
|
||||
{"(*B).Logf", Method, 0},
|
||||
{"(*B).Loop", Method, 24},
|
||||
{"(*B).Name", Method, 8},
|
||||
{"(*B).ReportAllocs", Method, 1},
|
||||
{"(*B).ReportMetric", Method, 13},
|
||||
@@ -16442,7 +16650,9 @@ var PackageSymbols = map[string][]Symbol{
|
||||
{"(*B).StopTimer", Method, 0},
|
||||
{"(*B).TempDir", Method, 15},
|
||||
{"(*F).Add", Method, 18},
|
||||
{"(*F).Chdir", Method, 24},
|
||||
{"(*F).Cleanup", Method, 18},
|
||||
{"(*F).Context", Method, 24},
|
||||
{"(*F).Error", Method, 18},
|
||||
{"(*F).Errorf", Method, 18},
|
||||
{"(*F).Fail", Method, 18},
|
||||
@@ -16463,7 +16673,9 @@ var PackageSymbols = map[string][]Symbol{
|
||||
{"(*F).TempDir", Method, 18},
|
||||
{"(*M).Run", Method, 4},
|
||||
{"(*PB).Next", Method, 3},
|
||||
{"(*T).Chdir", Method, 24},
|
||||
{"(*T).Cleanup", Method, 14},
|
||||
{"(*T).Context", Method, 24},
|
||||
{"(*T).Deadline", Method, 15},
|
||||
{"(*T).Error", Method, 0},
|
||||
{"(*T).Errorf", Method, 0},
|
||||
@@ -16954,7 +17166,9 @@ var PackageSymbols = map[string][]Symbol{
|
||||
{"(Time).Add", Method, 0},
|
||||
{"(Time).AddDate", Method, 0},
|
||||
{"(Time).After", Method, 0},
|
||||
{"(Time).AppendBinary", Method, 24},
|
||||
{"(Time).AppendFormat", Method, 5},
|
||||
{"(Time).AppendText", Method, 24},
|
||||
{"(Time).Before", Method, 0},
|
||||
{"(Time).Clock", Method, 0},
|
||||
{"(Time).Compare", Method, 20},
|
||||
@@ -17428,4 +17642,9 @@ var PackageSymbols = map[string][]Symbol{
|
||||
{"String", Func, 0},
|
||||
{"StringData", Func, 0},
|
||||
},
|
||||
"weak": {
|
||||
{"(Pointer).Value", Method, 24},
|
||||
{"Make", Func, 24},
|
||||
{"Pointer", Type, 24},
|
||||
},
|
||||
}
|
||||
|
||||
72
vendor/golang.org/x/tools/internal/typeparams/common.go
generated
vendored
72
vendor/golang.org/x/tools/internal/typeparams/common.go
generated
vendored
@@ -66,75 +66,3 @@ func IsTypeParam(t types.Type) bool {
|
||||
_, ok := types.Unalias(t).(*types.TypeParam)
|
||||
return ok
|
||||
}
|
||||
|
||||
// GenericAssignableTo is a generalization of types.AssignableTo that
|
||||
// implements the following rule for uninstantiated generic types:
|
||||
//
|
||||
// If V and T are generic named types, then V is considered assignable to T if,
|
||||
// for every possible instantiation of V[A_1, ..., A_N], the instantiation
|
||||
// T[A_1, ..., A_N] is valid and V[A_1, ..., A_N] implements T[A_1, ..., A_N].
|
||||
//
|
||||
// If T has structural constraints, they must be satisfied by V.
|
||||
//
|
||||
// For example, consider the following type declarations:
|
||||
//
|
||||
// type Interface[T any] interface {
|
||||
// Accept(T)
|
||||
// }
|
||||
//
|
||||
// type Container[T any] struct {
|
||||
// Element T
|
||||
// }
|
||||
//
|
||||
// func (c Container[T]) Accept(t T) { c.Element = t }
|
||||
//
|
||||
// In this case, GenericAssignableTo reports that instantiations of Container
|
||||
// are assignable to the corresponding instantiation of Interface.
|
||||
func GenericAssignableTo(ctxt *types.Context, V, T types.Type) bool {
|
||||
V = types.Unalias(V)
|
||||
T = types.Unalias(T)
|
||||
|
||||
// If V and T are not both named, or do not have matching non-empty type
|
||||
// parameter lists, fall back on types.AssignableTo.
|
||||
|
||||
VN, Vnamed := V.(*types.Named)
|
||||
TN, Tnamed := T.(*types.Named)
|
||||
if !Vnamed || !Tnamed {
|
||||
return types.AssignableTo(V, T)
|
||||
}
|
||||
|
||||
vtparams := VN.TypeParams()
|
||||
ttparams := TN.TypeParams()
|
||||
if vtparams.Len() == 0 || vtparams.Len() != ttparams.Len() || VN.TypeArgs().Len() != 0 || TN.TypeArgs().Len() != 0 {
|
||||
return types.AssignableTo(V, T)
|
||||
}
|
||||
|
||||
// V and T have the same (non-zero) number of type params. Instantiate both
|
||||
// with the type parameters of V. This must always succeed for V, and will
|
||||
// succeed for T if and only if the type set of each type parameter of V is a
|
||||
// subset of the type set of the corresponding type parameter of T, meaning
|
||||
// that every instantiation of V corresponds to a valid instantiation of T.
|
||||
|
||||
// Minor optimization: ensure we share a context across the two
|
||||
// instantiations below.
|
||||
if ctxt == nil {
|
||||
ctxt = types.NewContext()
|
||||
}
|
||||
|
||||
var targs []types.Type
|
||||
for i := 0; i < vtparams.Len(); i++ {
|
||||
targs = append(targs, vtparams.At(i))
|
||||
}
|
||||
|
||||
vinst, err := types.Instantiate(ctxt, V, targs, true)
|
||||
if err != nil {
|
||||
panic("type parameters should satisfy their own constraints")
|
||||
}
|
||||
|
||||
tinst, err := types.Instantiate(ctxt, T, targs, true)
|
||||
if err != nil {
|
||||
return false
|
||||
}
|
||||
|
||||
return types.AssignableTo(vinst, tinst)
|
||||
}
|
||||
|
||||
11
vendor/golang.org/x/tools/internal/typeparams/coretype.go
generated
vendored
11
vendor/golang.org/x/tools/internal/typeparams/coretype.go
generated
vendored
@@ -109,8 +109,13 @@ func CoreType(T types.Type) types.Type {
|
||||
//
|
||||
// NormalTerms makes no guarantees about the order of terms, except that it
|
||||
// is deterministic.
|
||||
func NormalTerms(typ types.Type) ([]*types.Term, error) {
|
||||
switch typ := typ.Underlying().(type) {
|
||||
func NormalTerms(T types.Type) ([]*types.Term, error) {
|
||||
// typeSetOf(T) == typeSetOf(Unalias(T))
|
||||
typ := types.Unalias(T)
|
||||
if named, ok := typ.(*types.Named); ok {
|
||||
typ = named.Underlying()
|
||||
}
|
||||
switch typ := typ.(type) {
|
||||
case *types.TypeParam:
|
||||
return StructuralTerms(typ)
|
||||
case *types.Union:
|
||||
@@ -118,7 +123,7 @@ func NormalTerms(typ types.Type) ([]*types.Term, error) {
|
||||
case *types.Interface:
|
||||
return InterfaceTermSet(typ)
|
||||
default:
|
||||
return []*types.Term{types.NewTerm(false, typ)}, nil
|
||||
return []*types.Term{types.NewTerm(false, T)}, nil
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
2
vendor/golang.org/x/tools/internal/typesinternal/errorcode.go
generated
vendored
2
vendor/golang.org/x/tools/internal/typesinternal/errorcode.go
generated
vendored
@@ -966,7 +966,7 @@ const (
|
||||
// var _ = string(x)
|
||||
InvalidConversion
|
||||
|
||||
// InvalidUntypedConversion occurs when an there is no valid implicit
|
||||
// InvalidUntypedConversion occurs when there is no valid implicit
|
||||
// conversion from an untyped value satisfying the type constraints of the
|
||||
// context in which it is used.
|
||||
//
|
||||
|
||||
46
vendor/golang.org/x/tools/internal/typesinternal/qualifier.go
generated
vendored
Normal file
46
vendor/golang.org/x/tools/internal/typesinternal/qualifier.go
generated
vendored
Normal file
@@ -0,0 +1,46 @@
|
||||
// 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 typesinternal
|
||||
|
||||
import (
|
||||
"go/ast"
|
||||
"go/types"
|
||||
"strconv"
|
||||
)
|
||||
|
||||
// FileQualifier returns a [types.Qualifier] function that qualifies
|
||||
// imported symbols appropriately based on the import environment of a given
|
||||
// file.
|
||||
// If the same package is imported multiple times, the last appearance is
|
||||
// recorded.
|
||||
func FileQualifier(f *ast.File, pkg *types.Package) types.Qualifier {
|
||||
// Construct mapping of import paths to their defined names.
|
||||
// It is only necessary to look at renaming imports.
|
||||
imports := make(map[string]string)
|
||||
for _, imp := range f.Imports {
|
||||
if imp.Name != nil && imp.Name.Name != "_" {
|
||||
path, _ := strconv.Unquote(imp.Path.Value)
|
||||
imports[path] = imp.Name.Name
|
||||
}
|
||||
}
|
||||
|
||||
// Define qualifier to replace full package paths with names of the imports.
|
||||
return func(p *types.Package) string {
|
||||
if p == nil || p == pkg {
|
||||
return ""
|
||||
}
|
||||
|
||||
if name, ok := imports[p.Path()]; ok {
|
||||
if name == "." {
|
||||
return ""
|
||||
} else {
|
||||
return name
|
||||
}
|
||||
}
|
||||
|
||||
// If there is no local renaming, fall back to the package name.
|
||||
return p.Name()
|
||||
}
|
||||
}
|
||||
3
vendor/golang.org/x/tools/internal/typesinternal/recv.go
generated
vendored
3
vendor/golang.org/x/tools/internal/typesinternal/recv.go
generated
vendored
@@ -11,6 +11,9 @@ import (
|
||||
// ReceiverNamed returns the named type (if any) associated with the
|
||||
// type of recv, which may be of the form N or *N, or aliases thereof.
|
||||
// It also reports whether a Pointer was present.
|
||||
//
|
||||
// The named result may be nil if recv is from a method on an
|
||||
// anonymous interface or struct types or in ill-typed code.
|
||||
func ReceiverNamed(recv *types.Var) (isPtr bool, named *types.Named) {
|
||||
t := recv.Type()
|
||||
if ptr, ok := types.Unalias(t).(*types.Pointer); ok {
|
||||
|
||||
6
vendor/golang.org/x/tools/internal/typesinternal/types.go
generated
vendored
6
vendor/golang.org/x/tools/internal/typesinternal/types.go
generated
vendored
@@ -82,6 +82,7 @@ func NameRelativeTo(pkg *types.Package) types.Qualifier {
|
||||
type NamedOrAlias interface {
|
||||
types.Type
|
||||
Obj() *types.TypeName
|
||||
// TODO(hxjiang): add method TypeArgs() *types.TypeList after stop supporting go1.22.
|
||||
}
|
||||
|
||||
// TypeParams is a light shim around t.TypeParams().
|
||||
@@ -119,3 +120,8 @@ func Origin(t NamedOrAlias) NamedOrAlias {
|
||||
}
|
||||
return t
|
||||
}
|
||||
|
||||
// IsPackageLevel reports whether obj is a package-level symbol.
|
||||
func IsPackageLevel(obj types.Object) bool {
|
||||
return obj.Pkg() != nil && obj.Parent() == obj.Pkg().Scope()
|
||||
}
|
||||
|
||||
40
vendor/golang.org/x/tools/internal/typesinternal/varkind.go
generated
vendored
Normal file
40
vendor/golang.org/x/tools/internal/typesinternal/varkind.go
generated
vendored
Normal file
@@ -0,0 +1,40 @@
|
||||
// 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 typesinternal
|
||||
|
||||
// TODO(adonovan): when CL 645115 lands, define the go1.25 version of
|
||||
// this API that actually does something.
|
||||
|
||||
import "go/types"
|
||||
|
||||
type VarKind uint8
|
||||
|
||||
const (
|
||||
_ VarKind = iota // (not meaningful)
|
||||
PackageVar // a package-level variable
|
||||
LocalVar // a local variable
|
||||
RecvVar // a method receiver variable
|
||||
ParamVar // a function parameter variable
|
||||
ResultVar // a function result variable
|
||||
FieldVar // a struct field
|
||||
)
|
||||
|
||||
func (kind VarKind) String() string {
|
||||
return [...]string{
|
||||
0: "VarKind(0)",
|
||||
PackageVar: "PackageVar",
|
||||
LocalVar: "LocalVar",
|
||||
RecvVar: "RecvVar",
|
||||
ParamVar: "ParamVar",
|
||||
ResultVar: "ResultVar",
|
||||
FieldVar: "FieldVar",
|
||||
}[kind]
|
||||
}
|
||||
|
||||
// GetVarKind returns an invalid VarKind.
|
||||
func GetVarKind(v *types.Var) VarKind { return 0 }
|
||||
|
||||
// SetVarKind has no effect.
|
||||
func SetVarKind(v *types.Var, kind VarKind) {}
|
||||
258
vendor/golang.org/x/tools/internal/typesinternal/zerovalue.go
generated
vendored
258
vendor/golang.org/x/tools/internal/typesinternal/zerovalue.go
generated
vendored
@@ -9,62 +9,97 @@ import (
|
||||
"go/ast"
|
||||
"go/token"
|
||||
"go/types"
|
||||
"strconv"
|
||||
"strings"
|
||||
)
|
||||
|
||||
// ZeroString returns the string representation of the "zero" value of the type t.
|
||||
// This string can be used on the right-hand side of an assignment where the
|
||||
// left-hand side has that explicit type.
|
||||
// Exception: This does not apply to tuples. Their string representation is
|
||||
// informational only and cannot be used in an assignment.
|
||||
// ZeroString returns the string representation of the zero value for any type t.
|
||||
// The boolean result indicates whether the type is or contains an invalid type
|
||||
// or a non-basic (constraint) interface type.
|
||||
//
|
||||
// Even for invalid input types, ZeroString may return a partially correct
|
||||
// string representation. The caller should use the returned isValid boolean
|
||||
// to determine the validity of the expression.
|
||||
//
|
||||
// When assigning to a wider type (such as 'any'), it's the caller's
|
||||
// responsibility to handle any necessary type conversions.
|
||||
//
|
||||
// This string can be used on the right-hand side of an assignment where the
|
||||
// left-hand side has that explicit type.
|
||||
// References to named types are qualified by an appropriate (optional)
|
||||
// qualifier function.
|
||||
// Exception: This does not apply to tuples. Their string representation is
|
||||
// informational only and cannot be used in an assignment.
|
||||
//
|
||||
// See [ZeroExpr] for a variant that returns an [ast.Expr].
|
||||
func ZeroString(t types.Type, qf types.Qualifier) string {
|
||||
func ZeroString(t types.Type, qual types.Qualifier) (_ string, isValid bool) {
|
||||
switch t := t.(type) {
|
||||
case *types.Basic:
|
||||
switch {
|
||||
case t.Info()&types.IsBoolean != 0:
|
||||
return "false"
|
||||
return "false", true
|
||||
case t.Info()&types.IsNumeric != 0:
|
||||
return "0"
|
||||
return "0", true
|
||||
case t.Info()&types.IsString != 0:
|
||||
return `""`
|
||||
return `""`, true
|
||||
case t.Kind() == types.UnsafePointer:
|
||||
fallthrough
|
||||
case t.Kind() == types.UntypedNil:
|
||||
return "nil"
|
||||
return "nil", true
|
||||
case t.Kind() == types.Invalid:
|
||||
return "invalid", false
|
||||
default:
|
||||
panic(fmt.Sprint("ZeroString for unexpected type:", t))
|
||||
panic(fmt.Sprintf("ZeroString for unexpected type %v", t))
|
||||
}
|
||||
|
||||
case *types.Pointer, *types.Slice, *types.Interface, *types.Chan, *types.Map, *types.Signature:
|
||||
return "nil"
|
||||
case *types.Pointer, *types.Slice, *types.Chan, *types.Map, *types.Signature:
|
||||
return "nil", true
|
||||
|
||||
case *types.Named, *types.Alias:
|
||||
case *types.Interface:
|
||||
if !t.IsMethodSet() {
|
||||
return "invalid", false
|
||||
}
|
||||
return "nil", true
|
||||
|
||||
case *types.Named:
|
||||
switch under := t.Underlying().(type) {
|
||||
case *types.Struct, *types.Array:
|
||||
return types.TypeString(t, qf) + "{}"
|
||||
return types.TypeString(t, qual) + "{}", true
|
||||
default:
|
||||
return ZeroString(under, qf)
|
||||
return ZeroString(under, qual)
|
||||
}
|
||||
|
||||
case *types.Alias:
|
||||
switch t.Underlying().(type) {
|
||||
case *types.Struct, *types.Array:
|
||||
return types.TypeString(t, qual) + "{}", true
|
||||
default:
|
||||
// A type parameter can have alias but alias type's underlying type
|
||||
// can never be a type parameter.
|
||||
// Use types.Unalias to preserve the info of type parameter instead
|
||||
// of call Underlying() going right through and get the underlying
|
||||
// type of the type parameter which is always an interface.
|
||||
return ZeroString(types.Unalias(t), qual)
|
||||
}
|
||||
|
||||
case *types.Array, *types.Struct:
|
||||
return types.TypeString(t, qf) + "{}"
|
||||
return types.TypeString(t, qual) + "{}", true
|
||||
|
||||
case *types.TypeParam:
|
||||
// Assumes func new is not shadowed.
|
||||
return "*new(" + types.TypeString(t, qf) + ")"
|
||||
return "*new(" + types.TypeString(t, qual) + ")", true
|
||||
|
||||
case *types.Tuple:
|
||||
// Tuples are not normal values.
|
||||
// We are currently format as "(t[0], ..., t[n])". Could be something else.
|
||||
isValid := true
|
||||
components := make([]string, t.Len())
|
||||
for i := 0; i < t.Len(); i++ {
|
||||
components[i] = ZeroString(t.At(i).Type(), qf)
|
||||
comp, ok := ZeroString(t.At(i).Type(), qual)
|
||||
|
||||
components[i] = comp
|
||||
isValid = isValid && ok
|
||||
}
|
||||
return "(" + strings.Join(components, ", ") + ")"
|
||||
return "(" + strings.Join(components, ", ") + ")", isValid
|
||||
|
||||
case *types.Union:
|
||||
// Variables of these types cannot be created, so it makes
|
||||
@@ -76,45 +111,72 @@ func ZeroString(t types.Type, qf types.Qualifier) string {
|
||||
}
|
||||
}
|
||||
|
||||
// ZeroExpr returns the ast.Expr representation of the "zero" value of the type t.
|
||||
// ZeroExpr is defined for types that are suitable for variables.
|
||||
// It may panic for other types such as Tuple or Union.
|
||||
// ZeroExpr returns the ast.Expr representation of the zero value for any type t.
|
||||
// The boolean result indicates whether the type is or contains an invalid type
|
||||
// or a non-basic (constraint) interface type.
|
||||
//
|
||||
// Even for invalid input types, ZeroExpr may return a partially correct ast.Expr
|
||||
// representation. The caller should use the returned isValid boolean to determine
|
||||
// the validity of the expression.
|
||||
//
|
||||
// This function is designed for types suitable for variables and should not be
|
||||
// used with Tuple or Union types.References to named types are qualified by an
|
||||
// appropriate (optional) qualifier function.
|
||||
//
|
||||
// See [ZeroString] for a variant that returns a string.
|
||||
func ZeroExpr(f *ast.File, pkg *types.Package, typ types.Type) ast.Expr {
|
||||
switch t := typ.(type) {
|
||||
func ZeroExpr(t types.Type, qual types.Qualifier) (_ ast.Expr, isValid bool) {
|
||||
switch t := t.(type) {
|
||||
case *types.Basic:
|
||||
switch {
|
||||
case t.Info()&types.IsBoolean != 0:
|
||||
return &ast.Ident{Name: "false"}
|
||||
return &ast.Ident{Name: "false"}, true
|
||||
case t.Info()&types.IsNumeric != 0:
|
||||
return &ast.BasicLit{Kind: token.INT, Value: "0"}
|
||||
return &ast.BasicLit{Kind: token.INT, Value: "0"}, true
|
||||
case t.Info()&types.IsString != 0:
|
||||
return &ast.BasicLit{Kind: token.STRING, Value: `""`}
|
||||
return &ast.BasicLit{Kind: token.STRING, Value: `""`}, true
|
||||
case t.Kind() == types.UnsafePointer:
|
||||
fallthrough
|
||||
case t.Kind() == types.UntypedNil:
|
||||
return ast.NewIdent("nil")
|
||||
return ast.NewIdent("nil"), true
|
||||
case t.Kind() == types.Invalid:
|
||||
return &ast.BasicLit{Kind: token.STRING, Value: `"invalid"`}, false
|
||||
default:
|
||||
panic(fmt.Sprint("ZeroExpr for unexpected type:", t))
|
||||
panic(fmt.Sprintf("ZeroExpr for unexpected type %v", t))
|
||||
}
|
||||
|
||||
case *types.Pointer, *types.Slice, *types.Interface, *types.Chan, *types.Map, *types.Signature:
|
||||
return ast.NewIdent("nil")
|
||||
case *types.Pointer, *types.Slice, *types.Chan, *types.Map, *types.Signature:
|
||||
return ast.NewIdent("nil"), true
|
||||
|
||||
case *types.Named, *types.Alias:
|
||||
case *types.Interface:
|
||||
if !t.IsMethodSet() {
|
||||
return &ast.BasicLit{Kind: token.STRING, Value: `"invalid"`}, false
|
||||
}
|
||||
return ast.NewIdent("nil"), true
|
||||
|
||||
case *types.Named:
|
||||
switch under := t.Underlying().(type) {
|
||||
case *types.Struct, *types.Array:
|
||||
return &ast.CompositeLit{
|
||||
Type: TypeExpr(f, pkg, typ),
|
||||
}
|
||||
Type: TypeExpr(t, qual),
|
||||
}, true
|
||||
default:
|
||||
return ZeroExpr(f, pkg, under)
|
||||
return ZeroExpr(under, qual)
|
||||
}
|
||||
|
||||
case *types.Alias:
|
||||
switch t.Underlying().(type) {
|
||||
case *types.Struct, *types.Array:
|
||||
return &ast.CompositeLit{
|
||||
Type: TypeExpr(t, qual),
|
||||
}, true
|
||||
default:
|
||||
return ZeroExpr(types.Unalias(t), qual)
|
||||
}
|
||||
|
||||
case *types.Array, *types.Struct:
|
||||
return &ast.CompositeLit{
|
||||
Type: TypeExpr(f, pkg, typ),
|
||||
}
|
||||
Type: TypeExpr(t, qual),
|
||||
}, true
|
||||
|
||||
case *types.TypeParam:
|
||||
return &ast.StarExpr{ // *new(T)
|
||||
@@ -125,7 +187,7 @@ func ZeroExpr(f *ast.File, pkg *types.Package, typ types.Type) ast.Expr {
|
||||
ast.NewIdent(t.Obj().Name()),
|
||||
},
|
||||
},
|
||||
}
|
||||
}, true
|
||||
|
||||
case *types.Tuple:
|
||||
// Unlike ZeroString, there is no ast.Expr can express tuple by
|
||||
@@ -157,16 +219,14 @@ func IsZeroExpr(expr ast.Expr) bool {
|
||||
}
|
||||
|
||||
// TypeExpr returns syntax for the specified type. References to named types
|
||||
// from packages other than pkg are qualified by an appropriate package name, as
|
||||
// defined by the import environment of file.
|
||||
// are qualified by an appropriate (optional) qualifier function.
|
||||
// It may panic for types such as Tuple or Union.
|
||||
func TypeExpr(f *ast.File, pkg *types.Package, typ types.Type) ast.Expr {
|
||||
switch t := typ.(type) {
|
||||
func TypeExpr(t types.Type, qual types.Qualifier) ast.Expr {
|
||||
switch t := t.(type) {
|
||||
case *types.Basic:
|
||||
switch t.Kind() {
|
||||
case types.UnsafePointer:
|
||||
// TODO(hxjiang): replace the implementation with types.Qualifier.
|
||||
return &ast.SelectorExpr{X: ast.NewIdent("unsafe"), Sel: ast.NewIdent("Pointer")}
|
||||
return &ast.SelectorExpr{X: ast.NewIdent(qual(types.NewPackage("unsafe", "unsafe"))), Sel: ast.NewIdent("Pointer")}
|
||||
default:
|
||||
return ast.NewIdent(t.Name())
|
||||
}
|
||||
@@ -174,7 +234,7 @@ func TypeExpr(f *ast.File, pkg *types.Package, typ types.Type) ast.Expr {
|
||||
case *types.Pointer:
|
||||
return &ast.UnaryExpr{
|
||||
Op: token.MUL,
|
||||
X: TypeExpr(f, pkg, t.Elem()),
|
||||
X: TypeExpr(t.Elem(), qual),
|
||||
}
|
||||
|
||||
case *types.Array:
|
||||
@@ -183,18 +243,18 @@ func TypeExpr(f *ast.File, pkg *types.Package, typ types.Type) ast.Expr {
|
||||
Kind: token.INT,
|
||||
Value: fmt.Sprintf("%d", t.Len()),
|
||||
},
|
||||
Elt: TypeExpr(f, pkg, t.Elem()),
|
||||
Elt: TypeExpr(t.Elem(), qual),
|
||||
}
|
||||
|
||||
case *types.Slice:
|
||||
return &ast.ArrayType{
|
||||
Elt: TypeExpr(f, pkg, t.Elem()),
|
||||
Elt: TypeExpr(t.Elem(), qual),
|
||||
}
|
||||
|
||||
case *types.Map:
|
||||
return &ast.MapType{
|
||||
Key: TypeExpr(f, pkg, t.Key()),
|
||||
Value: TypeExpr(f, pkg, t.Elem()),
|
||||
Key: TypeExpr(t.Key(), qual),
|
||||
Value: TypeExpr(t.Elem(), qual),
|
||||
}
|
||||
|
||||
case *types.Chan:
|
||||
@@ -204,14 +264,14 @@ func TypeExpr(f *ast.File, pkg *types.Package, typ types.Type) ast.Expr {
|
||||
}
|
||||
return &ast.ChanType{
|
||||
Dir: dir,
|
||||
Value: TypeExpr(f, pkg, t.Elem()),
|
||||
Value: TypeExpr(t.Elem(), qual),
|
||||
}
|
||||
|
||||
case *types.Signature:
|
||||
var params []*ast.Field
|
||||
for i := 0; i < t.Params().Len(); i++ {
|
||||
params = append(params, &ast.Field{
|
||||
Type: TypeExpr(f, pkg, t.Params().At(i).Type()),
|
||||
Type: TypeExpr(t.Params().At(i).Type(), qual),
|
||||
Names: []*ast.Ident{
|
||||
{
|
||||
Name: t.Params().At(i).Name(),
|
||||
@@ -226,7 +286,7 @@ func TypeExpr(f *ast.File, pkg *types.Package, typ types.Type) ast.Expr {
|
||||
var returns []*ast.Field
|
||||
for i := 0; i < t.Results().Len(); i++ {
|
||||
returns = append(returns, &ast.Field{
|
||||
Type: TypeExpr(f, pkg, t.Results().At(i).Type()),
|
||||
Type: TypeExpr(t.Results().At(i).Type(), qual),
|
||||
})
|
||||
}
|
||||
return &ast.FuncType{
|
||||
@@ -238,23 +298,9 @@ func TypeExpr(f *ast.File, pkg *types.Package, typ types.Type) ast.Expr {
|
||||
},
|
||||
}
|
||||
|
||||
case interface{ Obj() *types.TypeName }: // *types.{Alias,Named,TypeParam}
|
||||
switch t.Obj().Pkg() {
|
||||
case pkg, nil:
|
||||
return ast.NewIdent(t.Obj().Name())
|
||||
}
|
||||
pkgName := t.Obj().Pkg().Name()
|
||||
|
||||
// TODO(hxjiang): replace the implementation with types.Qualifier.
|
||||
// If the file already imports the package under another name, use that.
|
||||
for _, cand := range f.Imports {
|
||||
if path, _ := strconv.Unquote(cand.Path.Value); path == t.Obj().Pkg().Path() {
|
||||
if cand.Name != nil && cand.Name.Name != "" {
|
||||
pkgName = cand.Name.Name
|
||||
}
|
||||
}
|
||||
}
|
||||
if pkgName == "." {
|
||||
case *types.TypeParam:
|
||||
pkgName := qual(t.Obj().Pkg())
|
||||
if pkgName == "" || t.Obj().Pkg() == nil {
|
||||
return ast.NewIdent(t.Obj().Name())
|
||||
}
|
||||
return &ast.SelectorExpr{
|
||||
@@ -262,6 +308,36 @@ func TypeExpr(f *ast.File, pkg *types.Package, typ types.Type) ast.Expr {
|
||||
Sel: ast.NewIdent(t.Obj().Name()),
|
||||
}
|
||||
|
||||
// types.TypeParam also implements interface NamedOrAlias. To differentiate,
|
||||
// case TypeParam need to be present before case NamedOrAlias.
|
||||
// TODO(hxjiang): remove this comment once TypeArgs() is added to interface
|
||||
// NamedOrAlias.
|
||||
case NamedOrAlias:
|
||||
var expr ast.Expr = ast.NewIdent(t.Obj().Name())
|
||||
if pkgName := qual(t.Obj().Pkg()); pkgName != "." && pkgName != "" {
|
||||
expr = &ast.SelectorExpr{
|
||||
X: ast.NewIdent(pkgName),
|
||||
Sel: expr.(*ast.Ident),
|
||||
}
|
||||
}
|
||||
|
||||
// TODO(hxjiang): call t.TypeArgs after adding method TypeArgs() to
|
||||
// typesinternal.NamedOrAlias.
|
||||
if hasTypeArgs, ok := t.(interface{ TypeArgs() *types.TypeList }); ok {
|
||||
if typeArgs := hasTypeArgs.TypeArgs(); typeArgs != nil && typeArgs.Len() > 0 {
|
||||
var indices []ast.Expr
|
||||
for i := range typeArgs.Len() {
|
||||
indices = append(indices, TypeExpr(typeArgs.At(i), qual))
|
||||
}
|
||||
expr = &ast.IndexListExpr{
|
||||
X: expr,
|
||||
Indices: indices,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return expr
|
||||
|
||||
case *types.Struct:
|
||||
return ast.NewIdent(t.String())
|
||||
|
||||
@@ -269,9 +345,43 @@ func TypeExpr(f *ast.File, pkg *types.Package, typ types.Type) ast.Expr {
|
||||
return ast.NewIdent(t.String())
|
||||
|
||||
case *types.Union:
|
||||
// TODO(hxjiang): handle the union through syntax (~A | ... | ~Z).
|
||||
// Remove nil check when calling typesinternal.TypeExpr.
|
||||
return nil
|
||||
if t.Len() == 0 {
|
||||
panic("Union type should have at least one term")
|
||||
}
|
||||
// Same as go/ast, the return expression will put last term in the
|
||||
// Y field at topmost level of BinaryExpr.
|
||||
// For union of type "float32 | float64 | int64", the structure looks
|
||||
// similar to:
|
||||
// {
|
||||
// X: {
|
||||
// X: float32,
|
||||
// Op: |
|
||||
// Y: float64,
|
||||
// }
|
||||
// Op: |,
|
||||
// Y: int64,
|
||||
// }
|
||||
var union ast.Expr
|
||||
for i := range t.Len() {
|
||||
term := t.Term(i)
|
||||
termExpr := TypeExpr(term.Type(), qual)
|
||||
if term.Tilde() {
|
||||
termExpr = &ast.UnaryExpr{
|
||||
Op: token.TILDE,
|
||||
X: termExpr,
|
||||
}
|
||||
}
|
||||
if i == 0 {
|
||||
union = termExpr
|
||||
} else {
|
||||
union = &ast.BinaryExpr{
|
||||
X: union,
|
||||
Op: token.OR,
|
||||
Y: termExpr,
|
||||
}
|
||||
}
|
||||
}
|
||||
return union
|
||||
|
||||
case *types.Tuple:
|
||||
panic("invalid input type types.Tuple")
|
||||
|
||||
9
vendor/modules.txt
vendored
9
vendor/modules.txt
vendored
@@ -1060,8 +1060,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.22.2
|
||||
## explicit; go 1.22.0
|
||||
# github.com/onsi/ginkgo/v2 v2.23.0
|
||||
## explicit; go 1.23.0
|
||||
github.com/onsi/ginkgo/v2
|
||||
github.com/onsi/ginkgo/v2/config
|
||||
github.com/onsi/ginkgo/v2/formatter
|
||||
@@ -2146,7 +2146,7 @@ golang.org/x/image/math/fixed
|
||||
golang.org/x/image/tiff
|
||||
golang.org/x/image/tiff/lzw
|
||||
golang.org/x/image/vector
|
||||
# golang.org/x/mod v0.22.0
|
||||
# golang.org/x/mod v0.23.0
|
||||
## explicit; go 1.22.0
|
||||
golang.org/x/mod/internal/lazyregexp
|
||||
golang.org/x/mod/module
|
||||
@@ -2226,7 +2226,7 @@ golang.org/x/text/width
|
||||
# golang.org/x/time v0.10.0
|
||||
## explicit; go 1.18
|
||||
golang.org/x/time/rate
|
||||
# golang.org/x/tools v0.28.0
|
||||
# golang.org/x/tools v0.30.0
|
||||
## explicit; go 1.22.0
|
||||
golang.org/x/tools/cover
|
||||
golang.org/x/tools/go/ast/astutil
|
||||
@@ -2237,6 +2237,7 @@ golang.org/x/tools/go/types/objectpath
|
||||
golang.org/x/tools/go/types/typeutil
|
||||
golang.org/x/tools/imports
|
||||
golang.org/x/tools/internal/aliases
|
||||
golang.org/x/tools/internal/astutil/edge
|
||||
golang.org/x/tools/internal/event
|
||||
golang.org/x/tools/internal/event/core
|
||||
golang.org/x/tools/internal/event/keys
|
||||
|
||||
Reference in New Issue
Block a user