aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>2025-01-22 13:34:11 +0000
committerTaras Madan <tarasmadan@google.com>2025-01-22 14:22:08 +0000
commita44b0418acb3ae8fdad9277c2f2aaa6446b97530 (patch)
tree0e90cf4564a64812d9d3ee56199b101c9539a8d0
parent25e17fd3886c9c7eda47ce82a8804493b0b792f8 (diff)
mod: bump golang.org/x/tools from 0.27.0 to 0.29.0
Bumps [golang.org/x/tools](https://github.com/golang/tools) from 0.27.0 to 0.29.0. - [Release notes](https://github.com/golang/tools/releases) - [Commits](https://github.com/golang/tools/compare/v0.27.0...v0.29.0) --- updated-dependencies: - dependency-name: golang.org/x/tools dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com>
-rw-r--r--go.mod14
-rw-r--r--go.sum28
-rw-r--r--vendor/golang.org/x/net/http2/config.go2
-rw-r--r--vendor/golang.org/x/net/http2/config_go124.go2
-rw-r--r--vendor/golang.org/x/net/http2/frame.go4
-rw-r--r--vendor/golang.org/x/net/http2/http2.go42
-rw-r--r--vendor/golang.org/x/net/http2/server.go35
-rw-r--r--vendor/golang.org/x/net/http2/transport.go150
-rw-r--r--vendor/golang.org/x/sys/unix/syscall_dragonfly.go12
-rw-r--r--vendor/golang.org/x/sys/unix/zerrors_linux.go9
-rw-r--r--vendor/golang.org/x/sys/unix/zerrors_linux_386.go6
-rw-r--r--vendor/golang.org/x/sys/unix/zerrors_linux_amd64.go6
-rw-r--r--vendor/golang.org/x/sys/unix/zerrors_linux_arm.go6
-rw-r--r--vendor/golang.org/x/sys/unix/zerrors_linux_arm64.go7
-rw-r--r--vendor/golang.org/x/sys/unix/zerrors_linux_loong64.go6
-rw-r--r--vendor/golang.org/x/sys/unix/zerrors_linux_mips.go6
-rw-r--r--vendor/golang.org/x/sys/unix/zerrors_linux_mips64.go6
-rw-r--r--vendor/golang.org/x/sys/unix/zerrors_linux_mips64le.go6
-rw-r--r--vendor/golang.org/x/sys/unix/zerrors_linux_mipsle.go6
-rw-r--r--vendor/golang.org/x/sys/unix/zerrors_linux_ppc.go6
-rw-r--r--vendor/golang.org/x/sys/unix/zerrors_linux_ppc64.go6
-rw-r--r--vendor/golang.org/x/sys/unix/zerrors_linux_ppc64le.go6
-rw-r--r--vendor/golang.org/x/sys/unix/zerrors_linux_riscv64.go6
-rw-r--r--vendor/golang.org/x/sys/unix/zerrors_linux_s390x.go6
-rw-r--r--vendor/golang.org/x/sys/unix/zerrors_linux_sparc64.go6
-rw-r--r--vendor/golang.org/x/sys/unix/ztypes_darwin_amd64.go60
-rw-r--r--vendor/golang.org/x/sys/unix/ztypes_darwin_arm64.go60
-rw-r--r--vendor/golang.org/x/sys/unix/ztypes_linux.go20
-rw-r--r--vendor/golang.org/x/sys/windows/dll_windows.go11
-rw-r--r--vendor/golang.org/x/sys/windows/syscall_windows.go2
-rw-r--r--vendor/golang.org/x/sys/windows/types_windows.go1
-rw-r--r--vendor/golang.org/x/sys/windows/zsyscall_windows.go28
-rw-r--r--vendor/golang.org/x/tools/go/analysis/analysis.go9
-rw-r--r--vendor/golang.org/x/tools/go/analysis/analysistest/analysistest.go168
-rw-r--r--vendor/golang.org/x/tools/go/analysis/checker/checker.go625
-rw-r--r--vendor/golang.org/x/tools/go/analysis/checker/iter_go122.go10
-rw-r--r--vendor/golang.org/x/tools/go/analysis/checker/iter_go123.go (renamed from vendor/golang.org/x/tools/internal/versions/constraint_go121.go)11
-rw-r--r--vendor/golang.org/x/tools/go/analysis/checker/print.go88
-rw-r--r--vendor/golang.org/x/tools/go/analysis/internal/analysisflags/flags.go37
-rw-r--r--vendor/golang.org/x/tools/go/analysis/internal/checker/checker.go984
-rw-r--r--vendor/golang.org/x/tools/go/analysis/internal/internal.go12
-rw-r--r--vendor/golang.org/x/tools/go/analysis/passes/buildtag/buildtag.go25
-rw-r--r--vendor/golang.org/x/tools/go/analysis/passes/printf/printf.go3
-rw-r--r--vendor/golang.org/x/tools/go/analysis/passes/structtag/structtag.go2
-rw-r--r--vendor/golang.org/x/tools/go/ast/inspector/inspector.go37
-rw-r--r--vendor/golang.org/x/tools/go/ast/inspector/iter.go4
-rw-r--r--vendor/golang.org/x/tools/go/ast/inspector/typeof.go3
-rw-r--r--vendor/golang.org/x/tools/go/gcexportdata/gcexportdata.go22
-rw-r--r--vendor/golang.org/x/tools/go/packages/external.go7
-rw-r--r--vendor/golang.org/x/tools/go/packages/golist.go10
-rw-r--r--vendor/golang.org/x/tools/go/packages/loadmode_string.go2
-rw-r--r--vendor/golang.org/x/tools/go/packages/packages.go57
-rw-r--r--vendor/golang.org/x/tools/go/ssa/const.go42
-rw-r--r--vendor/golang.org/x/tools/go/ssa/dom.go1
-rw-r--r--vendor/golang.org/x/tools/go/ssa/util.go13
-rw-r--r--vendor/golang.org/x/tools/go/types/typeutil/map.go246
-rw-r--r--vendor/golang.org/x/tools/internal/analysisinternal/analysis.go259
-rw-r--r--vendor/golang.org/x/tools/internal/diff/lcs/old.go1
-rw-r--r--vendor/golang.org/x/tools/internal/gcimporter/exportdata.go426
-rw-r--r--vendor/golang.org/x/tools/internal/gcimporter/gcimporter.go187
-rw-r--r--vendor/golang.org/x/tools/internal/gcimporter/iimport.go8
-rw-r--r--vendor/golang.org/x/tools/internal/gcimporter/support.go30
-rw-r--r--vendor/golang.org/x/tools/internal/gcimporter/ureader_yes.go9
-rw-r--r--vendor/golang.org/x/tools/internal/imports/source.go2
-rw-r--r--vendor/golang.org/x/tools/internal/imports/source_env.go8
-rw-r--r--vendor/golang.org/x/tools/internal/imports/source_modindex.go103
-rw-r--r--vendor/golang.org/x/tools/internal/modindex/directories.go135
-rw-r--r--vendor/golang.org/x/tools/internal/modindex/index.go266
-rw-r--r--vendor/golang.org/x/tools/internal/modindex/lookup.go148
-rw-r--r--vendor/golang.org/x/tools/internal/modindex/modindex.go164
-rw-r--r--vendor/golang.org/x/tools/internal/modindex/symbols.go217
-rw-r--r--vendor/golang.org/x/tools/internal/modindex/types.go25
-rw-r--r--vendor/golang.org/x/tools/internal/packagesinternal/packages.go2
-rw-r--r--vendor/golang.org/x/tools/internal/robustio/gopls_windows.go16
-rw-r--r--vendor/golang.org/x/tools/internal/robustio/robustio.go69
-rw-r--r--vendor/golang.org/x/tools/internal/robustio/robustio_darwin.go21
-rw-r--r--vendor/golang.org/x/tools/internal/robustio/robustio_flaky.go92
-rw-r--r--vendor/golang.org/x/tools/internal/robustio/robustio_other.go28
-rw-r--r--vendor/golang.org/x/tools/internal/robustio/robustio_plan9.go26
-rw-r--r--vendor/golang.org/x/tools/internal/robustio/robustio_posix.go26
-rw-r--r--vendor/golang.org/x/tools/internal/robustio/robustio_windows.go51
-rw-r--r--vendor/golang.org/x/tools/internal/stdlib/manifest.go219
-rw-r--r--vendor/golang.org/x/tools/internal/testenv/testenv.go2
-rw-r--r--vendor/golang.org/x/tools/internal/typeparams/common.go72
-rw-r--r--vendor/golang.org/x/tools/internal/typesinternal/qualifier.go46
-rw-r--r--vendor/golang.org/x/tools/internal/typesinternal/recv.go2
-rw-r--r--vendor/golang.org/x/tools/internal/typesinternal/types.go1
-rw-r--r--vendor/golang.org/x/tools/internal/typesinternal/zerovalue.go392
-rw-r--r--vendor/golang.org/x/tools/internal/versions/constraint.go13
-rw-r--r--vendor/modules.txt19
90 files changed, 3701 insertions, 2373 deletions
diff --git a/go.mod b/go.mod
index 7b1c67979..4ad78168f 100644
--- a/go.mod
+++ b/go.mod
@@ -32,9 +32,9 @@ require (
golang.org/x/exp v0.0.0-20240909161429-701f63a606c0
golang.org/x/oauth2 v0.24.0
golang.org/x/perf v0.0.0-20230221235046-aebcfb61e84c
- golang.org/x/sync v0.9.0
- golang.org/x/sys v0.27.0
- golang.org/x/tools v0.27.0
+ golang.org/x/sync v0.10.0
+ golang.org/x/sys v0.29.0
+ golang.org/x/tools v0.29.0
google.golang.org/api v0.198.0
google.golang.org/appengine/v2 v2.0.5
google.golang.org/genproto v0.0.0-20240903143218-8af14fe29dc1
@@ -269,12 +269,12 @@ require (
go.uber.org/automaxprocs v1.6.0 // indirect
go.uber.org/multierr v1.11.0 // indirect
go.uber.org/zap v1.24.0 // indirect
- golang.org/x/crypto v0.29.0 // indirect
+ golang.org/x/crypto v0.32.0 // indirect
golang.org/x/exp/typeparams v0.0.0-20241108190413-2d47ceb2692f // indirect
golang.org/x/mod v0.22.0 // indirect
- golang.org/x/net v0.31.0 // indirect
- golang.org/x/term v0.26.0 // indirect
- golang.org/x/text v0.20.0 // indirect
+ golang.org/x/net v0.34.0 // indirect
+ golang.org/x/term v0.28.0 // indirect
+ golang.org/x/text v0.21.0 // indirect
golang.org/x/time v0.7.0 // indirect
golang.org/x/xerrors v0.0.0-20240903120638-7835f813f4da // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20240903143218-8af14fe29dc1 // indirect
diff --git a/go.sum b/go.sum
index 4990b6dff..9a6364b76 100644
--- a/go.sum
+++ b/go.sum
@@ -1453,8 +1453,8 @@ golang.org/x/crypto v0.0.0-20210421170649-83a5a9bb288b/go.mod h1:T9bdIzuCu7OtxOm
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
golang.org/x/crypto v0.0.0-20211108221036-ceb1ce70b4fa/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
golang.org/x/crypto v0.1.0/go.mod h1:RecgLatLF4+eUMCP1PoPZQb+cVrJcOPbHkTkbkB9sbw=
-golang.org/x/crypto v0.29.0 h1:L5SG1JTTXupVV3n6sUqMTeWbjAyfPwoda2DLX8J8FrQ=
-golang.org/x/crypto v0.29.0/go.mod h1:+F4F4N5hv6v38hfeYwTdx20oUvLLc+QfrE9Ax9HtgRg=
+golang.org/x/crypto v0.32.0 h1:euUpcYgM8WcP71gNpTqQCn6rC2t6ULUPiOzfWaXVVfc=
+golang.org/x/crypto v0.32.0/go.mod h1:ZnnJkOaASj8g0AjIduWNlq2NRxL0PlBrbKVyZ6V/Ugc=
golang.org/x/exp v0.0.0-20180321215751-8460e604b9de/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
golang.org/x/exp v0.0.0-20180807140117-3d87b88a115f/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
@@ -1580,8 +1580,8 @@ golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs=
golang.org/x/net v0.7.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs=
golang.org/x/net v0.8.0/go.mod h1:QVkue5JL9kW//ek3r6jTKnTFis1tRmNAW2P1shuFdJc=
golang.org/x/net v0.9.0/go.mod h1:d48xBJpPfHeWQsugry2m+kC02ZBRGRgulfHnEXEuWns=
-golang.org/x/net v0.31.0 h1:68CPQngjLL0r2AlUKiSxtQFKvzRVbnzLwMUn5SzcLHo=
-golang.org/x/net v0.31.0/go.mod h1:P4fl1q7dY2hnZFxEk4pPSkDHF+QqjitcnDjUQyMM+pM=
+golang.org/x/net v0.34.0 h1:Mb7Mrk043xzHgnRM88suvJFwzVrRfHEHJEl5/71CKw0=
+golang.org/x/net v0.34.0/go.mod h1:di0qlW3YNM5oh6GqDGQr92MyTozJPmybPK4Ev/Gm31k=
golang.org/x/oauth2 v0.0.0-20170207211851-4464e7848382/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
@@ -1632,8 +1632,8 @@ golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJ
golang.org/x/sync v0.0.0-20220819030929-7fc1605a5dde/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20220929204114-8fcdb60fdcc0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
-golang.org/x/sync v0.9.0 h1:fEo0HyrW1GIgZdpbhCRO0PkJajUS5H9IFUztCgEo2jQ=
-golang.org/x/sync v0.9.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
+golang.org/x/sync v0.10.0 h1:3NQrjDixjgGwUOCaF8w2+VYHv0Ve/vGYSbdkTa98gmQ=
+golang.org/x/sync v0.10.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190312061237-fead79001313/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
@@ -1716,8 +1716,8 @@ golang.org/x/sys v0.4.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.7.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
-golang.org/x/sys v0.27.0 h1:wBqf8DvsY9Y/2P8gAfPDEYNuS30J4lPHJxXSb/nJZ+s=
-golang.org/x/sys v0.27.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
+golang.org/x/sys v0.29.0 h1:TPYlXGxvx1MGTn2GiZDhnjPA9wZzZeGKHHmKhHYvgaU=
+golang.org/x/sys v0.29.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
golang.org/x/term v0.1.0/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
@@ -1727,8 +1727,8 @@ golang.org/x/term v0.4.0/go.mod h1:9P2UbLfCdcvo3p/nzKvsmas4TnlujnuoV9hGgYzW1lQ=
golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k=
golang.org/x/term v0.6.0/go.mod h1:m6U89DPEgQRMq3DNkDClhWw02AUbt2daBVO4cn4Hv9U=
golang.org/x/term v0.7.0/go.mod h1:P32HKFT3hSsZrRxla30E9HqToFYAQPCMs/zFMBUFqPY=
-golang.org/x/term v0.26.0 h1:WEQa6V3Gja/BhNxg540hBip/kkaYtRg3cxg4oXSw4AU=
-golang.org/x/term v0.26.0/go.mod h1:Si5m1o57C5nBNQo5z1iq+XDijt21BDBDp2bK0QI8e3E=
+golang.org/x/term v0.28.0 h1:/Ts8HFuMR2E6IP/jlo7QVLZHggjKQbhu/7H0LJFr3Gg=
+golang.org/x/term v0.28.0/go.mod h1:Sw/lC2IAUZ92udQNf3WodGtn4k/XoLyZoh8v/8uiwek=
golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
@@ -1745,8 +1745,8 @@ golang.org/x/text v0.6.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
golang.org/x/text v0.8.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8=
golang.org/x/text v0.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8=
-golang.org/x/text v0.20.0 h1:gK/Kv2otX8gz+wn7Rmb3vT96ZwuoxnQlY+HlJVj7Qug=
-golang.org/x/text v0.20.0/go.mod h1:D4IsuqiFMhST5bX19pQ9ikHC2GsaKyk/oF+pn3ducp4=
+golang.org/x/text v0.21.0 h1:zyQAAkrwaneQ066sspRyJaG9VNi/YJ1NfzcGB3hZ/qo=
+golang.org/x/text v0.21.0/go.mod h1:4IBbMaMmOPCJ8SecivzSH54+73PCFmPWxNTLm+vZkEQ=
golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
@@ -1830,8 +1830,8 @@ golang.org/x/tools v0.3.0/go.mod h1:/rWhSS2+zyEVwoJf8YAX6L2f0ntZ7Kn/mGgAWcipA5k=
golang.org/x/tools v0.5.0/go.mod h1:N+Kgy78s5I24c24dU8OfWNEotWjutIs8SnJvn5IDq+k=
golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU=
golang.org/x/tools v0.7.0/go.mod h1:4pg6aUX35JBAogB10C9AtvVL+qowtN4pT3CGSQex14s=
-golang.org/x/tools v0.27.0 h1:qEKojBykQkQ4EynWy4S8Weg69NumxKdn40Fce3uc/8o=
-golang.org/x/tools v0.27.0/go.mod h1:sUi0ZgbwW9ZPAq26Ekut+weQPR5eIM6GQLQ1Yjm1H0Q=
+golang.org/x/tools v0.29.0 h1:Xx0h3TtM9rzQpQuR4dKLrdglAmCEN5Oi+P74JdhdzXE=
+golang.org/x/tools v0.29.0/go.mod h1:KMQVMRsVxU6nHCFXrBPhDB8XncLNLM0lIy/F14RP588=
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=
diff --git a/vendor/golang.org/x/net/http2/config.go b/vendor/golang.org/x/net/http2/config.go
index de58dfb8d..ca645d9a1 100644
--- a/vendor/golang.org/x/net/http2/config.go
+++ b/vendor/golang.org/x/net/http2/config.go
@@ -60,7 +60,7 @@ func configFromServer(h1 *http.Server, h2 *Server) http2Config {
return conf
}
-// configFromServer merges configuration settings from h2 and h2.t1.HTTP2
+// configFromTransport merges configuration settings from h2 and h2.t1.HTTP2
// (the net/http Transport).
func configFromTransport(h2 *Transport) http2Config {
conf := http2Config{
diff --git a/vendor/golang.org/x/net/http2/config_go124.go b/vendor/golang.org/x/net/http2/config_go124.go
index e3784123c..5b516c55f 100644
--- a/vendor/golang.org/x/net/http2/config_go124.go
+++ b/vendor/golang.org/x/net/http2/config_go124.go
@@ -13,7 +13,7 @@ func fillNetHTTPServerConfig(conf *http2Config, srv *http.Server) {
fillNetHTTPConfig(conf, srv.HTTP2)
}
-// fillNetHTTPServerConfig sets fields in conf from tr.HTTP2.
+// fillNetHTTPTransportConfig sets fields in conf from tr.HTTP2.
func fillNetHTTPTransportConfig(conf *http2Config, tr *http.Transport) {
fillNetHTTPConfig(conf, tr.HTTP2)
}
diff --git a/vendor/golang.org/x/net/http2/frame.go b/vendor/golang.org/x/net/http2/frame.go
index 105c3b279..81faec7e7 100644
--- a/vendor/golang.org/x/net/http2/frame.go
+++ b/vendor/golang.org/x/net/http2/frame.go
@@ -1490,7 +1490,7 @@ func (mh *MetaHeadersFrame) checkPseudos() error {
pf := mh.PseudoFields()
for i, hf := range pf {
switch hf.Name {
- case ":method", ":path", ":scheme", ":authority":
+ case ":method", ":path", ":scheme", ":authority", ":protocol":
isRequest = true
case ":status":
isResponse = true
@@ -1498,7 +1498,7 @@ func (mh *MetaHeadersFrame) checkPseudos() error {
return pseudoHeaderError(hf.Name)
}
// Check for duplicates.
- // This would be a bad algorithm, but N is 4.
+ // This would be a bad algorithm, but N is 5.
// And this doesn't allocate.
for _, hf2 := range pf[:i] {
if hf.Name == hf2.Name {
diff --git a/vendor/golang.org/x/net/http2/http2.go b/vendor/golang.org/x/net/http2/http2.go
index 7688c356b..c7601c909 100644
--- a/vendor/golang.org/x/net/http2/http2.go
+++ b/vendor/golang.org/x/net/http2/http2.go
@@ -34,10 +34,11 @@ import (
)
var (
- VerboseLogs bool
- logFrameWrites bool
- logFrameReads bool
- inTests bool
+ VerboseLogs bool
+ logFrameWrites bool
+ logFrameReads bool
+ inTests bool
+ disableExtendedConnectProtocol bool
)
func init() {
@@ -50,6 +51,9 @@ func init() {
logFrameWrites = true
logFrameReads = true
}
+ if strings.Contains(e, "http2xconnect=0") {
+ disableExtendedConnectProtocol = true
+ }
}
const (
@@ -141,6 +145,10 @@ func (s Setting) Valid() error {
if s.Val < 16384 || s.Val > 1<<24-1 {
return ConnectionError(ErrCodeProtocol)
}
+ case SettingEnableConnectProtocol:
+ if s.Val != 1 && s.Val != 0 {
+ return ConnectionError(ErrCodeProtocol)
+ }
}
return nil
}
@@ -150,21 +158,23 @@ func (s Setting) Valid() error {
type SettingID uint16
const (
- SettingHeaderTableSize SettingID = 0x1
- SettingEnablePush SettingID = 0x2
- SettingMaxConcurrentStreams SettingID = 0x3
- SettingInitialWindowSize SettingID = 0x4
- SettingMaxFrameSize SettingID = 0x5
- SettingMaxHeaderListSize SettingID = 0x6
+ SettingHeaderTableSize SettingID = 0x1
+ SettingEnablePush SettingID = 0x2
+ SettingMaxConcurrentStreams SettingID = 0x3
+ SettingInitialWindowSize SettingID = 0x4
+ SettingMaxFrameSize SettingID = 0x5
+ SettingMaxHeaderListSize SettingID = 0x6
+ SettingEnableConnectProtocol SettingID = 0x8
)
var settingName = map[SettingID]string{
- SettingHeaderTableSize: "HEADER_TABLE_SIZE",
- SettingEnablePush: "ENABLE_PUSH",
- SettingMaxConcurrentStreams: "MAX_CONCURRENT_STREAMS",
- SettingInitialWindowSize: "INITIAL_WINDOW_SIZE",
- SettingMaxFrameSize: "MAX_FRAME_SIZE",
- SettingMaxHeaderListSize: "MAX_HEADER_LIST_SIZE",
+ SettingHeaderTableSize: "HEADER_TABLE_SIZE",
+ SettingEnablePush: "ENABLE_PUSH",
+ SettingMaxConcurrentStreams: "MAX_CONCURRENT_STREAMS",
+ SettingInitialWindowSize: "INITIAL_WINDOW_SIZE",
+ SettingMaxFrameSize: "MAX_FRAME_SIZE",
+ SettingMaxHeaderListSize: "MAX_HEADER_LIST_SIZE",
+ SettingEnableConnectProtocol: "ENABLE_CONNECT_PROTOCOL",
}
func (s SettingID) String() string {
diff --git a/vendor/golang.org/x/net/http2/server.go b/vendor/golang.org/x/net/http2/server.go
index 832414b45..b55547aec 100644
--- a/vendor/golang.org/x/net/http2/server.go
+++ b/vendor/golang.org/x/net/http2/server.go
@@ -932,14 +932,18 @@ func (sc *serverConn) serve(conf http2Config) {
sc.vlogf("http2: server connection from %v on %p", sc.conn.RemoteAddr(), sc.hs)
}
+ settings := writeSettings{
+ {SettingMaxFrameSize, conf.MaxReadFrameSize},
+ {SettingMaxConcurrentStreams, sc.advMaxStreams},
+ {SettingMaxHeaderListSize, sc.maxHeaderListSize()},
+ {SettingHeaderTableSize, conf.MaxDecoderHeaderTableSize},
+ {SettingInitialWindowSize, uint32(sc.initialStreamRecvWindowSize)},
+ }
+ if !disableExtendedConnectProtocol {
+ settings = append(settings, Setting{SettingEnableConnectProtocol, 1})
+ }
sc.writeFrame(FrameWriteRequest{
- write: writeSettings{
- {SettingMaxFrameSize, conf.MaxReadFrameSize},
- {SettingMaxConcurrentStreams, sc.advMaxStreams},
- {SettingMaxHeaderListSize, sc.maxHeaderListSize()},
- {SettingHeaderTableSize, conf.MaxDecoderHeaderTableSize},
- {SettingInitialWindowSize, uint32(sc.initialStreamRecvWindowSize)},
- },
+ write: settings,
})
sc.unackedSettings++
@@ -1801,6 +1805,9 @@ func (sc *serverConn) processSetting(s Setting) error {
sc.maxFrameSize = int32(s.Val) // the maximum valid s.Val is < 2^31
case SettingMaxHeaderListSize:
sc.peerMaxHeaderListSize = s.Val
+ case SettingEnableConnectProtocol:
+ // Receipt of this parameter by a server does not
+ // have any impact
default:
// Unknown setting: "An endpoint that receives a SETTINGS
// frame with any unknown or unsupported identifier MUST
@@ -2231,11 +2238,17 @@ func (sc *serverConn) newWriterAndRequest(st *stream, f *MetaHeadersFrame) (*res
scheme: f.PseudoValue("scheme"),
authority: f.PseudoValue("authority"),
path: f.PseudoValue("path"),
+ protocol: f.PseudoValue("protocol"),
+ }
+
+ // extended connect is disabled, so we should not see :protocol
+ if disableExtendedConnectProtocol && rp.protocol != "" {
+ return nil, nil, sc.countError("bad_connect", streamError(f.StreamID, ErrCodeProtocol))
}
isConnect := rp.method == "CONNECT"
if isConnect {
- if rp.path != "" || rp.scheme != "" || rp.authority == "" {
+ if rp.protocol == "" && (rp.path != "" || rp.scheme != "" || rp.authority == "") {
return nil, nil, sc.countError("bad_connect", streamError(f.StreamID, ErrCodeProtocol))
}
} else if rp.method == "" || rp.path == "" || (rp.scheme != "https" && rp.scheme != "http") {
@@ -2259,6 +2272,9 @@ func (sc *serverConn) newWriterAndRequest(st *stream, f *MetaHeadersFrame) (*res
if rp.authority == "" {
rp.authority = rp.header.Get("Host")
}
+ if rp.protocol != "" {
+ rp.header.Set(":protocol", rp.protocol)
+ }
rw, req, err := sc.newWriterAndRequestNoBody(st, rp)
if err != nil {
@@ -2285,6 +2301,7 @@ func (sc *serverConn) newWriterAndRequest(st *stream, f *MetaHeadersFrame) (*res
type requestParam struct {
method string
scheme, authority, path string
+ protocol string
header http.Header
}
@@ -2326,7 +2343,7 @@ func (sc *serverConn) newWriterAndRequestNoBody(st *stream, rp requestParam) (*r
var url_ *url.URL
var requestURI string
- if rp.method == "CONNECT" {
+ if rp.method == "CONNECT" && rp.protocol == "" {
url_ = &url.URL{Host: rp.authority}
requestURI = rp.authority // mimic HTTP/1 server behavior
} else {
diff --git a/vendor/golang.org/x/net/http2/transport.go b/vendor/golang.org/x/net/http2/transport.go
index f5968f440..b2e2ed337 100644
--- a/vendor/golang.org/x/net/http2/transport.go
+++ b/vendor/golang.org/x/net/http2/transport.go
@@ -368,25 +368,27 @@ type ClientConn struct {
idleTimeout time.Duration // or 0 for never
idleTimer timer
- mu sync.Mutex // guards following
- cond *sync.Cond // hold mu; broadcast on flow/closed changes
- flow outflow // our conn-level flow control quota (cs.outflow is per stream)
- inflow inflow // peer's conn-level flow control
- doNotReuse bool // whether conn is marked to not be reused for any future requests
- closing bool
- closed bool
- seenSettings bool // true if we've seen a settings frame, false otherwise
- wantSettingsAck bool // we sent a SETTINGS frame and haven't heard back
- goAway *GoAwayFrame // if non-nil, the GoAwayFrame we received
- goAwayDebug string // goAway frame's debug data, retained as a string
- streams map[uint32]*clientStream // client-initiated
- streamsReserved int // incr by ReserveNewRequest; decr on RoundTrip
- nextStreamID uint32
- pendingRequests int // requests blocked and waiting to be sent because len(streams) == maxConcurrentStreams
- pings map[[8]byte]chan struct{} // in flight ping data to notification channel
- br *bufio.Reader
- lastActive time.Time
- lastIdle time.Time // time last idle
+ mu sync.Mutex // guards following
+ cond *sync.Cond // hold mu; broadcast on flow/closed changes
+ flow outflow // our conn-level flow control quota (cs.outflow is per stream)
+ inflow inflow // peer's conn-level flow control
+ doNotReuse bool // whether conn is marked to not be reused for any future requests
+ closing bool
+ closed bool
+ closedOnIdle bool // true if conn was closed for idleness
+ seenSettings bool // true if we've seen a settings frame, false otherwise
+ seenSettingsChan chan struct{} // closed when seenSettings is true or frame reading fails
+ wantSettingsAck bool // we sent a SETTINGS frame and haven't heard back
+ goAway *GoAwayFrame // if non-nil, the GoAwayFrame we received
+ goAwayDebug string // goAway frame's debug data, retained as a string
+ streams map[uint32]*clientStream // client-initiated
+ streamsReserved int // incr by ReserveNewRequest; decr on RoundTrip
+ nextStreamID uint32
+ pendingRequests int // requests blocked and waiting to be sent because len(streams) == maxConcurrentStreams
+ pings map[[8]byte]chan struct{} // in flight ping data to notification channel
+ br *bufio.Reader
+ lastActive time.Time
+ lastIdle time.Time // time last idle
// Settings from peer: (also guarded by wmu)
maxFrameSize uint32
maxConcurrentStreams uint32
@@ -396,6 +398,17 @@ type ClientConn struct {
initialStreamRecvWindowSize int32
readIdleTimeout time.Duration
pingTimeout time.Duration
+ extendedConnectAllowed bool
+
+ // rstStreamPingsBlocked works around an unfortunate gRPC behavior.
+ // gRPC strictly limits the number of PING frames that it will receive.
+ // The default is two pings per two hours, but the limit resets every time
+ // the gRPC endpoint sends a HEADERS or DATA frame. See golang/go#70575.
+ //
+ // rstStreamPingsBlocked is set after receiving a response to a PING frame
+ // bundled with an RST_STREAM (see pendingResets below), and cleared after
+ // receiving a HEADERS or DATA frame.
+ rstStreamPingsBlocked bool
// pendingResets is the number of RST_STREAM frames we have sent to the peer,
// without confirming that the peer has received them. When we send a RST_STREAM,
@@ -819,6 +832,7 @@ func (t *Transport) newClientConn(c net.Conn, singleUse bool) (*ClientConn, erro
peerMaxHeaderListSize: 0xffffffffffffffff, // "infinite", per spec. Use 2^64-1 instead.
streams: make(map[uint32]*clientStream),
singleUse: singleUse,
+ seenSettingsChan: make(chan struct{}),
wantSettingsAck: true,
readIdleTimeout: conf.SendPingTimeout,
pingTimeout: conf.PingTimeout,
@@ -1076,10 +1090,12 @@ func (cc *ClientConn) idleStateLocked() (st clientConnIdleState) {
// If this connection has never been used for a request and is closed,
// then let it take a request (which will fail).
+ // If the conn was closed for idleness, we're racing the idle timer;
+ // don't try to use the conn. (Issue #70515.)
//
// This avoids a situation where an error early in a connection's lifetime
// goes unreported.
- if cc.nextStreamID == 1 && cc.streamsReserved == 0 && cc.closed {
+ if cc.nextStreamID == 1 && cc.streamsReserved == 0 && cc.closed && !cc.closedOnIdle {
st.canTakeNewRequest = true
}
@@ -1142,6 +1158,7 @@ func (cc *ClientConn) closeIfIdle() {
return
}
cc.closed = true
+ cc.closedOnIdle = true
nextID := cc.nextStreamID
// TODO: do clients send GOAWAY too? maybe? Just Close:
cc.mu.Unlock()
@@ -1466,6 +1483,8 @@ func (cs *clientStream) doRequest(req *http.Request, streamf func(*clientStream)
cs.cleanupWriteRequest(err)
}
+var errExtendedConnectNotSupported = errors.New("net/http: extended connect not supported by peer")
+
// writeRequest sends a request.
//
// It returns nil after the request is written, the response read,
@@ -1481,12 +1500,31 @@ func (cs *clientStream) writeRequest(req *http.Request, streamf func(*clientStre
return err
}
+ // wait for setting frames to be received, a server can change this value later,
+ // but we just wait for the first settings frame
+ var isExtendedConnect bool
+ if req.Method == "CONNECT" && req.Header.Get(":protocol") != "" {
+ isExtendedConnect = true
+ }
+
// Acquire the new-request lock by writing to reqHeaderMu.
// This lock guards the critical section covering allocating a new stream ID
// (requires mu) and creating the stream (requires wmu).
if cc.reqHeaderMu == nil {
panic("RoundTrip on uninitialized ClientConn") // for tests
}
+ if isExtendedConnect {
+ select {
+ case <-cs.reqCancel:
+ return errRequestCanceled
+ case <-ctx.Done():
+ return ctx.Err()
+ case <-cc.seenSettingsChan:
+ if !cc.extendedConnectAllowed {
+ return errExtendedConnectNotSupported
+ }
+ }
+ }
select {
case cc.reqHeaderMu <- struct{}{}:
case <-cs.reqCancel:
@@ -1714,10 +1752,14 @@ func (cs *clientStream) cleanupWriteRequest(err error) {
ping := false
if !closeOnIdle {
cc.mu.Lock()
- if cc.pendingResets == 0 {
- ping = true
+ // rstStreamPingsBlocked works around a gRPC behavior:
+ // see comment on the field for details.
+ if !cc.rstStreamPingsBlocked {
+ if cc.pendingResets == 0 {
+ ping = true
+ }
+ cc.pendingResets++
}
- cc.pendingResets++
cc.mu.Unlock()
}
cc.writeStreamReset(cs.ID, ErrCodeCancel, ping, err)
@@ -2030,7 +2072,7 @@ func (cs *clientStream) awaitFlowControl(maxBytes int) (taken int32, err error)
func validateHeaders(hdrs http.Header) string {
for k, vv := range hdrs {
- if !httpguts.ValidHeaderFieldName(k) {
+ if !httpguts.ValidHeaderFieldName(k) && k != ":protocol" {
return fmt.Sprintf("name %q", k)
}
for _, v := range vv {
@@ -2046,6 +2088,10 @@ func validateHeaders(hdrs http.Header) string {
var errNilRequestURL = errors.New("http2: Request.URI is nil")
+func isNormalConnect(req *http.Request) bool {
+ return req.Method == "CONNECT" && req.Header.Get(":protocol") == ""
+}
+
// requires cc.wmu be held.
func (cc *ClientConn) encodeHeaders(req *http.Request, addGzipHeader bool, trailers string, contentLength int64) ([]byte, error) {
cc.hbuf.Reset()
@@ -2066,7 +2112,7 @@ func (cc *ClientConn) encodeHeaders(req *http.Request, addGzipHeader bool, trail
}
var path string
- if req.Method != "CONNECT" {
+ if !isNormalConnect(req) {
path = req.URL.RequestURI()
if !validPseudoPath(path) {
orig := path
@@ -2103,7 +2149,7 @@ func (cc *ClientConn) encodeHeaders(req *http.Request, addGzipHeader bool, trail
m = http.MethodGet
}
f(":method", m)
- if req.Method != "CONNECT" {
+ if !isNormalConnect(req) {
f(":path", path)
f(":scheme", req.URL.Scheme)
}
@@ -2392,9 +2438,12 @@ func (rl *clientConnReadLoop) cleanup() {
// This avoids a situation where new connections are constantly created,
// added to the pool, fail, and are removed from the pool, without any error
// being surfaced to the user.
- const unusedWaitTime = 5 * time.Second
+ unusedWaitTime := 5 * time.Second
+ if cc.idleTimeout > 0 && unusedWaitTime > cc.idleTimeout {
+ unusedWaitTime = cc.idleTimeout
+ }
idleTime := cc.t.now().Sub(cc.lastActive)
- if atomic.LoadUint32(&cc.atomicReused) == 0 && idleTime < unusedWaitTime {
+ if atomic.LoadUint32(&cc.atomicReused) == 0 && idleTime < unusedWaitTime && !cc.closedOnIdle {
cc.idleTimer = cc.t.afterFunc(unusedWaitTime-idleTime, func() {
cc.t.connPool().MarkDead(cc)
})
@@ -2461,7 +2510,7 @@ func (rl *clientConnReadLoop) run() error {
cc.vlogf("http2: Transport readFrame error on conn %p: (%T) %v", cc, err, err)
}
if se, ok := err.(StreamError); ok {
- if cs := rl.streamByID(se.StreamID); cs != nil {
+ if cs := rl.streamByID(se.StreamID, notHeaderOrDataFrame); cs != nil {
if se.Cause == nil {
se.Cause = cc.fr.errDetail
}
@@ -2507,13 +2556,16 @@ func (rl *clientConnReadLoop) run() error {
if VerboseLogs {
cc.vlogf("http2: Transport conn %p received error from processing frame %v: %v", cc, summarizeFrame(f), err)
}
+ if !cc.seenSettings {
+ close(cc.seenSettingsChan)
+ }
return err
}
}
}
func (rl *clientConnReadLoop) processHeaders(f *MetaHeadersFrame) error {
- cs := rl.streamByID(f.StreamID)
+ cs := rl.streamByID(f.StreamID, headerOrDataFrame)
if cs == nil {
// We'd get here if we canceled a request while the
// server had its response still in flight. So if this
@@ -2842,7 +2894,7 @@ func (b transportResponseBody) Close() error {
func (rl *clientConnReadLoop) processData(f *DataFrame) error {
cc := rl.cc
- cs := rl.streamByID(f.StreamID)
+ cs := rl.streamByID(f.StreamID, headerOrDataFrame)
data := f.Data()
if cs == nil {
cc.mu.Lock()
@@ -2977,9 +3029,22 @@ func (rl *clientConnReadLoop) endStreamError(cs *clientStream, err error) {
cs.abortStream(err)
}
-func (rl *clientConnReadLoop) streamByID(id uint32) *clientStream {
+// Constants passed to streamByID for documentation purposes.
+const (
+ headerOrDataFrame = true
+ notHeaderOrDataFrame = false
+)
+
+// streamByID returns the stream with the given id, or nil if no stream has that id.
+// If headerOrData is true, it clears rst.StreamPingsBlocked.
+func (rl *clientConnReadLoop) streamByID(id uint32, headerOrData bool) *clientStream {
rl.cc.mu.Lock()
defer rl.cc.mu.Unlock()
+ if headerOrData {
+ // Work around an unfortunate gRPC behavior.
+ // See comment on ClientConn.rstStreamPingsBlocked for details.
+ rl.cc.rstStreamPingsBlocked = false
+ }
cs := rl.cc.streams[id]
if cs != nil && !cs.readAborted {
return cs
@@ -3073,6 +3138,21 @@ func (rl *clientConnReadLoop) processSettingsNoWrite(f *SettingsFrame) error {
case SettingHeaderTableSize:
cc.henc.SetMaxDynamicTableSize(s.Val)
cc.peerMaxHeaderTableSize = s.Val
+ case SettingEnableConnectProtocol:
+ if err := s.Valid(); err != nil {
+ return err
+ }
+ // If the peer wants to send us SETTINGS_ENABLE_CONNECT_PROTOCOL,
+ // we require that it do so in the first SETTINGS frame.
+ //
+ // When we attempt to use extended CONNECT, we wait for the first
+ // SETTINGS frame to see if the server supports it. If we let the
+ // server enable the feature with a later SETTINGS frame, then
+ // users will see inconsistent results depending on whether we've
+ // seen that frame or not.
+ if !cc.seenSettings {
+ cc.extendedConnectAllowed = s.Val == 1
+ }
default:
cc.vlogf("Unhandled Setting: %v", s)
}
@@ -3090,6 +3170,7 @@ func (rl *clientConnReadLoop) processSettingsNoWrite(f *SettingsFrame) error {
// connection can establish to our default.
cc.maxConcurrentStreams = defaultMaxConcurrentStreams
}
+ close(cc.seenSettingsChan)
cc.seenSettings = true
}
@@ -3098,7 +3179,7 @@ func (rl *clientConnReadLoop) processSettingsNoWrite(f *SettingsFrame) error {
func (rl *clientConnReadLoop) processWindowUpdate(f *WindowUpdateFrame) error {
cc := rl.cc
- cs := rl.streamByID(f.StreamID)
+ cs := rl.streamByID(f.StreamID, notHeaderOrDataFrame)
if f.StreamID != 0 && cs == nil {
return nil
}
@@ -3127,7 +3208,7 @@ func (rl *clientConnReadLoop) processWindowUpdate(f *WindowUpdateFrame) error {
}
func (rl *clientConnReadLoop) processResetStream(f *RSTStreamFrame) error {
- cs := rl.streamByID(f.StreamID)
+ cs := rl.streamByID(f.StreamID, notHeaderOrDataFrame)
if cs == nil {
// TODO: return error if server tries to RST_STREAM an idle stream
return nil
@@ -3205,6 +3286,7 @@ func (rl *clientConnReadLoop) processPing(f *PingFrame) error {
if cc.pendingResets > 0 {
// See clientStream.cleanupWriteRequest.
cc.pendingResets = 0
+ cc.rstStreamPingsBlocked = true
cc.cond.Broadcast()
}
return nil
diff --git a/vendor/golang.org/x/sys/unix/syscall_dragonfly.go b/vendor/golang.org/x/sys/unix/syscall_dragonfly.go
index 97cb916f2..be8c00207 100644
--- a/vendor/golang.org/x/sys/unix/syscall_dragonfly.go
+++ b/vendor/golang.org/x/sys/unix/syscall_dragonfly.go
@@ -246,6 +246,18 @@ func Sendfile(outfd int, infd int, offset *int64, count int) (written int, err e
return sendfile(outfd, infd, offset, count)
}
+func Dup3(oldfd, newfd, flags int) error {
+ if oldfd == newfd || flags&^O_CLOEXEC != 0 {
+ return EINVAL
+ }
+ how := F_DUP2FD
+ if flags&O_CLOEXEC != 0 {
+ how = F_DUP2FD_CLOEXEC
+ }
+ _, err := fcntl(oldfd, how, newfd)
+ return err
+}
+
/*
* Exposed directly
*/
diff --git a/vendor/golang.org/x/sys/unix/zerrors_linux.go b/vendor/golang.org/x/sys/unix/zerrors_linux.go
index ccba391c9..6ebc48b3f 100644
--- a/vendor/golang.org/x/sys/unix/zerrors_linux.go
+++ b/vendor/golang.org/x/sys/unix/zerrors_linux.go
@@ -321,6 +321,9 @@ const (
AUDIT_INTEGRITY_STATUS = 0x70a
AUDIT_IPC = 0x517
AUDIT_IPC_SET_PERM = 0x51f
+ AUDIT_IPE_ACCESS = 0x58c
+ AUDIT_IPE_CONFIG_CHANGE = 0x58d
+ AUDIT_IPE_POLICY_LOAD = 0x58e
AUDIT_KERNEL = 0x7d0
AUDIT_KERNEL_OTHER = 0x524
AUDIT_KERN_MODULE = 0x532
@@ -489,6 +492,7 @@ const (
BPF_F_ID = 0x20
BPF_F_NETFILTER_IP_DEFRAG = 0x1
BPF_F_QUERY_EFFECTIVE = 0x1
+ BPF_F_REDIRECT_FLAGS = 0x19
BPF_F_REPLACE = 0x4
BPF_F_SLEEPABLE = 0x10
BPF_F_STRICT_ALIGNMENT = 0x1
@@ -1166,6 +1170,7 @@ const (
EXTA = 0xe
EXTB = 0xf
F2FS_SUPER_MAGIC = 0xf2f52010
+ FALLOC_FL_ALLOCATE_RANGE = 0x0
FALLOC_FL_COLLAPSE_RANGE = 0x8
FALLOC_FL_INSERT_RANGE = 0x20
FALLOC_FL_KEEP_SIZE = 0x1
@@ -1799,6 +1804,8 @@ const (
LANDLOCK_ACCESS_NET_BIND_TCP = 0x1
LANDLOCK_ACCESS_NET_CONNECT_TCP = 0x2
LANDLOCK_CREATE_RULESET_VERSION = 0x1
+ LANDLOCK_SCOPE_ABSTRACT_UNIX_SOCKET = 0x1
+ LANDLOCK_SCOPE_SIGNAL = 0x2
LINUX_REBOOT_CMD_CAD_OFF = 0x0
LINUX_REBOOT_CMD_CAD_ON = 0x89abcdef
LINUX_REBOOT_CMD_HALT = 0xcdef0123
@@ -1924,6 +1931,7 @@ const (
MNT_FORCE = 0x1
MNT_ID_REQ_SIZE_VER0 = 0x18
MNT_ID_REQ_SIZE_VER1 = 0x20
+ MNT_NS_INFO_SIZE_VER0 = 0x10
MODULE_INIT_COMPRESSED_FILE = 0x4
MODULE_INIT_IGNORE_MODVERSIONS = 0x1
MODULE_INIT_IGNORE_VERMAGIC = 0x2
@@ -2970,6 +2978,7 @@ const (
RWF_WRITE_LIFE_NOT_SET = 0x0
SCHED_BATCH = 0x3
SCHED_DEADLINE = 0x6
+ SCHED_EXT = 0x7
SCHED_FIFO = 0x1
SCHED_FLAG_ALL = 0x7f
SCHED_FLAG_DL_OVERRUN = 0x4
diff --git a/vendor/golang.org/x/sys/unix/zerrors_linux_386.go b/vendor/golang.org/x/sys/unix/zerrors_linux_386.go
index 0c00cb3f3..c0d45e320 100644
--- a/vendor/golang.org/x/sys/unix/zerrors_linux_386.go
+++ b/vendor/golang.org/x/sys/unix/zerrors_linux_386.go
@@ -109,6 +109,7 @@ const (
HIDIOCGRAWINFO = 0x80084803
HIDIOCGRDESC = 0x90044802
HIDIOCGRDESCSIZE = 0x80044801
+ HIDIOCREVOKE = 0x4004480d
HUPCL = 0x400
ICANON = 0x2
IEXTEN = 0x8000
@@ -297,6 +298,8 @@ const (
RTC_WIE_ON = 0x700f
RTC_WKALM_RD = 0x80287010
RTC_WKALM_SET = 0x4028700f
+ SCM_DEVMEM_DMABUF = 0x4f
+ SCM_DEVMEM_LINEAR = 0x4e
SCM_TIMESTAMPING = 0x25
SCM_TIMESTAMPING_OPT_STATS = 0x36
SCM_TIMESTAMPING_PKTINFO = 0x3a
@@ -335,6 +338,9 @@ const (
SO_CNX_ADVICE = 0x35
SO_COOKIE = 0x39
SO_DETACH_REUSEPORT_BPF = 0x44
+ SO_DEVMEM_DMABUF = 0x4f
+ SO_DEVMEM_DONTNEED = 0x50
+ SO_DEVMEM_LINEAR = 0x4e
SO_DOMAIN = 0x27
SO_DONTROUTE = 0x5
SO_ERROR = 0x4
diff --git a/vendor/golang.org/x/sys/unix/zerrors_linux_amd64.go b/vendor/golang.org/x/sys/unix/zerrors_linux_amd64.go
index dfb364554..c731d24f0 100644
--- a/vendor/golang.org/x/sys/unix/zerrors_linux_amd64.go
+++ b/vendor/golang.org/x/sys/unix/zerrors_linux_amd64.go
@@ -109,6 +109,7 @@ const (
HIDIOCGRAWINFO = 0x80084803
HIDIOCGRDESC = 0x90044802
HIDIOCGRDESCSIZE = 0x80044801
+ HIDIOCREVOKE = 0x4004480d
HUPCL = 0x400
ICANON = 0x2
IEXTEN = 0x8000
@@ -298,6 +299,8 @@ const (
RTC_WIE_ON = 0x700f
RTC_WKALM_RD = 0x80287010
RTC_WKALM_SET = 0x4028700f
+ SCM_DEVMEM_DMABUF = 0x4f
+ SCM_DEVMEM_LINEAR = 0x4e
SCM_TIMESTAMPING = 0x25
SCM_TIMESTAMPING_OPT_STATS = 0x36
SCM_TIMESTAMPING_PKTINFO = 0x3a
@@ -336,6 +339,9 @@ const (
SO_CNX_ADVICE = 0x35
SO_COOKIE = 0x39
SO_DETACH_REUSEPORT_BPF = 0x44
+ SO_DEVMEM_DMABUF = 0x4f
+ SO_DEVMEM_DONTNEED = 0x50
+ SO_DEVMEM_LINEAR = 0x4e
SO_DOMAIN = 0x27
SO_DONTROUTE = 0x5
SO_ERROR = 0x4
diff --git a/vendor/golang.org/x/sys/unix/zerrors_linux_arm.go b/vendor/golang.org/x/sys/unix/zerrors_linux_arm.go
index d46dcf78a..680018a4a 100644
--- a/vendor/golang.org/x/sys/unix/zerrors_linux_arm.go
+++ b/vendor/golang.org/x/sys/unix/zerrors_linux_arm.go
@@ -108,6 +108,7 @@ const (
HIDIOCGRAWINFO = 0x80084803
HIDIOCGRDESC = 0x90044802
HIDIOCGRDESCSIZE = 0x80044801
+ HIDIOCREVOKE = 0x4004480d
HUPCL = 0x400
ICANON = 0x2
IEXTEN = 0x8000
@@ -303,6 +304,8 @@ const (
RTC_WIE_ON = 0x700f
RTC_WKALM_RD = 0x80287010
RTC_WKALM_SET = 0x4028700f
+ SCM_DEVMEM_DMABUF = 0x4f
+ SCM_DEVMEM_LINEAR = 0x4e
SCM_TIMESTAMPING = 0x25
SCM_TIMESTAMPING_OPT_STATS = 0x36
SCM_TIMESTAMPING_PKTINFO = 0x3a
@@ -341,6 +344,9 @@ const (
SO_CNX_ADVICE = 0x35
SO_COOKIE = 0x39
SO_DETACH_REUSEPORT_BPF = 0x44
+ SO_DEVMEM_DMABUF = 0x4f
+ SO_DEVMEM_DONTNEED = 0x50
+ SO_DEVMEM_LINEAR = 0x4e
SO_DOMAIN = 0x27
SO_DONTROUTE = 0x5
SO_ERROR = 0x4
diff --git a/vendor/golang.org/x/sys/unix/zerrors_linux_arm64.go b/vendor/golang.org/x/sys/unix/zerrors_linux_arm64.go
index 3af3248a7..a63909f30 100644
--- a/vendor/golang.org/x/sys/unix/zerrors_linux_arm64.go
+++ b/vendor/golang.org/x/sys/unix/zerrors_linux_arm64.go
@@ -112,6 +112,7 @@ const (
HIDIOCGRAWINFO = 0x80084803
HIDIOCGRDESC = 0x90044802
HIDIOCGRDESCSIZE = 0x80044801
+ HIDIOCREVOKE = 0x4004480d
HUPCL = 0x400
ICANON = 0x2
IEXTEN = 0x8000
@@ -205,6 +206,7 @@ const (
PERF_EVENT_IOC_SET_BPF = 0x40042408
PERF_EVENT_IOC_SET_FILTER = 0x40082406
PERF_EVENT_IOC_SET_OUTPUT = 0x2405
+ POE_MAGIC = 0x504f4530
PPPIOCATTACH = 0x4004743d
PPPIOCATTCHAN = 0x40047438
PPPIOCBRIDGECHAN = 0x40047435
@@ -294,6 +296,8 @@ const (
RTC_WIE_ON = 0x700f
RTC_WKALM_RD = 0x80287010
RTC_WKALM_SET = 0x4028700f
+ SCM_DEVMEM_DMABUF = 0x4f
+ SCM_DEVMEM_LINEAR = 0x4e
SCM_TIMESTAMPING = 0x25
SCM_TIMESTAMPING_OPT_STATS = 0x36
SCM_TIMESTAMPING_PKTINFO = 0x3a
@@ -332,6 +336,9 @@ const (
SO_CNX_ADVICE = 0x35
SO_COOKIE = 0x39
SO_DETACH_REUSEPORT_BPF = 0x44
+ SO_DEVMEM_DMABUF = 0x4f
+ SO_DEVMEM_DONTNEED = 0x50
+ SO_DEVMEM_LINEAR = 0x4e
SO_DOMAIN = 0x27
SO_DONTROUTE = 0x5
SO_ERROR = 0x4
diff --git a/vendor/golang.org/x/sys/unix/zerrors_linux_loong64.go b/vendor/golang.org/x/sys/unix/zerrors_linux_loong64.go
index 292bcf028..9b0a2573f 100644
--- a/vendor/golang.org/x/sys/unix/zerrors_linux_loong64.go
+++ b/vendor/golang.org/x/sys/unix/zerrors_linux_loong64.go
@@ -109,6 +109,7 @@ const (
HIDIOCGRAWINFO = 0x80084803
HIDIOCGRDESC = 0x90044802
HIDIOCGRDESCSIZE = 0x80044801
+ HIDIOCREVOKE = 0x4004480d
HUPCL = 0x400
ICANON = 0x2
IEXTEN = 0x8000
@@ -290,6 +291,8 @@ const (
RTC_WIE_ON = 0x700f
RTC_WKALM_RD = 0x80287010
RTC_WKALM_SET = 0x4028700f
+ SCM_DEVMEM_DMABUF = 0x4f
+ SCM_DEVMEM_LINEAR = 0x4e
SCM_TIMESTAMPING = 0x25
SCM_TIMESTAMPING_OPT_STATS = 0x36
SCM_TIMESTAMPING_PKTINFO = 0x3a
@@ -328,6 +331,9 @@ const (
SO_CNX_ADVICE = 0x35
SO_COOKIE = 0x39
SO_DETACH_REUSEPORT_BPF = 0x44
+ SO_DEVMEM_DMABUF = 0x4f
+ SO_DEVMEM_DONTNEED = 0x50
+ SO_DEVMEM_LINEAR = 0x4e
SO_DOMAIN = 0x27
SO_DONTROUTE = 0x5
SO_ERROR = 0x4
diff --git a/vendor/golang.org/x/sys/unix/zerrors_linux_mips.go b/vendor/golang.org/x/sys/unix/zerrors_linux_mips.go
index 782b7110f..958e6e064 100644
--- a/vendor/golang.org/x/sys/unix/zerrors_linux_mips.go
+++ b/vendor/golang.org/x/sys/unix/zerrors_linux_mips.go
@@ -108,6 +108,7 @@ const (
HIDIOCGRAWINFO = 0x40084803
HIDIOCGRDESC = 0x50044802
HIDIOCGRDESCSIZE = 0x40044801
+ HIDIOCREVOKE = 0x8004480d
HUPCL = 0x400
ICANON = 0x2
IEXTEN = 0x100
@@ -296,6 +297,8 @@ const (
RTC_WIE_ON = 0x2000700f
RTC_WKALM_RD = 0x40287010
RTC_WKALM_SET = 0x8028700f
+ SCM_DEVMEM_DMABUF = 0x4f
+ SCM_DEVMEM_LINEAR = 0x4e
SCM_TIMESTAMPING = 0x25
SCM_TIMESTAMPING_OPT_STATS = 0x36
SCM_TIMESTAMPING_PKTINFO = 0x3a
@@ -334,6 +337,9 @@ const (
SO_CNX_ADVICE = 0x35
SO_COOKIE = 0x39
SO_DETACH_REUSEPORT_BPF = 0x44
+ SO_DEVMEM_DMABUF = 0x4f
+ SO_DEVMEM_DONTNEED = 0x50
+ SO_DEVMEM_LINEAR = 0x4e
SO_DOMAIN = 0x1029
SO_DONTROUTE = 0x10
SO_ERROR = 0x1007
diff --git a/vendor/golang.org/x/sys/unix/zerrors_linux_mips64.go b/vendor/golang.org/x/sys/unix/zerrors_linux_mips64.go
index 84973fd92..50c7f25bd 100644
--- a/vendor/golang.org/x/sys/unix/zerrors_linux_mips64.go
+++ b/vendor/golang.org/x/sys/unix/zerrors_linux_mips64.go
@@ -108,6 +108,7 @@ const (
HIDIOCGRAWINFO = 0x40084803
HIDIOCGRDESC = 0x50044802
HIDIOCGRDESCSIZE = 0x40044801
+ HIDIOCREVOKE = 0x8004480d
HUPCL = 0x400
ICANON = 0x2
IEXTEN = 0x100
@@ -296,6 +297,8 @@ const (
RTC_WIE_ON = 0x2000700f
RTC_WKALM_RD = 0x40287010
RTC_WKALM_SET = 0x8028700f
+ SCM_DEVMEM_DMABUF = 0x4f
+ SCM_DEVMEM_LINEAR = 0x4e
SCM_TIMESTAMPING = 0x25
SCM_TIMESTAMPING_OPT_STATS = 0x36
SCM_TIMESTAMPING_PKTINFO = 0x3a
@@ -334,6 +337,9 @@ const (
SO_CNX_ADVICE = 0x35
SO_COOKIE = 0x39
SO_DETACH_REUSEPORT_BPF = 0x44
+ SO_DEVMEM_DMABUF = 0x4f
+ SO_DEVMEM_DONTNEED = 0x50
+ SO_DEVMEM_LINEAR = 0x4e
SO_DOMAIN = 0x1029
SO_DONTROUTE = 0x10
SO_ERROR = 0x1007
diff --git a/vendor/golang.org/x/sys/unix/zerrors_linux_mips64le.go b/vendor/golang.org/x/sys/unix/zerrors_linux_mips64le.go
index 6d9cbc3b2..ced21d66d 100644
--- a/vendor/golang.org/x/sys/unix/zerrors_linux_mips64le.go
+++ b/vendor/golang.org/x/sys/unix/zerrors_linux_mips64le.go
@@ -108,6 +108,7 @@ const (
HIDIOCGRAWINFO = 0x40084803
HIDIOCGRDESC = 0x50044802
HIDIOCGRDESCSIZE = 0x40044801
+ HIDIOCREVOKE = 0x8004480d
HUPCL = 0x400
ICANON = 0x2
IEXTEN = 0x100
@@ -296,6 +297,8 @@ const (
RTC_WIE_ON = 0x2000700f
RTC_WKALM_RD = 0x40287010
RTC_WKALM_SET = 0x8028700f
+ SCM_DEVMEM_DMABUF = 0x4f
+ SCM_DEVMEM_LINEAR = 0x4e
SCM_TIMESTAMPING = 0x25
SCM_TIMESTAMPING_OPT_STATS = 0x36
SCM_TIMESTAMPING_PKTINFO = 0x3a
@@ -334,6 +337,9 @@ const (
SO_CNX_ADVICE = 0x35
SO_COOKIE = 0x39
SO_DETACH_REUSEPORT_BPF = 0x44
+ SO_DEVMEM_DMABUF = 0x4f
+ SO_DEVMEM_DONTNEED = 0x50
+ SO_DEVMEM_LINEAR = 0x4e
SO_DOMAIN = 0x1029
SO_DONTROUTE = 0x10
SO_ERROR = 0x1007
diff --git a/vendor/golang.org/x/sys/unix/zerrors_linux_mipsle.go b/vendor/golang.org/x/sys/unix/zerrors_linux_mipsle.go
index 5f9fedbce..226c04419 100644
--- a/vendor/golang.org/x/sys/unix/zerrors_linux_mipsle.go
+++ b/vendor/golang.org/x/sys/unix/zerrors_linux_mipsle.go
@@ -108,6 +108,7 @@ const (
HIDIOCGRAWINFO = 0x40084803
HIDIOCGRDESC = 0x50044802
HIDIOCGRDESCSIZE = 0x40044801
+ HIDIOCREVOKE = 0x8004480d
HUPCL = 0x400
ICANON = 0x2
IEXTEN = 0x100
@@ -296,6 +297,8 @@ const (
RTC_WIE_ON = 0x2000700f
RTC_WKALM_RD = 0x40287010
RTC_WKALM_SET = 0x8028700f
+ SCM_DEVMEM_DMABUF = 0x4f
+ SCM_DEVMEM_LINEAR = 0x4e
SCM_TIMESTAMPING = 0x25
SCM_TIMESTAMPING_OPT_STATS = 0x36
SCM_TIMESTAMPING_PKTINFO = 0x3a
@@ -334,6 +337,9 @@ const (
SO_CNX_ADVICE = 0x35
SO_COOKIE = 0x39
SO_DETACH_REUSEPORT_BPF = 0x44
+ SO_DEVMEM_DMABUF = 0x4f
+ SO_DEVMEM_DONTNEED = 0x50
+ SO_DEVMEM_LINEAR = 0x4e
SO_DOMAIN = 0x1029
SO_DONTROUTE = 0x10
SO_ERROR = 0x1007
diff --git a/vendor/golang.org/x/sys/unix/zerrors_linux_ppc.go b/vendor/golang.org/x/sys/unix/zerrors_linux_ppc.go
index bb0026ee0..3122737cd 100644
--- a/vendor/golang.org/x/sys/unix/zerrors_linux_ppc.go
+++ b/vendor/golang.org/x/sys/unix/zerrors_linux_ppc.go
@@ -108,6 +108,7 @@ const (
HIDIOCGRAWINFO = 0x40084803
HIDIOCGRDESC = 0x50044802
HIDIOCGRDESCSIZE = 0x40044801
+ HIDIOCREVOKE = 0x8004480d
HUPCL = 0x4000
ICANON = 0x100
IEXTEN = 0x400
@@ -351,6 +352,8 @@ const (
RTC_WIE_ON = 0x2000700f
RTC_WKALM_RD = 0x40287010
RTC_WKALM_SET = 0x8028700f
+ SCM_DEVMEM_DMABUF = 0x4f
+ SCM_DEVMEM_LINEAR = 0x4e
SCM_TIMESTAMPING = 0x25
SCM_TIMESTAMPING_OPT_STATS = 0x36
SCM_TIMESTAMPING_PKTINFO = 0x3a
@@ -389,6 +392,9 @@ const (
SO_CNX_ADVICE = 0x35
SO_COOKIE = 0x39
SO_DETACH_REUSEPORT_BPF = 0x44
+ SO_DEVMEM_DMABUF = 0x4f
+ SO_DEVMEM_DONTNEED = 0x50
+ SO_DEVMEM_LINEAR = 0x4e
SO_DOMAIN = 0x27
SO_DONTROUTE = 0x5
SO_ERROR = 0x4
diff --git a/vendor/golang.org/x/sys/unix/zerrors_linux_ppc64.go b/vendor/golang.org/x/sys/unix/zerrors_linux_ppc64.go
index 46120db5c..eb5d3467e 100644
--- a/vendor/golang.org/x/sys/unix/zerrors_linux_ppc64.go
+++ b/vendor/golang.org/x/sys/unix/zerrors_linux_ppc64.go
@@ -108,6 +108,7 @@ const (
HIDIOCGRAWINFO = 0x40084803
HIDIOCGRDESC = 0x50044802
HIDIOCGRDESCSIZE = 0x40044801
+ HIDIOCREVOKE = 0x8004480d
HUPCL = 0x4000
ICANON = 0x100
IEXTEN = 0x400
@@ -355,6 +356,8 @@ const (
RTC_WIE_ON = 0x2000700f
RTC_WKALM_RD = 0x40287010
RTC_WKALM_SET = 0x8028700f
+ SCM_DEVMEM_DMABUF = 0x4f
+ SCM_DEVMEM_LINEAR = 0x4e
SCM_TIMESTAMPING = 0x25
SCM_TIMESTAMPING_OPT_STATS = 0x36
SCM_TIMESTAMPING_PKTINFO = 0x3a
@@ -393,6 +396,9 @@ const (
SO_CNX_ADVICE = 0x35
SO_COOKIE = 0x39
SO_DETACH_REUSEPORT_BPF = 0x44
+ SO_DEVMEM_DMABUF = 0x4f
+ SO_DEVMEM_DONTNEED = 0x50
+ SO_DEVMEM_LINEAR = 0x4e
SO_DOMAIN = 0x27
SO_DONTROUTE = 0x5
SO_ERROR = 0x4
diff --git a/vendor/golang.org/x/sys/unix/zerrors_linux_ppc64le.go b/vendor/golang.org/x/sys/unix/zerrors_linux_ppc64le.go
index 5c951634f..e921ebc60 100644
--- a/vendor/golang.org/x/sys/unix/zerrors_linux_ppc64le.go
+++ b/vendor/golang.org/x/sys/unix/zerrors_linux_ppc64le.go
@@ -108,6 +108,7 @@ const (
HIDIOCGRAWINFO = 0x40084803
HIDIOCGRDESC = 0x50044802
HIDIOCGRDESCSIZE = 0x40044801
+ HIDIOCREVOKE = 0x8004480d
HUPCL = 0x4000
ICANON = 0x100
IEXTEN = 0x400
@@ -355,6 +356,8 @@ const (
RTC_WIE_ON = 0x2000700f
RTC_WKALM_RD = 0x40287010
RTC_WKALM_SET = 0x8028700f
+ SCM_DEVMEM_DMABUF = 0x4f
+ SCM_DEVMEM_LINEAR = 0x4e
SCM_TIMESTAMPING = 0x25
SCM_TIMESTAMPING_OPT_STATS = 0x36
SCM_TIMESTAMPING_PKTINFO = 0x3a
@@ -393,6 +396,9 @@ const (
SO_CNX_ADVICE = 0x35
SO_COOKIE = 0x39
SO_DETACH_REUSEPORT_BPF = 0x44
+ SO_DEVMEM_DMABUF = 0x4f
+ SO_DEVMEM_DONTNEED = 0x50
+ SO_DEVMEM_LINEAR = 0x4e
SO_DOMAIN = 0x27
SO_DONTROUTE = 0x5
SO_ERROR = 0x4
diff --git a/vendor/golang.org/x/sys/unix/zerrors_linux_riscv64.go b/vendor/golang.org/x/sys/unix/zerrors_linux_riscv64.go
index 11a84d5af..38ba81c55 100644
--- a/vendor/golang.org/x/sys/unix/zerrors_linux_riscv64.go
+++ b/vendor/golang.org/x/sys/unix/zerrors_linux_riscv64.go
@@ -108,6 +108,7 @@ const (
HIDIOCGRAWINFO = 0x80084803
HIDIOCGRDESC = 0x90044802
HIDIOCGRDESCSIZE = 0x80044801
+ HIDIOCREVOKE = 0x4004480d
HUPCL = 0x400
ICANON = 0x2
IEXTEN = 0x8000
@@ -287,6 +288,8 @@ const (
RTC_WIE_ON = 0x700f
RTC_WKALM_RD = 0x80287010
RTC_WKALM_SET = 0x4028700f
+ SCM_DEVMEM_DMABUF = 0x4f
+ SCM_DEVMEM_LINEAR = 0x4e
SCM_TIMESTAMPING = 0x25
SCM_TIMESTAMPING_OPT_STATS = 0x36
SCM_TIMESTAMPING_PKTINFO = 0x3a
@@ -325,6 +328,9 @@ const (
SO_CNX_ADVICE = 0x35
SO_COOKIE = 0x39
SO_DETACH_REUSEPORT_BPF = 0x44
+ SO_DEVMEM_DMABUF = 0x4f
+ SO_DEVMEM_DONTNEED = 0x50
+ SO_DEVMEM_LINEAR = 0x4e
SO_DOMAIN = 0x27
SO_DONTROUTE = 0x5
SO_ERROR = 0x4
diff --git a/vendor/golang.org/x/sys/unix/zerrors_linux_s390x.go b/vendor/golang.org/x/sys/unix/zerrors_linux_s390x.go
index f78c4617c..71f040097 100644
--- a/vendor/golang.org/x/sys/unix/zerrors_linux_s390x.go
+++ b/vendor/golang.org/x/sys/unix/zerrors_linux_s390x.go
@@ -108,6 +108,7 @@ const (
HIDIOCGRAWINFO = 0x80084803
HIDIOCGRDESC = 0x90044802
HIDIOCGRDESCSIZE = 0x80044801
+ HIDIOCREVOKE = 0x4004480d
HUPCL = 0x400
ICANON = 0x2
IEXTEN = 0x8000
@@ -359,6 +360,8 @@ const (
RTC_WIE_ON = 0x700f
RTC_WKALM_RD = 0x80287010
RTC_WKALM_SET = 0x4028700f
+ SCM_DEVMEM_DMABUF = 0x4f
+ SCM_DEVMEM_LINEAR = 0x4e
SCM_TIMESTAMPING = 0x25
SCM_TIMESTAMPING_OPT_STATS = 0x36
SCM_TIMESTAMPING_PKTINFO = 0x3a
@@ -397,6 +400,9 @@ const (
SO_CNX_ADVICE = 0x35
SO_COOKIE = 0x39
SO_DETACH_REUSEPORT_BPF = 0x44
+ SO_DEVMEM_DMABUF = 0x4f
+ SO_DEVMEM_DONTNEED = 0x50
+ SO_DEVMEM_LINEAR = 0x4e
SO_DOMAIN = 0x27
SO_DONTROUTE = 0x5
SO_ERROR = 0x4
diff --git a/vendor/golang.org/x/sys/unix/zerrors_linux_sparc64.go b/vendor/golang.org/x/sys/unix/zerrors_linux_sparc64.go
index aeb777c34..c44a31332 100644
--- a/vendor/golang.org/x/sys/unix/zerrors_linux_sparc64.go
+++ b/vendor/golang.org/x/sys/unix/zerrors_linux_sparc64.go
@@ -112,6 +112,7 @@ const (
HIDIOCGRAWINFO = 0x40084803
HIDIOCGRDESC = 0x50044802
HIDIOCGRDESCSIZE = 0x40044801
+ HIDIOCREVOKE = 0x8004480d
HUPCL = 0x400
ICANON = 0x2
IEXTEN = 0x8000
@@ -350,6 +351,8 @@ const (
RTC_WIE_ON = 0x2000700f
RTC_WKALM_RD = 0x40287010
RTC_WKALM_SET = 0x8028700f
+ SCM_DEVMEM_DMABUF = 0x58
+ SCM_DEVMEM_LINEAR = 0x57
SCM_TIMESTAMPING = 0x23
SCM_TIMESTAMPING_OPT_STATS = 0x38
SCM_TIMESTAMPING_PKTINFO = 0x3c
@@ -436,6 +439,9 @@ const (
SO_CNX_ADVICE = 0x37
SO_COOKIE = 0x3b
SO_DETACH_REUSEPORT_BPF = 0x47
+ SO_DEVMEM_DMABUF = 0x58
+ SO_DEVMEM_DONTNEED = 0x59
+ SO_DEVMEM_LINEAR = 0x57
SO_DOMAIN = 0x1029
SO_DONTROUTE = 0x10
SO_ERROR = 0x1007
diff --git a/vendor/golang.org/x/sys/unix/ztypes_darwin_amd64.go b/vendor/golang.org/x/sys/unix/ztypes_darwin_amd64.go
index d003c3d43..17c53bd9b 100644
--- a/vendor/golang.org/x/sys/unix/ztypes_darwin_amd64.go
+++ b/vendor/golang.org/x/sys/unix/ztypes_darwin_amd64.go
@@ -462,11 +462,14 @@ type FdSet struct {
const (
SizeofIfMsghdr = 0x70
+ SizeofIfMsghdr2 = 0xa0
SizeofIfData = 0x60
+ SizeofIfData64 = 0x80
SizeofIfaMsghdr = 0x14
SizeofIfmaMsghdr = 0x10
SizeofIfmaMsghdr2 = 0x14
SizeofRtMsghdr = 0x5c
+ SizeofRtMsghdr2 = 0x5c
SizeofRtMetrics = 0x38
)
@@ -480,6 +483,20 @@ type IfMsghdr struct {
Data IfData
}
+type IfMsghdr2 struct {
+ Msglen uint16
+ Version uint8
+ Type uint8
+ Addrs int32
+ Flags int32
+ Index uint16
+ Snd_len int32
+ Snd_maxlen int32
+ Snd_drops int32
+ Timer int32
+ Data IfData64
+}
+
type IfData struct {
Type uint8
Typelen uint8
@@ -512,6 +529,34 @@ type IfData struct {
Reserved2 uint32
}
+type IfData64 struct {
+ Type uint8
+ Typelen uint8
+ Physical uint8
+ Addrlen uint8
+ Hdrlen uint8
+ Recvquota uint8
+ Xmitquota uint8
+ Unused1 uint8
+ Mtu uint32
+ Metric uint32
+ Baudrate uint64
+ Ipackets uint64
+ Ierrors uint64
+ Opackets uint64
+ Oerrors uint64
+ Collisions uint64
+ Ibytes uint64
+ Obytes uint64
+ Imcasts uint64
+ Omcasts uint64
+ Iqdrops uint64
+ Noproto uint64
+ Recvtiming uint32
+ Xmittiming uint32
+ Lastchange Timeval32
+}
+
type IfaMsghdr struct {
Msglen uint16
Version uint8
@@ -557,6 +602,21 @@ type RtMsghdr struct {
Rmx RtMetrics
}
+type RtMsghdr2 struct {
+ Msglen uint16
+ Version uint8
+ Type uint8
+ Index uint16
+ Flags int32
+ Addrs int32
+ Refcnt int32
+ Parentflags int32
+ Reserved int32
+ Use int32
+ Inits uint32
+ Rmx RtMetrics
+}
+
type RtMetrics struct {
Locks uint32
Mtu uint32
diff --git a/vendor/golang.org/x/sys/unix/ztypes_darwin_arm64.go b/vendor/golang.org/x/sys/unix/ztypes_darwin_arm64.go
index 0d45a941a..2392226a7 100644
--- a/vendor/golang.org/x/sys/unix/ztypes_darwin_arm64.go
+++ b/vendor/golang.org/x/sys/unix/ztypes_darwin_arm64.go
@@ -462,11 +462,14 @@ type FdSet struct {
const (
SizeofIfMsghdr = 0x70
+ SizeofIfMsghdr2 = 0xa0
SizeofIfData = 0x60
+ SizeofIfData64 = 0x80
SizeofIfaMsghdr = 0x14
SizeofIfmaMsghdr = 0x10
SizeofIfmaMsghdr2 = 0x14
SizeofRtMsghdr = 0x5c
+ SizeofRtMsghdr2 = 0x5c
SizeofRtMetrics = 0x38
)
@@ -480,6 +483,20 @@ type IfMsghdr struct {
Data IfData
}
+type IfMsghdr2 struct {
+ Msglen uint16
+ Version uint8
+ Type uint8
+ Addrs int32
+ Flags int32
+ Index uint16
+ Snd_len int32
+ Snd_maxlen int32
+ Snd_drops int32
+ Timer int32
+ Data IfData64
+}
+
type IfData struct {
Type uint8
Typelen uint8
@@ -512,6 +529,34 @@ type IfData struct {
Reserved2 uint32
}
+type IfData64 struct {
+ Type uint8
+ Typelen uint8
+ Physical uint8
+ Addrlen uint8
+ Hdrlen uint8
+ Recvquota uint8
+ Xmitquota uint8
+ Unused1 uint8
+ Mtu uint32
+ Metric uint32
+ Baudrate uint64
+ Ipackets uint64
+ Ierrors uint64
+ Opackets uint64
+ Oerrors uint64
+ Collisions uint64
+ Ibytes uint64
+ Obytes uint64
+ Imcasts uint64
+ Omcasts uint64
+ Iqdrops uint64
+ Noproto uint64
+ Recvtiming uint32
+ Xmittiming uint32
+ Lastchange Timeval32
+}
+
type IfaMsghdr struct {
Msglen uint16
Version uint8
@@ -557,6 +602,21 @@ type RtMsghdr struct {
Rmx RtMetrics
}
+type RtMsghdr2 struct {
+ Msglen uint16
+ Version uint8
+ Type uint8
+ Index uint16
+ Flags int32
+ Addrs int32
+ Refcnt int32
+ Parentflags int32
+ Reserved int32
+ Use int32
+ Inits uint32
+ Rmx RtMetrics
+}
+
type RtMetrics struct {
Locks uint32
Mtu uint32
diff --git a/vendor/golang.org/x/sys/unix/ztypes_linux.go b/vendor/golang.org/x/sys/unix/ztypes_linux.go
index 8daaf3faf..5537148dc 100644
--- a/vendor/golang.org/x/sys/unix/ztypes_linux.go
+++ b/vendor/golang.org/x/sys/unix/ztypes_linux.go
@@ -2594,8 +2594,8 @@ const (
SOF_TIMESTAMPING_BIND_PHC = 0x8000
SOF_TIMESTAMPING_OPT_ID_TCP = 0x10000
- SOF_TIMESTAMPING_LAST = 0x10000
- SOF_TIMESTAMPING_MASK = 0x1ffff
+ SOF_TIMESTAMPING_LAST = 0x20000
+ SOF_TIMESTAMPING_MASK = 0x3ffff
SCM_TSTAMP_SND = 0x0
SCM_TSTAMP_SCHED = 0x1
@@ -3541,7 +3541,7 @@ type Nhmsg struct {
type NexthopGrp struct {
Id uint32
Weight uint8
- Resvd1 uint8
+ High uint8
Resvd2 uint16
}
@@ -3802,7 +3802,7 @@ const (
ETHTOOL_MSG_PSE_GET = 0x24
ETHTOOL_MSG_PSE_SET = 0x25
ETHTOOL_MSG_RSS_GET = 0x26
- ETHTOOL_MSG_USER_MAX = 0x2c
+ ETHTOOL_MSG_USER_MAX = 0x2d
ETHTOOL_MSG_KERNEL_NONE = 0x0
ETHTOOL_MSG_STRSET_GET_REPLY = 0x1
ETHTOOL_MSG_LINKINFO_GET_REPLY = 0x2
@@ -3842,7 +3842,7 @@ const (
ETHTOOL_MSG_MODULE_NTF = 0x24
ETHTOOL_MSG_PSE_GET_REPLY = 0x25
ETHTOOL_MSG_RSS_GET_REPLY = 0x26
- ETHTOOL_MSG_KERNEL_MAX = 0x2c
+ ETHTOOL_MSG_KERNEL_MAX = 0x2e
ETHTOOL_FLAG_COMPACT_BITSETS = 0x1
ETHTOOL_FLAG_OMIT_REPLY = 0x2
ETHTOOL_FLAG_STATS = 0x4
@@ -3850,7 +3850,7 @@ const (
ETHTOOL_A_HEADER_DEV_INDEX = 0x1
ETHTOOL_A_HEADER_DEV_NAME = 0x2
ETHTOOL_A_HEADER_FLAGS = 0x3
- ETHTOOL_A_HEADER_MAX = 0x3
+ ETHTOOL_A_HEADER_MAX = 0x4
ETHTOOL_A_BITSET_BIT_UNSPEC = 0x0
ETHTOOL_A_BITSET_BIT_INDEX = 0x1
ETHTOOL_A_BITSET_BIT_NAME = 0x2
@@ -4031,11 +4031,11 @@ const (
ETHTOOL_A_CABLE_RESULT_UNSPEC = 0x0
ETHTOOL_A_CABLE_RESULT_PAIR = 0x1
ETHTOOL_A_CABLE_RESULT_CODE = 0x2
- ETHTOOL_A_CABLE_RESULT_MAX = 0x2
+ ETHTOOL_A_CABLE_RESULT_MAX = 0x3
ETHTOOL_A_CABLE_FAULT_LENGTH_UNSPEC = 0x0
ETHTOOL_A_CABLE_FAULT_LENGTH_PAIR = 0x1
ETHTOOL_A_CABLE_FAULT_LENGTH_CM = 0x2
- ETHTOOL_A_CABLE_FAULT_LENGTH_MAX = 0x2
+ ETHTOOL_A_CABLE_FAULT_LENGTH_MAX = 0x3
ETHTOOL_A_CABLE_TEST_NTF_STATUS_UNSPEC = 0x0
ETHTOOL_A_CABLE_TEST_NTF_STATUS_STARTED = 0x1
ETHTOOL_A_CABLE_TEST_NTF_STATUS_COMPLETED = 0x2
@@ -4200,7 +4200,8 @@ type (
}
PtpSysOffsetExtended struct {
Samples uint32
- Rsv [3]uint32
+ Clockid int32
+ Rsv [2]uint32
Ts [25][3]PtpClockTime
}
PtpSysOffsetPrecise struct {
@@ -4399,6 +4400,7 @@ const (
type LandlockRulesetAttr struct {
Access_fs uint64
Access_net uint64
+ Scoped uint64
}
type LandlockPathBeneathAttr struct {
diff --git a/vendor/golang.org/x/sys/windows/dll_windows.go b/vendor/golang.org/x/sys/windows/dll_windows.go
index 4e613cf63..3ca814f54 100644
--- a/vendor/golang.org/x/sys/windows/dll_windows.go
+++ b/vendor/golang.org/x/sys/windows/dll_windows.go
@@ -43,8 +43,8 @@ type DLL struct {
// LoadDLL loads DLL file into memory.
//
// Warning: using LoadDLL without an absolute path name is subject to
-// DLL preloading attacks. To safely load a system DLL, use LazyDLL
-// with System set to true, or use LoadLibraryEx directly.
+// DLL preloading attacks. To safely load a system DLL, use [NewLazySystemDLL],
+// or use [LoadLibraryEx] directly.
func LoadDLL(name string) (dll *DLL, err error) {
namep, err := UTF16PtrFromString(name)
if err != nil {
@@ -271,6 +271,9 @@ func (d *LazyDLL) NewProc(name string) *LazyProc {
}
// NewLazyDLL creates new LazyDLL associated with DLL file.
+//
+// Warning: using NewLazyDLL without an absolute path name is subject to
+// DLL preloading attacks. To safely load a system DLL, use [NewLazySystemDLL].
func NewLazyDLL(name string) *LazyDLL {
return &LazyDLL{Name: name}
}
@@ -410,7 +413,3 @@ func loadLibraryEx(name string, system bool) (*DLL, error) {
}
return &DLL{Name: name, Handle: h}, nil
}
-
-type errString string
-
-func (s errString) Error() string { return string(s) }
diff --git a/vendor/golang.org/x/sys/windows/syscall_windows.go b/vendor/golang.org/x/sys/windows/syscall_windows.go
index 4510bfc3f..4a3254386 100644
--- a/vendor/golang.org/x/sys/windows/syscall_windows.go
+++ b/vendor/golang.org/x/sys/windows/syscall_windows.go
@@ -168,6 +168,8 @@ func NewCallbackCDecl(fn interface{}) uintptr {
//sys CreateNamedPipe(name *uint16, flags uint32, pipeMode uint32, maxInstances uint32, outSize uint32, inSize uint32, defaultTimeout uint32, sa *SecurityAttributes) (handle Handle, err error) [failretval==InvalidHandle] = CreateNamedPipeW
//sys ConnectNamedPipe(pipe Handle, overlapped *Overlapped) (err error)
//sys DisconnectNamedPipe(pipe Handle) (err error)
+//sys GetNamedPipeClientProcessId(pipe Handle, clientProcessID *uint32) (err error)
+//sys GetNamedPipeServerProcessId(pipe Handle, serverProcessID *uint32) (err error)
//sys GetNamedPipeInfo(pipe Handle, flags *uint32, outSize *uint32, inSize *uint32, maxInstances *uint32) (err error)
//sys GetNamedPipeHandleState(pipe Handle, state *uint32, curInstances *uint32, maxCollectionCount *uint32, collectDataTimeout *uint32, userName *uint16, maxUserNameSize uint32) (err error) = GetNamedPipeHandleStateW
//sys SetNamedPipeHandleState(pipe Handle, state *uint32, maxCollectionCount *uint32, collectDataTimeout *uint32) (err error) = SetNamedPipeHandleState
diff --git a/vendor/golang.org/x/sys/windows/types_windows.go b/vendor/golang.org/x/sys/windows/types_windows.go
index 51311e205..9d138de5f 100644
--- a/vendor/golang.org/x/sys/windows/types_windows.go
+++ b/vendor/golang.org/x/sys/windows/types_windows.go
@@ -176,6 +176,7 @@ const (
WAIT_FAILED = 0xFFFFFFFF
// Access rights for process.
+ PROCESS_ALL_ACCESS = 0xFFFF
PROCESS_CREATE_PROCESS = 0x0080
PROCESS_CREATE_THREAD = 0x0002
PROCESS_DUP_HANDLE = 0x0040
diff --git a/vendor/golang.org/x/sys/windows/zsyscall_windows.go b/vendor/golang.org/x/sys/windows/zsyscall_windows.go
index 6f5252880..01c0716c2 100644
--- a/vendor/golang.org/x/sys/windows/zsyscall_windows.go
+++ b/vendor/golang.org/x/sys/windows/zsyscall_windows.go
@@ -280,8 +280,10 @@ var (
procGetMaximumProcessorCount = modkernel32.NewProc("GetMaximumProcessorCount")
procGetModuleFileNameW = modkernel32.NewProc("GetModuleFileNameW")
procGetModuleHandleExW = modkernel32.NewProc("GetModuleHandleExW")
+ procGetNamedPipeClientProcessId = modkernel32.NewProc("GetNamedPipeClientProcessId")
procGetNamedPipeHandleStateW = modkernel32.NewProc("GetNamedPipeHandleStateW")
procGetNamedPipeInfo = modkernel32.NewProc("GetNamedPipeInfo")
+ procGetNamedPipeServerProcessId = modkernel32.NewProc("GetNamedPipeServerProcessId")
procGetOverlappedResult = modkernel32.NewProc("GetOverlappedResult")
procGetPriorityClass = modkernel32.NewProc("GetPriorityClass")
procGetProcAddress = modkernel32.NewProc("GetProcAddress")
@@ -1612,7 +1614,7 @@ func DwmSetWindowAttribute(hwnd HWND, attribute uint32, value unsafe.Pointer, si
}
func CancelMibChangeNotify2(notificationHandle Handle) (errcode error) {
- r0, _, _ := syscall.SyscallN(procCancelMibChangeNotify2.Addr(), uintptr(notificationHandle))
+ r0, _, _ := syscall.Syscall(procCancelMibChangeNotify2.Addr(), 1, uintptr(notificationHandle), 0, 0)
if r0 != 0 {
errcode = syscall.Errno(r0)
}
@@ -1652,7 +1654,7 @@ func GetIfEntry(pIfRow *MibIfRow) (errcode error) {
}
func GetIfEntry2Ex(level uint32, row *MibIfRow2) (errcode error) {
- r0, _, _ := syscall.SyscallN(procGetIfEntry2Ex.Addr(), uintptr(level), uintptr(unsafe.Pointer(row)))
+ r0, _, _ := syscall.Syscall(procGetIfEntry2Ex.Addr(), 2, uintptr(level), uintptr(unsafe.Pointer(row)), 0)
if r0 != 0 {
errcode = syscall.Errno(r0)
}
@@ -1660,7 +1662,7 @@ func GetIfEntry2Ex(level uint32, row *MibIfRow2) (errcode error) {
}
func GetUnicastIpAddressEntry(row *MibUnicastIpAddressRow) (errcode error) {
- r0, _, _ := syscall.SyscallN(procGetUnicastIpAddressEntry.Addr(), uintptr(unsafe.Pointer(row)))
+ r0, _, _ := syscall.Syscall(procGetUnicastIpAddressEntry.Addr(), 1, uintptr(unsafe.Pointer(row)), 0, 0)
if r0 != 0 {
errcode = syscall.Errno(r0)
}
@@ -1672,7 +1674,7 @@ func NotifyIpInterfaceChange(family uint16, callback uintptr, callerContext unsa
if initialNotification {
_p0 = 1
}
- r0, _, _ := syscall.SyscallN(procNotifyIpInterfaceChange.Addr(), uintptr(family), uintptr(callback), uintptr(callerContext), uintptr(_p0), uintptr(unsafe.Pointer(notificationHandle)))
+ r0, _, _ := syscall.Syscall6(procNotifyIpInterfaceChange.Addr(), 5, uintptr(family), uintptr(callback), uintptr(callerContext), uintptr(_p0), uintptr(unsafe.Pointer(notificationHandle)), 0)
if r0 != 0 {
errcode = syscall.Errno(r0)
}
@@ -1684,7 +1686,7 @@ func NotifyUnicastIpAddressChange(family uint16, callback uintptr, callerContext
if initialNotification {
_p0 = 1
}
- r0, _, _ := syscall.SyscallN(procNotifyUnicastIpAddressChange.Addr(), uintptr(family), uintptr(callback), uintptr(callerContext), uintptr(_p0), uintptr(unsafe.Pointer(notificationHandle)))
+ r0, _, _ := syscall.Syscall6(procNotifyUnicastIpAddressChange.Addr(), 5, uintptr(family), uintptr(callback), uintptr(callerContext), uintptr(_p0), uintptr(unsafe.Pointer(notificationHandle)), 0)
if r0 != 0 {
errcode = syscall.Errno(r0)
}
@@ -2446,6 +2448,14 @@ func GetModuleHandleEx(flags uint32, moduleName *uint16, module *Handle) (err er
return
}
+func GetNamedPipeClientProcessId(pipe Handle, clientProcessID *uint32) (err error) {
+ r1, _, e1 := syscall.Syscall(procGetNamedPipeClientProcessId.Addr(), 2, uintptr(pipe), uintptr(unsafe.Pointer(clientProcessID)), 0)
+ if r1 == 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
func GetNamedPipeHandleState(pipe Handle, state *uint32, curInstances *uint32, maxCollectionCount *uint32, collectDataTimeout *uint32, userName *uint16, maxUserNameSize uint32) (err error) {
r1, _, e1 := syscall.Syscall9(procGetNamedPipeHandleStateW.Addr(), 7, uintptr(pipe), uintptr(unsafe.Pointer(state)), uintptr(unsafe.Pointer(curInstances)), uintptr(unsafe.Pointer(maxCollectionCount)), uintptr(unsafe.Pointer(collectDataTimeout)), uintptr(unsafe.Pointer(userName)), uintptr(maxUserNameSize), 0, 0)
if r1 == 0 {
@@ -2462,6 +2472,14 @@ func GetNamedPipeInfo(pipe Handle, flags *uint32, outSize *uint32, inSize *uint3
return
}
+func GetNamedPipeServerProcessId(pipe Handle, serverProcessID *uint32) (err error) {
+ r1, _, e1 := syscall.Syscall(procGetNamedPipeServerProcessId.Addr(), 2, uintptr(pipe), uintptr(unsafe.Pointer(serverProcessID)), 0)
+ if r1 == 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
func GetOverlappedResult(handle Handle, overlapped *Overlapped, done *uint32, wait bool) (err error) {
var _p0 uint32
if wait {
diff --git a/vendor/golang.org/x/tools/go/analysis/analysis.go b/vendor/golang.org/x/tools/go/analysis/analysis.go
index aa02eeda6..3a73084a5 100644
--- a/vendor/golang.org/x/tools/go/analysis/analysis.go
+++ b/vendor/golang.org/x/tools/go/analysis/analysis.go
@@ -50,7 +50,7 @@ type Analyzer struct {
// RunDespiteErrors allows the driver to invoke
// the Run method of this analyzer even on a
// package that contains parse or type errors.
- // The Pass.TypeErrors field may consequently be non-empty.
+ // The [Pass.TypeErrors] field may consequently be non-empty.
RunDespiteErrors bool
// Requires is a set of analyzers that must run successfully
@@ -156,10 +156,17 @@ type Pass struct {
// AllPackageFacts returns a new slice containing all package
// facts of the analysis's FactTypes in unspecified order.
+ // See comments for AllObjectFacts.
AllPackageFacts func() []PackageFact
// AllObjectFacts returns a new slice containing all object
// facts of the analysis's FactTypes in unspecified order.
+ //
+ // The result includes all facts exported by packages
+ // whose symbols are referenced by the current package
+ // (by qualified identifiers or field/method selections).
+ // And it includes all facts exported from the current
+ // package by the current analysis pass.
AllObjectFacts func() []ObjectFact
/* Further fields may be added in future. */
diff --git a/vendor/golang.org/x/tools/go/analysis/analysistest/analysistest.go b/vendor/golang.org/x/tools/go/analysis/analysistest/analysistest.go
index c1b2dd4fa..3cc2beca7 100644
--- a/vendor/golang.org/x/tools/go/analysis/analysistest/analysistest.go
+++ b/vendor/golang.org/x/tools/go/analysis/analysistest/analysistest.go
@@ -23,7 +23,8 @@ import (
"text/scanner"
"golang.org/x/tools/go/analysis"
- "golang.org/x/tools/go/analysis/internal/checker"
+ "golang.org/x/tools/go/analysis/checker"
+ "golang.org/x/tools/go/analysis/internal"
"golang.org/x/tools/go/packages"
"golang.org/x/tools/internal/diff"
"golang.org/x/tools/internal/testenv"
@@ -137,7 +138,7 @@ type Testing interface {
// analyzers that offer alternative fixes are advised to put each fix
// in a separate .go file in the testdata.
func RunWithSuggestedFixes(t Testing, dir string, a *analysis.Analyzer, patterns ...string) []*Result {
- r := Run(t, dir, a, patterns...)
+ results := Run(t, dir, a, patterns...)
// If the immediate caller of RunWithSuggestedFixes is in
// x/tools, we apply stricter checks as required by gopls.
@@ -162,7 +163,9 @@ func RunWithSuggestedFixes(t Testing, dir string, a *analysis.Analyzer, patterns
// Validating the results separately means as long as the two analyses
// don't produce conflicting suggestions for a single file, everything
// should match up.
- for _, act := range r {
+ for _, result := range results {
+ act := result.Action
+
// file -> message -> edits
fileEdits := make(map[*token.File]map[string][]diff.Edit)
fileContents := make(map[*token.File][]byte)
@@ -185,14 +188,14 @@ func RunWithSuggestedFixes(t Testing, dir string, a *analysis.Analyzer, patterns
if start > end {
t.Errorf(
"diagnostic for analysis %v contains Suggested Fix with malformed edit: pos (%v) > end (%v)",
- act.Pass.Analyzer.Name, start, end)
+ act.Analyzer.Name, start, end)
continue
}
- file, endfile := act.Pass.Fset.File(start), act.Pass.Fset.File(end)
+ file, endfile := act.Package.Fset.File(start), act.Package.Fset.File(end)
if file == nil || endfile == nil || file != endfile {
t.Errorf(
"diagnostic for analysis %v contains Suggested Fix with malformed spanning files %v and %v",
- act.Pass.Analyzer.Name, file.Name(), endfile.Name())
+ act.Analyzer.Name, file.Name(), endfile.Name())
continue
}
if _, ok := fileContents[file]; !ok {
@@ -275,7 +278,7 @@ func RunWithSuggestedFixes(t Testing, dir string, a *analysis.Analyzer, patterns
}
}
}
- return r
+ return results
}
// applyDiffsAndCompare applies edits to src and compares the results against
@@ -349,36 +352,88 @@ func Run(t Testing, dir string, a *analysis.Analyzer, patterns ...string) []*Res
testenv.NeedsGoPackages(t)
}
- pkgs, err := loadPackages(a, dir, patterns...)
+ pkgs, err := loadPackages(dir, patterns...)
if err != nil {
t.Errorf("loading %s: %v", patterns, err)
return nil
}
- if err := analysis.Validate([]*analysis.Analyzer{a}); err != nil {
- t.Errorf("Validate: %v", err)
+ // Print parse and type errors to the test log.
+ // (Do not print them to stderr, which would pollute
+ // the log in cases where the tests pass.)
+ if t, ok := t.(testing.TB); ok && !a.RunDespiteErrors {
+ packages.Visit(pkgs, nil, func(pkg *packages.Package) {
+ for _, err := range pkg.Errors {
+ t.Log(err)
+ }
+ })
+ }
+
+ res, err := checker.Analyze([]*analysis.Analyzer{a}, pkgs, nil)
+ if err != nil {
+ t.Errorf("Analyze: %v", err)
return nil
}
- results := checker.TestAnalyzer(a, pkgs)
- for _, result := range results {
- if result.Err != nil {
- t.Errorf("error analyzing %s: %v", result.Pass, result.Err)
+ var results []*Result
+ for _, act := range res.Roots {
+ if act.Err != nil {
+ t.Errorf("error analyzing %s: %v", act, act.Err)
} else {
- check(t, dir, result.Pass, result.Diagnostics, result.Facts)
+ check(t, dir, act)
}
+
+ // Compute legacy map of facts relating to this package.
+ facts := make(map[types.Object][]analysis.Fact)
+ for _, objFact := range act.AllObjectFacts() {
+ if obj := objFact.Object; obj.Pkg() == act.Package.Types {
+ facts[obj] = append(facts[obj], objFact.Fact)
+ }
+ }
+ for _, pkgFact := range act.AllPackageFacts() {
+ if pkgFact.Package == act.Package.Types {
+ facts[nil] = append(facts[nil], pkgFact.Fact)
+ }
+ }
+
+ // Construct the legacy result.
+ results = append(results, &Result{
+ Pass: internal.Pass(act),
+ Diagnostics: act.Diagnostics,
+ Facts: facts,
+ Result: act.Result,
+ Err: act.Err,
+ Action: act,
+ })
}
return results
}
// A Result holds the result of applying an analyzer to a package.
-type Result = checker.TestAnalyzerResult
+//
+// Facts contains only facts associated with the package and its objects.
+//
+// This internal type was inadvertently and regrettably exposed
+// through a public type alias. It is essentially redundant with
+// [checker.Action], but must be retained for compatibility. Clients may
+// access the public fields of the Pass but must not invoke any of
+// its "verbs", since the pass is already complete.
+type Result struct {
+ Action *checker.Action
+
+ // legacy fields
+ Facts map[types.Object][]analysis.Fact // nil key => package fact
+ Pass *analysis.Pass
+ Diagnostics []analysis.Diagnostic // see Action.Diagnostics
+ Result any // see Action.Result
+ Err error // see Action.Err
+}
// loadPackages uses go/packages to load a specified packages (from source, with
// dependencies) from dir, which is the root of a GOPATH-style project tree.
// loadPackages returns an error if any package had an error, or the pattern
// matched no packages.
-func loadPackages(a *analysis.Analyzer, dir string, patterns ...string) ([]*packages.Package, error) {
+func loadPackages(dir string, patterns ...string) ([]*packages.Package, error) {
env := []string{"GOPATH=" + dir, "GO111MODULE=off", "GOWORK=off"} // GOPATH mode
// Undocumented module mode. Will be replaced by something better.
@@ -421,16 +476,6 @@ func loadPackages(a *analysis.Analyzer, dir string, patterns ...string) ([]*pack
}
}
- // Do NOT print errors if the analyzer will continue running.
- // It is incredibly confusing for tests to be printing to stderr
- // willy-nilly instead of their test logs, especially when the
- // errors are expected and are going to be fixed.
- if !a.RunDespiteErrors {
- if packages.PrintErrors(pkgs) > 0 {
- return nil, fmt.Errorf("there were package loading errors (and RunDespiteErrors is false)")
- }
- }
-
if len(pkgs) == 0 {
return nil, fmt.Errorf("no packages matched %s", patterns)
}
@@ -441,7 +486,7 @@ func loadPackages(a *analysis.Analyzer, dir string, patterns ...string) ([]*pack
// been run, and verifies that all reported diagnostics and facts match
// specified by the contents of "// want ..." comments in the package's
// source files, which must have been parsed with comments enabled.
-func check(t Testing, gopath string, pass *analysis.Pass, diagnostics []analysis.Diagnostic, facts map[types.Object][]analysis.Fact) {
+func check(t Testing, gopath string, act *checker.Action) {
type key struct {
file string
line int
@@ -468,7 +513,7 @@ func check(t Testing, gopath string, pass *analysis.Pass, diagnostics []analysis
}
// Extract 'want' comments from parsed Go files.
- for _, f := range pass.Files {
+ for _, f := range act.Package.Syntax {
for _, cgroup := range f.Comments {
for _, c := range cgroup.List {
@@ -491,7 +536,7 @@ func check(t Testing, gopath string, pass *analysis.Pass, diagnostics []analysis
// once outside the loop, but it's
// incorrect because it can change due
// to //line directives.
- posn := pass.Fset.Position(c.Pos())
+ posn := act.Package.Fset.Position(c.Pos())
filename := sanitize(gopath, posn.Filename)
processComment(filename, posn.Line, text)
}
@@ -500,7 +545,17 @@ func check(t Testing, gopath string, pass *analysis.Pass, diagnostics []analysis
// Extract 'want' comments from non-Go files.
// TODO(adonovan): we may need to handle //line directives.
- for _, filename := range pass.OtherFiles {
+ files := act.Package.OtherFiles
+
+ // Hack: these two analyzers need to extract expectations from
+ // all configurations, so include the files are are usually
+ // ignored. (This was previously a hack in the respective
+ // analyzers' tests.)
+ if act.Analyzer.Name == "buildtag" || act.Analyzer.Name == "directive" {
+ files = append(files[:len(files):len(files)], act.Package.IgnoredFiles...)
+ }
+
+ for _, filename := range files {
data, err := os.ReadFile(filename)
if err != nil {
t.Errorf("can't read '// want' comments from %s: %v", filename, err)
@@ -553,45 +608,38 @@ func check(t Testing, gopath string, pass *analysis.Pass, diagnostics []analysis
}
// Check the diagnostics match expectations.
- for _, f := range diagnostics {
+ for _, f := range act.Diagnostics {
// TODO(matloob): Support ranges in analysistest.
- posn := pass.Fset.Position(f.Pos)
+ posn := act.Package.Fset.Position(f.Pos)
checkMessage(posn, "diagnostic", "", f.Message)
}
// Check the facts match expectations.
- // Report errors in lexical order for determinism.
+ // We check only facts relating to the current package.
+ //
+ // We report errors in lexical order for determinism.
// (It's only deterministic within each file, not across files,
// because go/packages does not guarantee file.Pos is ascending
// across the files of a single compilation unit.)
- var objects []types.Object
- for obj := range facts {
- objects = append(objects, obj)
- }
- sort.Slice(objects, func(i, j int) bool {
- // Package facts compare less than object facts.
- ip, jp := objects[i] == nil, objects[j] == nil // whether i, j is a package fact
- if ip != jp {
- return ip && !jp
- }
- return objects[i].Pos() < objects[j].Pos()
- })
- for _, obj := range objects {
- var posn token.Position
- var name string
- if obj != nil {
- // Object facts are reported on the declaring line.
- name = obj.Name()
- posn = pass.Fset.Position(obj.Pos())
- } else {
- // Package facts are reported at the start of the file.
- name = "package"
- posn = pass.Fset.Position(pass.Files[0].Pos())
- posn.Line = 1
+
+ // package facts: reported at start of first file
+ for _, pkgFact := range act.AllPackageFacts() {
+ if pkgFact.Package == act.Package.Types {
+ posn := act.Package.Fset.Position(act.Package.Syntax[0].Pos())
+ posn.Line, posn.Column = 1, 1
+ checkMessage(posn, "fact", "package", fmt.Sprint(pkgFact))
}
+ }
- for _, fact := range facts[obj] {
- checkMessage(posn, "fact", name, fmt.Sprint(fact))
+ // object facts: reported at line of object declaration
+ objFacts := act.AllObjectFacts()
+ sort.Slice(objFacts, func(i, j int) bool {
+ return objFacts[i].Object.Pos() < objFacts[j].Object.Pos()
+ })
+ for _, objFact := range objFacts {
+ if obj := objFact.Object; obj.Pkg() == act.Package.Types {
+ posn := act.Package.Fset.Position(obj.Pos())
+ checkMessage(posn, "fact", obj.Name(), fmt.Sprint(objFact.Fact))
}
}
diff --git a/vendor/golang.org/x/tools/go/analysis/checker/checker.go b/vendor/golang.org/x/tools/go/analysis/checker/checker.go
new file mode 100644
index 000000000..5935a62ab
--- /dev/null
+++ b/vendor/golang.org/x/tools/go/analysis/checker/checker.go
@@ -0,0 +1,625 @@
+// 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 checker provides an analysis driver based on the
+// [golang.org/x/tools/go/packages] representation of a set of
+// packages and all their dependencies, as produced by
+// [packages.Load].
+//
+// It is the core of multichecker (the multi-analyzer driver),
+// singlechecker (the single-analyzer driver often used to provide a
+// convenient command alongside each analyzer), and analysistest, the
+// test driver.
+//
+// By contrast, the 'go vet' command is based on unitchecker, an
+// analysis driver that uses separate analysis--analogous to separate
+// compilation--with file-based intermediate results. Like separate
+// compilation, it is more scalable, especially for incremental
+// analysis of large code bases. Commands based on multichecker and
+// singlechecker are capable of detecting when they are being invoked
+// by "go vet -vettool=exe" and instead dispatching to unitchecker.
+//
+// Programs built using this package will, in general, not be usable
+// in that way. This package is intended only for use in applications
+// that invoke the analysis driver as a subroutine, and need to insert
+// additional steps before or after the analysis.
+//
+// See the Example of how to build a complete analysis driver program.
+package checker
+
+import (
+ "bytes"
+ "encoding/gob"
+ "fmt"
+ "go/types"
+ "io"
+ "log"
+ "reflect"
+ "sort"
+ "strings"
+ "sync"
+ "time"
+
+ "golang.org/x/tools/go/analysis"
+ "golang.org/x/tools/go/analysis/internal"
+ "golang.org/x/tools/go/analysis/internal/analysisflags"
+ "golang.org/x/tools/go/packages"
+ "golang.org/x/tools/internal/analysisinternal"
+)
+
+// Options specifies options that control the analysis driver.
+type Options struct {
+ // These options correspond to existing flags exposed by multichecker:
+ Sequential bool // disable parallelism
+ SanityCheck bool // check fact encoding is ok and deterministic
+ FactLog io.Writer // if non-nil, log each exported fact to it
+
+ // TODO(adonovan): add ReadFile so that an Overlay specified
+ // in the [packages.Config] can be communicated via
+ // Pass.ReadFile to each Analyzer.
+}
+
+// Graph holds the results of a round of analysis, including the graph
+// of requested actions (analyzers applied to packages) plus any
+// dependent actions that it was necessary to compute.
+type Graph struct {
+ // Roots contains the roots of the action graph.
+ // Each node (a, p) in the action graph represents the
+ // application of one analyzer a to one package p.
+ // (A node thus corresponds to one analysis.Pass instance.)
+ // Roots holds one action per element of the product
+ // of the analyzers × packages arguments to Analyze,
+ // in unspecified order.
+ //
+ // Each element of Action.Deps represents an edge in the
+ // action graph: a dependency from one action to another.
+ // An edge of the form (a, p) -> (a, p2) indicates that the
+ // analysis of package p requires information ("facts") from
+ // the same analyzer applied to one of p's dependencies, p2.
+ // An edge of the form (a, p) -> (a2, p) indicates that the
+ // analysis of package p requires information ("results")
+ // from a different analyzer a2 applied to the same package.
+ // These two kind of edges are called "vertical" and "horizontal",
+ // respectively.
+ Roots []*Action
+}
+
+// All returns an iterator over the action graph in depth-first postorder.
+//
+// Example:
+//
+// for act := range graph.All() {
+// ...
+// }
+//
+// Clients using go1.22 should iterate using the code below and may
+// not assume anything else about the result:
+//
+// graph.All()(func (act *Action) bool {
+// ...
+// })
+func (g *Graph) All() actionSeq {
+ return func(yield func(*Action) bool) {
+ forEach(g.Roots, func(act *Action) error {
+ if !yield(act) {
+ return io.EOF // any error will do
+ }
+ return nil
+ })
+ }
+}
+
+// An Action represents one unit of analysis work by the driver: the
+// application of one analysis to one package. It provides the inputs
+// to and records the outputs of a single analysis.Pass.
+//
+// Actions form a DAG, both within a package (as different analyzers
+// are applied, either in sequence or parallel), and across packages
+// (as dependencies are analyzed).
+type Action struct {
+ Analyzer *analysis.Analyzer
+ Package *packages.Package
+ IsRoot bool // whether this is a root node of the graph
+ Deps []*Action
+ Result any // computed result of Analyzer.run, if any (and if IsRoot)
+ Err error // error result of Analyzer.run
+ Diagnostics []analysis.Diagnostic
+ Duration time.Duration // execution time of this step
+
+ opts *Options
+ once sync.Once
+ pass *analysis.Pass
+ objectFacts map[objectFactKey]analysis.Fact
+ packageFacts map[packageFactKey]analysis.Fact
+ inputs map[*analysis.Analyzer]any
+}
+
+func (act *Action) String() string {
+ return fmt.Sprintf("%s@%s", act.Analyzer, act.Package)
+}
+
+// Analyze runs the specified analyzers on the initial packages.
+//
+// The initial packages and all dependencies must have been loaded
+// using the [packages.LoadAllSyntax] flag, Analyze may need to run
+// some analyzer (those that consume and produce facts) on
+// dependencies too.
+//
+// On success, it returns a Graph of actions whose Roots hold one
+// item per (a, p) in the cross-product of analyzers and pkgs.
+//
+// If opts is nil, it is equivalent to new(Options).
+func Analyze(analyzers []*analysis.Analyzer, pkgs []*packages.Package, opts *Options) (*Graph, error) {
+ if opts == nil {
+ opts = new(Options)
+ }
+
+ if err := analysis.Validate(analyzers); err != nil {
+ return nil, err
+ }
+
+ // Construct the action graph.
+ //
+ // Each graph node (action) is one unit of analysis.
+ // Edges express package-to-package (vertical) dependencies,
+ // and analysis-to-analysis (horizontal) dependencies.
+ type key struct {
+ a *analysis.Analyzer
+ pkg *packages.Package
+ }
+ actions := make(map[key]*Action)
+
+ var mkAction func(a *analysis.Analyzer, pkg *packages.Package) *Action
+ mkAction = func(a *analysis.Analyzer, pkg *packages.Package) *Action {
+ k := key{a, pkg}
+ act, ok := actions[k]
+ if !ok {
+ act = &Action{Analyzer: a, Package: pkg, opts: opts}
+
+ // Add a dependency on each required analyzers.
+ for _, req := range a.Requires {
+ act.Deps = append(act.Deps, mkAction(req, pkg))
+ }
+
+ // An analysis that consumes/produces facts
+ // must run on the package's dependencies too.
+ if len(a.FactTypes) > 0 {
+ paths := make([]string, 0, len(pkg.Imports))
+ for path := range pkg.Imports {
+ paths = append(paths, path)
+ }
+ sort.Strings(paths) // for determinism
+ for _, path := range paths {
+ dep := mkAction(a, pkg.Imports[path])
+ act.Deps = append(act.Deps, dep)
+ }
+ }
+
+ actions[k] = act
+ }
+ return act
+ }
+
+ // Build nodes for initial packages.
+ var roots []*Action
+ for _, a := range analyzers {
+ for _, pkg := range pkgs {
+ root := mkAction(a, pkg)
+ root.IsRoot = true
+ roots = append(roots, root)
+ }
+ }
+
+ // Execute the graph in parallel.
+ execAll(roots)
+
+ // Ensure that only root Results are visible to caller.
+ // (The others are considered temporary intermediaries.)
+ // TODO(adonovan): opt: clear them earlier, so we can
+ // release large data structures like SSA sooner.
+ for _, act := range actions {
+ if !act.IsRoot {
+ act.Result = nil
+ }
+ }
+
+ return &Graph{Roots: roots}, nil
+}
+
+func init() {
+ // Allow analysistest to access Action.pass,
+ // for its legacy Result data type.
+ internal.Pass = func(x any) *analysis.Pass { return x.(*Action).pass }
+}
+
+type objectFactKey struct {
+ obj types.Object
+ typ reflect.Type
+}
+
+type packageFactKey struct {
+ pkg *types.Package
+ typ reflect.Type
+}
+
+func execAll(actions []*Action) {
+ var wg sync.WaitGroup
+ for _, act := range actions {
+ wg.Add(1)
+ work := func(act *Action) {
+ act.exec()
+ wg.Done()
+ }
+ if act.opts.Sequential {
+ work(act)
+ } else {
+ go work(act)
+ }
+ }
+ wg.Wait()
+}
+
+func (act *Action) exec() { act.once.Do(act.execOnce) }
+
+func (act *Action) execOnce() {
+ // Analyze dependencies.
+ execAll(act.Deps)
+
+ // Record time spent in this node but not its dependencies.
+ // In parallel mode, due to GC/scheduler contention, the
+ // time is 5x higher than in sequential mode, even with a
+ // semaphore limiting the number of threads here.
+ // So use -debug=tp.
+ t0 := time.Now()
+ defer func() { act.Duration = time.Since(t0) }()
+
+ // Report an error if any dependency failed.
+ var failed []string
+ for _, dep := range act.Deps {
+ if dep.Err != nil {
+ failed = append(failed, dep.String())
+ }
+ }
+ if failed != nil {
+ sort.Strings(failed)
+ act.Err = fmt.Errorf("failed prerequisites: %s", strings.Join(failed, ", "))
+ return
+ }
+
+ // Plumb the output values of the dependencies
+ // into the inputs of this action. Also facts.
+ inputs := make(map[*analysis.Analyzer]any)
+ act.objectFacts = make(map[objectFactKey]analysis.Fact)
+ act.packageFacts = make(map[packageFactKey]analysis.Fact)
+ for _, dep := range act.Deps {
+ if dep.Package == act.Package {
+ // Same package, different analysis (horizontal edge):
+ // in-memory outputs of prerequisite analyzers
+ // become inputs to this analysis pass.
+ inputs[dep.Analyzer] = dep.Result
+
+ } else if dep.Analyzer == act.Analyzer { // (always true)
+ // Same analysis, different package (vertical edge):
+ // serialized facts produced by prerequisite analysis
+ // become available to this analysis pass.
+ inheritFacts(act, dep)
+ }
+ }
+
+ // Quick (nonexhaustive) check that the correct go/packages mode bits were used.
+ // (If there were errors, all bets are off.)
+ if pkg := act.Package; pkg.Errors == nil {
+ if pkg.Name == "" || pkg.PkgPath == "" || pkg.Types == nil || pkg.Fset == nil || pkg.TypesSizes == nil {
+ panic("packages must be loaded with packages.LoadSyntax mode")
+ }
+ }
+
+ module := &analysis.Module{} // possibly empty (non nil) in go/analysis drivers.
+ if mod := act.Package.Module; mod != nil {
+ module.Path = mod.Path
+ module.Version = mod.Version
+ module.GoVersion = mod.GoVersion
+ }
+
+ // Run the analysis.
+ pass := &analysis.Pass{
+ Analyzer: act.Analyzer,
+ Fset: act.Package.Fset,
+ Files: act.Package.Syntax,
+ OtherFiles: act.Package.OtherFiles,
+ IgnoredFiles: act.Package.IgnoredFiles,
+ Pkg: act.Package.Types,
+ TypesInfo: act.Package.TypesInfo,
+ TypesSizes: act.Package.TypesSizes,
+ TypeErrors: act.Package.TypeErrors,
+ Module: module,
+
+ ResultOf: inputs,
+ Report: func(d analysis.Diagnostic) { act.Diagnostics = append(act.Diagnostics, d) },
+ ImportObjectFact: act.ObjectFact,
+ ExportObjectFact: act.exportObjectFact,
+ ImportPackageFact: act.PackageFact,
+ ExportPackageFact: act.exportPackageFact,
+ AllObjectFacts: act.AllObjectFacts,
+ AllPackageFacts: act.AllPackageFacts,
+ }
+ pass.ReadFile = analysisinternal.MakeReadFile(pass)
+ act.pass = pass
+
+ act.Result, act.Err = func() (any, error) {
+ if act.Package.IllTyped && !pass.Analyzer.RunDespiteErrors {
+ return nil, fmt.Errorf("analysis skipped due to errors in package")
+ }
+
+ result, err := pass.Analyzer.Run(pass)
+ if err != nil {
+ return nil, err
+ }
+
+ // correct result type?
+ if got, want := reflect.TypeOf(result), pass.Analyzer.ResultType; got != want {
+ return nil, fmt.Errorf(
+ "internal error: on package %s, analyzer %s returned a result of type %v, but declared ResultType %v",
+ pass.Pkg.Path(), pass.Analyzer, got, want)
+ }
+
+ // resolve diagnostic URLs
+ for i := range act.Diagnostics {
+ url, err := analysisflags.ResolveURL(act.Analyzer, act.Diagnostics[i])
+ if err != nil {
+ return nil, err
+ }
+ act.Diagnostics[i].URL = url
+ }
+ return result, nil
+ }()
+
+ // Help detect (disallowed) calls after Run.
+ pass.ExportObjectFact = nil
+ pass.ExportPackageFact = nil
+}
+
+// inheritFacts populates act.facts with
+// those it obtains from its dependency, dep.
+func inheritFacts(act, dep *Action) {
+ for key, fact := range dep.objectFacts {
+ // Filter out facts related to objects
+ // that are irrelevant downstream
+ // (equivalently: not in the compiler export data).
+ if !exportedFrom(key.obj, dep.Package.Types) {
+ if false {
+ log.Printf("%v: discarding %T fact from %s for %s: %s", act, fact, dep, key.obj, fact)
+ }
+ continue
+ }
+
+ // Optionally serialize/deserialize fact
+ // to verify that it works across address spaces.
+ if act.opts.SanityCheck {
+ encodedFact, err := codeFact(fact)
+ if err != nil {
+ log.Panicf("internal error: encoding of %T fact failed in %v", fact, act)
+ }
+ fact = encodedFact
+ }
+
+ if false {
+ log.Printf("%v: inherited %T fact for %s: %s", act, fact, key.obj, fact)
+ }
+ act.objectFacts[key] = fact
+ }
+
+ for key, fact := range dep.packageFacts {
+ // TODO: filter out facts that belong to
+ // packages not mentioned in the export data
+ // to prevent side channels.
+ //
+ // The Pass.All{Object,Package}Facts accessors expose too much:
+ // all facts, of all types, for all dependencies in the action
+ // graph. Not only does the representation grow quadratically,
+ // but it violates the separate compilation paradigm, allowing
+ // analysis implementations to communicate with indirect
+ // dependencies that are not mentioned in the export data.
+ //
+ // It's not clear how to fix this short of a rather expensive
+ // filtering step after each action that enumerates all the
+ // objects that would appear in export data, and deletes
+ // facts associated with objects not in this set.
+
+ // Optionally serialize/deserialize fact
+ // to verify that it works across address spaces
+ // and is deterministic.
+ if act.opts.SanityCheck {
+ encodedFact, err := codeFact(fact)
+ if err != nil {
+ log.Panicf("internal error: encoding of %T fact failed in %v", fact, act)
+ }
+ fact = encodedFact
+ }
+
+ if false {
+ log.Printf("%v: inherited %T fact for %s: %s", act, fact, key.pkg.Path(), fact)
+ }
+ act.packageFacts[key] = fact
+ }
+}
+
+// codeFact encodes then decodes a fact,
+// just to exercise that logic.
+func codeFact(fact analysis.Fact) (analysis.Fact, error) {
+ // We encode facts one at a time.
+ // A real modular driver would emit all facts
+ // into one encoder to improve gob efficiency.
+ var buf bytes.Buffer
+ if err := gob.NewEncoder(&buf).Encode(fact); err != nil {
+ return nil, err
+ }
+
+ // Encode it twice and assert that we get the same bits.
+ // This helps detect nondeterministic Gob encoding (e.g. of maps).
+ var buf2 bytes.Buffer
+ if err := gob.NewEncoder(&buf2).Encode(fact); err != nil {
+ return nil, err
+ }
+ if !bytes.Equal(buf.Bytes(), buf2.Bytes()) {
+ return nil, fmt.Errorf("encoding of %T fact is nondeterministic", fact)
+ }
+
+ new := reflect.New(reflect.TypeOf(fact).Elem()).Interface().(analysis.Fact)
+ if err := gob.NewDecoder(&buf).Decode(new); err != nil {
+ return nil, err
+ }
+ return new, nil
+}
+
+// exportedFrom reports whether obj may be visible to a package that imports pkg.
+// This includes not just the exported members of pkg, but also unexported
+// constants, types, fields, and methods, perhaps belonging to other packages,
+// that find there way into the API.
+// This is an overapproximation of the more accurate approach used by
+// gc export data, which walks the type graph, but it's much simpler.
+//
+// TODO(adonovan): do more accurate filtering by walking the type graph.
+func exportedFrom(obj types.Object, pkg *types.Package) bool {
+ switch obj := obj.(type) {
+ case *types.Func:
+ return obj.Exported() && obj.Pkg() == pkg ||
+ obj.Type().(*types.Signature).Recv() != nil
+ case *types.Var:
+ if obj.IsField() {
+ return true
+ }
+ // we can't filter more aggressively than this because we need
+ // to consider function parameters exported, but have no way
+ // of telling apart function parameters from local variables.
+ return obj.Pkg() == pkg
+ case *types.TypeName, *types.Const:
+ return true
+ }
+ return false // Nil, Builtin, Label, or PkgName
+}
+
+// ObjectFact retrieves a fact associated with obj,
+// and returns true if one was found.
+// Given a value ptr of type *T, where *T satisfies Fact,
+// ObjectFact copies the value to *ptr.
+//
+// See documentation at ImportObjectFact field of [analysis.Pass].
+func (act *Action) ObjectFact(obj types.Object, ptr analysis.Fact) bool {
+ if obj == nil {
+ panic("nil object")
+ }
+ key := objectFactKey{obj, factType(ptr)}
+ if v, ok := act.objectFacts[key]; ok {
+ reflect.ValueOf(ptr).Elem().Set(reflect.ValueOf(v).Elem())
+ return true
+ }
+ return false
+}
+
+// exportObjectFact implements Pass.ExportObjectFact.
+func (act *Action) exportObjectFact(obj types.Object, fact analysis.Fact) {
+ if act.pass.ExportObjectFact == nil {
+ log.Panicf("%s: Pass.ExportObjectFact(%s, %T) called after Run", act, obj, fact)
+ }
+
+ if obj.Pkg() != act.Package.Types {
+ log.Panicf("internal error: in analysis %s of package %s: Fact.Set(%s, %T): can't set facts on objects belonging another package",
+ act.Analyzer, act.Package, obj, fact)
+ }
+
+ key := objectFactKey{obj, factType(fact)}
+ act.objectFacts[key] = fact // clobber any existing entry
+ if log := act.opts.FactLog; log != nil {
+ objstr := types.ObjectString(obj, (*types.Package).Name)
+ fmt.Fprintf(log, "%s: object %s has fact %s\n",
+ act.Package.Fset.Position(obj.Pos()), objstr, fact)
+ }
+}
+
+// AllObjectFacts returns a new slice containing all object facts of
+// the analysis's FactTypes in unspecified order.
+//
+// See documentation at AllObjectFacts field of [analysis.Pass].
+func (act *Action) AllObjectFacts() []analysis.ObjectFact {
+ facts := make([]analysis.ObjectFact, 0, len(act.objectFacts))
+ for k, fact := range act.objectFacts {
+ facts = append(facts, analysis.ObjectFact{Object: k.obj, Fact: fact})
+ }
+ return facts
+}
+
+// PackageFact retrieves a fact associated with package pkg,
+// which must be this package or one of its dependencies.
+//
+// See documentation at ImportObjectFact field of [analysis.Pass].
+func (act *Action) PackageFact(pkg *types.Package, ptr analysis.Fact) bool {
+ if pkg == nil {
+ panic("nil package")
+ }
+ key := packageFactKey{pkg, factType(ptr)}
+ if v, ok := act.packageFacts[key]; ok {
+ reflect.ValueOf(ptr).Elem().Set(reflect.ValueOf(v).Elem())
+ return true
+ }
+ return false
+}
+
+// exportPackageFact implements Pass.ExportPackageFact.
+func (act *Action) exportPackageFact(fact analysis.Fact) {
+ if act.pass.ExportPackageFact == nil {
+ log.Panicf("%s: Pass.ExportPackageFact(%T) called after Run", act, fact)
+ }
+
+ key := packageFactKey{act.pass.Pkg, factType(fact)}
+ act.packageFacts[key] = fact // clobber any existing entry
+ if log := act.opts.FactLog; log != nil {
+ fmt.Fprintf(log, "%s: package %s has fact %s\n",
+ act.Package.Fset.Position(act.pass.Files[0].Pos()), act.pass.Pkg.Path(), fact)
+ }
+}
+
+func factType(fact analysis.Fact) reflect.Type {
+ t := reflect.TypeOf(fact)
+ if t.Kind() != reflect.Ptr {
+ log.Fatalf("invalid Fact type: got %T, want pointer", fact)
+ }
+ return t
+}
+
+// AllPackageFacts returns a new slice containing all package
+// facts of the analysis's FactTypes in unspecified order.
+//
+// See documentation at AllPackageFacts field of [analysis.Pass].
+func (act *Action) AllPackageFacts() []analysis.PackageFact {
+ facts := make([]analysis.PackageFact, 0, len(act.packageFacts))
+ for k, fact := range act.packageFacts {
+ facts = append(facts, analysis.PackageFact{Package: k.pkg, Fact: fact})
+ }
+ return facts
+}
+
+// forEach is a utility function for traversing the action graph. It
+// applies function f to each action in the graph reachable from
+// roots, in depth-first postorder. If any call to f returns an error,
+// the traversal is aborted and ForEach returns the error.
+func forEach(roots []*Action, f func(*Action) error) error {
+ seen := make(map[*Action]bool)
+ var visitAll func(actions []*Action) error
+ visitAll = func(actions []*Action) error {
+ for _, act := range actions {
+ if !seen[act] {
+ seen[act] = true
+ if err := visitAll(act.Deps); err != nil {
+ return err
+ }
+ if err := f(act); err != nil {
+ return err
+ }
+ }
+ }
+ return nil
+ }
+ return visitAll(roots)
+}
diff --git a/vendor/golang.org/x/tools/go/analysis/checker/iter_go122.go b/vendor/golang.org/x/tools/go/analysis/checker/iter_go122.go
new file mode 100644
index 000000000..cd25cce03
--- /dev/null
+++ b/vendor/golang.org/x/tools/go/analysis/checker/iter_go122.go
@@ -0,0 +1,10 @@
+// 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.
+
+//go:build !go1.23
+
+package checker
+
+// This type is a placeholder for go1.23's iter.Seq[*Action].
+type actionSeq func(yield func(*Action) bool)
diff --git a/vendor/golang.org/x/tools/internal/versions/constraint_go121.go b/vendor/golang.org/x/tools/go/analysis/checker/iter_go123.go
index 38011407d..e8278a9c1 100644
--- a/vendor/golang.org/x/tools/internal/versions/constraint_go121.go
+++ b/vendor/golang.org/x/tools/go/analysis/checker/iter_go123.go
@@ -2,13 +2,10 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
-//go:build go1.21
-// +build go1.21
+//go:build go1.23
-package versions
+package checker
-import "go/build/constraint"
+import "iter"
-func init() {
- ConstraintGoVersion = constraint.GoVersion
-}
+type actionSeq = iter.Seq[*Action]
diff --git a/vendor/golang.org/x/tools/go/analysis/checker/print.go b/vendor/golang.org/x/tools/go/analysis/checker/print.go
new file mode 100644
index 000000000..d7c043011
--- /dev/null
+++ b/vendor/golang.org/x/tools/go/analysis/checker/print.go
@@ -0,0 +1,88 @@
+// 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 checker
+
+// This file defines helpers for printing analysis results.
+// They should all be pure functions.
+
+import (
+ "bytes"
+ "fmt"
+ "go/token"
+ "io"
+
+ "golang.org/x/tools/go/analysis"
+ "golang.org/x/tools/go/analysis/internal/analysisflags"
+)
+
+// PrintText emits diagnostics as plain text to w.
+//
+// If contextLines is nonnegative, it also prints the
+// offending line, plus that many lines of context
+// before and after the line.
+func (g *Graph) PrintText(w io.Writer, contextLines int) error {
+ return writeTextDiagnostics(w, g.Roots, contextLines)
+}
+
+func writeTextDiagnostics(w io.Writer, roots []*Action, contextLines int) error {
+ // De-duplicate diagnostics by position (not token.Pos) to
+ // avoid double-reporting in source files that belong to
+ // multiple packages, such as foo and foo.test.
+ // (We cannot assume that such repeated files were parsed
+ // only once and use syntax nodes as the key.)
+ type key struct {
+ pos token.Position
+ end token.Position
+ *analysis.Analyzer
+ message string
+ }
+ seen := make(map[key]bool)
+
+ // TODO(adonovan): opt: plumb errors back from PrintPlain and avoid buffer.
+ buf := new(bytes.Buffer)
+ forEach(roots, func(act *Action) error {
+ if act.Err != nil {
+ fmt.Fprintf(w, "%s: %v\n", act.Analyzer.Name, act.Err)
+ } else if act.IsRoot {
+ for _, diag := range act.Diagnostics {
+ // We don't display Analyzer.Name/diag.Category
+ // as most users don't care.
+
+ posn := act.Package.Fset.Position(diag.Pos)
+ end := act.Package.Fset.Position(diag.End)
+ k := key{posn, end, act.Analyzer, diag.Message}
+ if seen[k] {
+ continue // duplicate
+ }
+ seen[k] = true
+
+ analysisflags.PrintPlain(buf, act.Package.Fset, contextLines, diag)
+ }
+ }
+ return nil
+ })
+ _, err := w.Write(buf.Bytes())
+ return err
+}
+
+// PrintJSON emits diagnostics in JSON form to w.
+// Diagnostics are shown only for the root nodes,
+// but errors (if any) are shown for all dependencies.
+func (g *Graph) PrintJSON(w io.Writer) error {
+ return writeJSONDiagnostics(w, g.Roots)
+}
+
+func writeJSONDiagnostics(w io.Writer, roots []*Action) error {
+ tree := make(analysisflags.JSONTree)
+ forEach(roots, func(act *Action) error {
+ var diags []analysis.Diagnostic
+ if act.IsRoot {
+ diags = act.Diagnostics
+ }
+ tree.Add(act.Package.Fset, act.Package.ID, act.Analyzer.Name, diags, act.Err)
+ return nil
+ })
+ return tree.Print(w)
+}
diff --git a/vendor/golang.org/x/tools/go/analysis/internal/analysisflags/flags.go b/vendor/golang.org/x/tools/go/analysis/internal/analysisflags/flags.go
index ff14ff58f..c2445575c 100644
--- a/vendor/golang.org/x/tools/go/analysis/internal/analysisflags/flags.go
+++ b/vendor/golang.org/x/tools/go/analysis/internal/analysisflags/flags.go
@@ -250,21 +250,12 @@ const (
setFalse
)
-func triStateFlag(name string, value triState, usage string) *triState {
- flag.Var(&value, name, usage)
- return &value
-}
-
// triState implements flag.Value, flag.Getter, and flag.boolFlag.
// They work like boolean flags: we can say vet -printf as well as vet -printf=true
func (ts *triState) Get() interface{} {
return *ts == setTrue
}
-func (ts triState) isTrue() bool {
- return ts == setTrue
-}
-
func (ts *triState) Set(value string) error {
b, err := strconv.ParseBool(value)
if err != nil {
@@ -316,15 +307,22 @@ var vetLegacyFlags = map[string]string{
}
// ---- output helpers common to all drivers ----
+//
+// These functions should not depend on global state (flags)!
+// Really they belong in a different package.
+
+// TODO(adonovan): don't accept an io.Writer if we don't report errors.
+// Either accept a bytes.Buffer (infallible), or return a []byte.
-// PrintPlain prints a diagnostic in plain text form,
-// with context specified by the -c flag.
-func PrintPlain(fset *token.FileSet, diag analysis.Diagnostic) {
+// PrintPlain prints a diagnostic in plain text form.
+// If contextLines is nonnegative, it also prints the
+// offending line plus this many lines of context.
+func PrintPlain(out io.Writer, fset *token.FileSet, contextLines int, diag analysis.Diagnostic) {
posn := fset.Position(diag.Pos)
- fmt.Fprintf(os.Stderr, "%s: %s\n", posn, diag.Message)
+ fmt.Fprintf(out, "%s: %s\n", posn, diag.Message)
- // -c=N: show offending line plus N lines of context.
- if Context >= 0 {
+ // show offending line plus N lines of context.
+ if contextLines >= 0 {
posn := fset.Position(diag.Pos)
end := fset.Position(diag.End)
if !end.IsValid() {
@@ -332,9 +330,9 @@ func PrintPlain(fset *token.FileSet, diag analysis.Diagnostic) {
}
data, _ := os.ReadFile(posn.Filename)
lines := strings.Split(string(data), "\n")
- for i := posn.Line - Context; i <= end.Line+Context; i++ {
+ for i := posn.Line - contextLines; i <= end.Line+contextLines; i++ {
if 1 <= i && i <= len(lines) {
- fmt.Fprintf(os.Stderr, "%d\t%s\n", i, lines[i-1])
+ fmt.Fprintf(out, "%d\t%s\n", i, lines[i-1])
}
}
}
@@ -438,10 +436,11 @@ func (tree JSONTree) Add(fset *token.FileSet, id, name string, diags []analysis.
}
}
-func (tree JSONTree) Print() {
+func (tree JSONTree) Print(out io.Writer) error {
data, err := json.MarshalIndent(tree, "", "\t")
if err != nil {
log.Panicf("internal error: JSON marshaling failed: %v", err)
}
- fmt.Printf("%s\n", data)
+ _, err = fmt.Fprintf(out, "%s\n", data)
+ return err
}
diff --git a/vendor/golang.org/x/tools/go/analysis/internal/checker/checker.go b/vendor/golang.org/x/tools/go/analysis/internal/checker/checker.go
deleted file mode 100644
index 8a802831c..000000000
--- a/vendor/golang.org/x/tools/go/analysis/internal/checker/checker.go
+++ /dev/null
@@ -1,984 +0,0 @@
-// Copyright 2018 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 checker defines the implementation of the checker commands.
-// The same code drives the multi-analysis driver, the single-analysis
-// driver that is conventionally provided for convenience along with
-// each analysis package, and the test driver.
-package checker
-
-import (
- "bytes"
- "encoding/gob"
- "flag"
- "fmt"
- "go/format"
- "go/token"
- "go/types"
- "log"
- "os"
- "reflect"
- "runtime"
- "runtime/pprof"
- "runtime/trace"
- "sort"
- "strings"
- "sync"
- "time"
-
- "golang.org/x/tools/go/analysis"
- "golang.org/x/tools/go/analysis/internal/analysisflags"
- "golang.org/x/tools/go/packages"
- "golang.org/x/tools/internal/analysisinternal"
- "golang.org/x/tools/internal/diff"
- "golang.org/x/tools/internal/robustio"
-)
-
-var (
- // Debug is a set of single-letter flags:
- //
- // f show [f]acts as they are created
- // p disable [p]arallel execution of analyzers
- // s do additional [s]anity checks on fact types and serialization
- // t show [t]iming info (NB: use 'p' flag to avoid GC/scheduler noise)
- // v show [v]erbose logging
- //
- Debug = ""
-
- // Log files for optional performance tracing.
- CPUProfile, MemProfile, Trace string
-
- // IncludeTests indicates whether test files should be analyzed too.
- IncludeTests = true
-
- // Fix determines whether to apply all suggested fixes.
- Fix bool
-)
-
-// RegisterFlags registers command-line flags used by the analysis driver.
-func RegisterFlags() {
- // When adding flags here, remember to update
- // the list of suppressed flags in analysisflags.
-
- flag.StringVar(&Debug, "debug", Debug, `debug flags, any subset of "fpstv"`)
-
- flag.StringVar(&CPUProfile, "cpuprofile", "", "write CPU profile to this file")
- flag.StringVar(&MemProfile, "memprofile", "", "write memory profile to this file")
- flag.StringVar(&Trace, "trace", "", "write trace log to this file")
- flag.BoolVar(&IncludeTests, "test", IncludeTests, "indicates whether test files should be analyzed, too")
-
- flag.BoolVar(&Fix, "fix", false, "apply all suggested fixes")
-}
-
-// Run loads the packages specified by args using go/packages,
-// then applies the specified analyzers to them.
-// Analysis flags must already have been set.
-// Analyzers must be valid according to [analysis.Validate].
-// It provides most of the logic for the main functions of both the
-// singlechecker and the multi-analysis commands.
-// It returns the appropriate exit code.
-func Run(args []string, analyzers []*analysis.Analyzer) (exitcode int) {
- if CPUProfile != "" {
- f, err := os.Create(CPUProfile)
- if err != nil {
- log.Fatal(err)
- }
- if err := pprof.StartCPUProfile(f); err != nil {
- log.Fatal(err)
- }
- // NB: profile won't be written in case of error.
- defer pprof.StopCPUProfile()
- }
-
- if Trace != "" {
- f, err := os.Create(Trace)
- if err != nil {
- log.Fatal(err)
- }
- if err := trace.Start(f); err != nil {
- log.Fatal(err)
- }
- // NB: trace log won't be written in case of error.
- defer func() {
- trace.Stop()
- log.Printf("To view the trace, run:\n$ go tool trace view %s", Trace)
- }()
- }
-
- if MemProfile != "" {
- f, err := os.Create(MemProfile)
- if err != nil {
- log.Fatal(err)
- }
- // NB: memprofile won't be written in case of error.
- defer func() {
- runtime.GC() // get up-to-date statistics
- if err := pprof.WriteHeapProfile(f); err != nil {
- log.Fatalf("Writing memory profile: %v", err)
- }
- f.Close()
- }()
- }
-
- // Load the packages.
- if dbg('v') {
- log.SetPrefix("")
- log.SetFlags(log.Lmicroseconds) // display timing
- log.Printf("load %s", args)
- }
-
- // Optimization: if the selected analyzers don't produce/consume
- // facts, we need source only for the initial packages.
- allSyntax := needFacts(analyzers)
- initial, err := load(args, allSyntax)
- if err != nil {
- log.Print(err)
- return 1
- }
-
- pkgsExitCode := 0
- // Print package and module errors regardless of RunDespiteErrors.
- // Do not exit if there are errors, yet.
- if n := packages.PrintErrors(initial); n > 0 {
- pkgsExitCode = 1
- }
-
- // Run the analyzers. On each package with (transitive)
- // errors, we run only the subset of analyzers that are
- // marked (and whose transitive requirements are also
- // marked) with RunDespiteErrors.
- roots := analyze(initial, analyzers)
-
- // Apply fixes.
- if Fix {
- if err := applyFixes(roots); err != nil {
- // Fail when applying fixes failed.
- log.Print(err)
- return 1
- }
- }
-
- // Print the results. If !RunDespiteErrors and there
- // are errors in the packages, this will have 0 exit
- // code. Otherwise, we prefer to return exit code
- // indicating diagnostics.
- if diagExitCode := printDiagnostics(roots); diagExitCode != 0 {
- return diagExitCode // there were diagnostics
- }
- return pkgsExitCode // package errors but no diagnostics
-}
-
-// load loads the initial packages. Returns only top-level loading
-// errors. Does not consider errors in packages.
-func load(patterns []string, allSyntax bool) ([]*packages.Package, error) {
- mode := packages.LoadSyntax
- if allSyntax {
- mode = packages.LoadAllSyntax
- }
- mode |= packages.NeedModule
- conf := packages.Config{
- Mode: mode,
- Tests: IncludeTests,
- }
- initial, err := packages.Load(&conf, patterns...)
- if err == nil && len(initial) == 0 {
- err = fmt.Errorf("%s matched no packages", strings.Join(patterns, " "))
- }
- return initial, err
-}
-
-// TestAnalyzer applies an analyzer to a set of packages (and their
-// dependencies if necessary) and returns the results.
-// The analyzer must be valid according to [analysis.Validate].
-//
-// Facts about pkg are returned in a map keyed by object; package facts
-// have a nil key.
-//
-// This entry point is used only by analysistest.
-func TestAnalyzer(a *analysis.Analyzer, pkgs []*packages.Package) []*TestAnalyzerResult {
- var results []*TestAnalyzerResult
- for _, act := range analyze(pkgs, []*analysis.Analyzer{a}) {
- facts := make(map[types.Object][]analysis.Fact)
- for key, fact := range act.objectFacts {
- if key.obj.Pkg() == act.pass.Pkg {
- facts[key.obj] = append(facts[key.obj], fact)
- }
- }
- for key, fact := range act.packageFacts {
- if key.pkg == act.pass.Pkg {
- facts[nil] = append(facts[nil], fact)
- }
- }
-
- results = append(results, &TestAnalyzerResult{act.pass, act.diagnostics, facts, act.result, act.err})
- }
- return results
-}
-
-type TestAnalyzerResult struct {
- Pass *analysis.Pass
- Diagnostics []analysis.Diagnostic
- Facts map[types.Object][]analysis.Fact
- Result interface{}
- Err error
-}
-
-func analyze(pkgs []*packages.Package, analyzers []*analysis.Analyzer) []*action {
- // Construct the action graph.
- if dbg('v') {
- log.Printf("building graph of analysis passes")
- }
-
- // Each graph node (action) is one unit of analysis.
- // Edges express package-to-package (vertical) dependencies,
- // and analysis-to-analysis (horizontal) dependencies.
- type key struct {
- *analysis.Analyzer
- *packages.Package
- }
- actions := make(map[key]*action)
-
- var mkAction func(a *analysis.Analyzer, pkg *packages.Package) *action
- mkAction = func(a *analysis.Analyzer, pkg *packages.Package) *action {
- k := key{a, pkg}
- act, ok := actions[k]
- if !ok {
- act = &action{a: a, pkg: pkg}
-
- // Add a dependency on each required analyzers.
- for _, req := range a.Requires {
- act.deps = append(act.deps, mkAction(req, pkg))
- }
-
- // An analysis that consumes/produces facts
- // must run on the package's dependencies too.
- if len(a.FactTypes) > 0 {
- paths := make([]string, 0, len(pkg.Imports))
- for path := range pkg.Imports {
- paths = append(paths, path)
- }
- sort.Strings(paths) // for determinism
- for _, path := range paths {
- dep := mkAction(a, pkg.Imports[path])
- act.deps = append(act.deps, dep)
- }
- }
-
- actions[k] = act
- }
- return act
- }
-
- // Build nodes for initial packages.
- var roots []*action
- for _, a := range analyzers {
- for _, pkg := range pkgs {
- root := mkAction(a, pkg)
- root.isroot = true
- roots = append(roots, root)
- }
- }
-
- // Execute the graph in parallel.
- execAll(roots)
-
- return roots
-}
-
-func applyFixes(roots []*action) error {
- // visit all of the actions and accumulate the suggested edits.
- paths := make(map[robustio.FileID]string)
- editsByAction := make(map[robustio.FileID]map[*action][]diff.Edit)
- visited := make(map[*action]bool)
- var apply func(*action) error
- var visitAll func(actions []*action) error
- visitAll = func(actions []*action) error {
- for _, act := range actions {
- if !visited[act] {
- visited[act] = true
- if err := visitAll(act.deps); err != nil {
- return err
- }
- if err := apply(act); err != nil {
- return err
- }
- }
- }
- return nil
- }
-
- apply = func(act *action) error {
- editsForTokenFile := make(map[*token.File][]diff.Edit)
- for _, diag := range act.diagnostics {
- for _, sf := range diag.SuggestedFixes {
- for _, edit := range sf.TextEdits {
- // Validate the edit.
- // Any error here indicates a bug in the analyzer.
- start, end := edit.Pos, edit.End
- file := act.pkg.Fset.File(start)
- if file == nil {
- return fmt.Errorf("analysis %q suggests invalid fix: missing file info for pos (%v)",
- act.a.Name, start)
- }
- if !end.IsValid() {
- end = start
- }
- if start > end {
- return fmt.Errorf("analysis %q suggests invalid fix: pos (%v) > end (%v)",
- act.a.Name, start, end)
- }
- if eof := token.Pos(file.Base() + file.Size()); end > eof {
- return fmt.Errorf("analysis %q suggests invalid fix: end (%v) past end of file (%v)",
- act.a.Name, end, eof)
- }
- edit := diff.Edit{
- Start: file.Offset(start),
- End: file.Offset(end),
- New: string(edit.NewText),
- }
- editsForTokenFile[file] = append(editsForTokenFile[file], edit)
- }
- }
- }
-
- for f, edits := range editsForTokenFile {
- id, _, err := robustio.GetFileID(f.Name())
- if err != nil {
- return err
- }
- if _, hasId := paths[id]; !hasId {
- paths[id] = f.Name()
- editsByAction[id] = make(map[*action][]diff.Edit)
- }
- editsByAction[id][act] = edits
- }
- return nil
- }
-
- if err := visitAll(roots); err != nil {
- return err
- }
-
- // Validate and group the edits to each actual file.
- editsByPath := make(map[string][]diff.Edit)
- for id, actToEdits := range editsByAction {
- path := paths[id]
- actions := make([]*action, 0, len(actToEdits))
- for act := range actToEdits {
- actions = append(actions, act)
- }
-
- // Does any action create conflicting edits?
- for _, act := range actions {
- edits := actToEdits[act]
- if _, invalid := validateEdits(edits); invalid > 0 {
- name, x, y := act.a.Name, edits[invalid-1], edits[invalid]
- return diff3Conflict(path, name, name, []diff.Edit{x}, []diff.Edit{y})
- }
- }
-
- // Does any pair of different actions create edits that conflict?
- for j := range actions {
- for k := range actions[:j] {
- x, y := actions[j], actions[k]
- if x.a.Name > y.a.Name {
- x, y = y, x
- }
- xedits, yedits := actToEdits[x], actToEdits[y]
- combined := append(xedits, yedits...)
- if _, invalid := validateEdits(combined); invalid > 0 {
- // TODO: consider applying each action's consistent list of edits entirely,
- // and then using a three-way merge (such as GNU diff3) on the resulting
- // files to report more precisely the parts that actually conflict.
- return diff3Conflict(path, x.a.Name, y.a.Name, xedits, yedits)
- }
- }
- }
-
- var edits []diff.Edit
- for act := range actToEdits {
- edits = append(edits, actToEdits[act]...)
- }
- editsByPath[path], _ = validateEdits(edits) // remove duplicates. already validated.
- }
-
- // Now we've got a set of valid edits for each file. Apply them.
- for path, edits := range editsByPath {
- // TODO(adonovan): this should really work on the same
- // gulp from the file system that fed the analyzer (see #62292).
- contents, err := os.ReadFile(path)
- if err != nil {
- return err
- }
-
- out, err := diff.ApplyBytes(contents, edits)
- if err != nil {
- return err
- }
-
- // Try to format the file.
- if formatted, err := format.Source(out); err == nil {
- out = formatted
- }
-
- if err := os.WriteFile(path, out, 0644); err != nil {
- return err
- }
- }
- return nil
-}
-
-// validateEdits returns a list of edits that is sorted and
-// contains no duplicate edits. Returns the index of some
-// overlapping adjacent edits if there is one and <0 if the
-// edits are valid.
-func validateEdits(edits []diff.Edit) ([]diff.Edit, int) {
- if len(edits) == 0 {
- return nil, -1
- }
- equivalent := func(x, y diff.Edit) bool {
- return x.Start == y.Start && x.End == y.End && x.New == y.New
- }
- diff.SortEdits(edits)
- unique := []diff.Edit{edits[0]}
- invalid := -1
- for i := 1; i < len(edits); i++ {
- prev, cur := edits[i-1], edits[i]
- // We skip over equivalent edits without considering them
- // an error. This handles identical edits coming from the
- // multiple ways of loading a package into a
- // *go/packages.Packages for testing, e.g. packages "p" and "p [p.test]".
- if !equivalent(prev, cur) {
- unique = append(unique, cur)
- if prev.End > cur.Start {
- invalid = i
- }
- }
- }
- return unique, invalid
-}
-
-// diff3Conflict returns an error describing two conflicting sets of
-// edits on a file at path.
-func diff3Conflict(path string, xlabel, ylabel string, xedits, yedits []diff.Edit) error {
- contents, err := os.ReadFile(path)
- if err != nil {
- return err
- }
- oldlabel, old := "base", string(contents)
-
- xdiff, err := diff.ToUnified(oldlabel, xlabel, old, xedits, diff.DefaultContextLines)
- if err != nil {
- return err
- }
- ydiff, err := diff.ToUnified(oldlabel, ylabel, old, yedits, diff.DefaultContextLines)
- if err != nil {
- return err
- }
-
- return fmt.Errorf("conflicting edits from %s and %s on %s\nfirst edits:\n%s\nsecond edits:\n%s",
- xlabel, ylabel, path, xdiff, ydiff)
-}
-
-// printDiagnostics prints the diagnostics for the root packages in either
-// plain text or JSON format. JSON format also includes errors for any
-// dependencies.
-//
-// It returns the exitcode: in plain mode, 0 for success, 1 for analysis
-// errors, and 3 for diagnostics. We avoid 2 since the flag package uses
-// it. JSON mode always succeeds at printing errors and diagnostics in a
-// structured form to stdout.
-func printDiagnostics(roots []*action) (exitcode int) {
- // Print the output.
- //
- // Print diagnostics only for root packages,
- // but errors for all packages.
- printed := make(map[*action]bool)
- var print func(*action)
- var visitAll func(actions []*action)
- visitAll = func(actions []*action) {
- for _, act := range actions {
- if !printed[act] {
- printed[act] = true
- visitAll(act.deps)
- print(act)
- }
- }
- }
-
- if analysisflags.JSON {
- // JSON output
- tree := make(analysisflags.JSONTree)
- print = func(act *action) {
- var diags []analysis.Diagnostic
- if act.isroot {
- diags = act.diagnostics
- }
- tree.Add(act.pkg.Fset, act.pkg.ID, act.a.Name, diags, act.err)
- }
- visitAll(roots)
- tree.Print()
- } else {
- // plain text output
-
- // De-duplicate diagnostics by position (not token.Pos) to
- // avoid double-reporting in source files that belong to
- // multiple packages, such as foo and foo.test.
- type key struct {
- pos token.Position
- end token.Position
- *analysis.Analyzer
- message string
- }
- seen := make(map[key]bool)
-
- print = func(act *action) {
- if act.err != nil {
- fmt.Fprintf(os.Stderr, "%s: %v\n", act.a.Name, act.err)
- exitcode = 1 // analysis failed, at least partially
- return
- }
- if act.isroot {
- for _, diag := range act.diagnostics {
- // We don't display a.Name/f.Category
- // as most users don't care.
-
- posn := act.pkg.Fset.Position(diag.Pos)
- end := act.pkg.Fset.Position(diag.End)
- k := key{posn, end, act.a, diag.Message}
- if seen[k] {
- continue // duplicate
- }
- seen[k] = true
-
- analysisflags.PrintPlain(act.pkg.Fset, diag)
- }
- }
- }
- visitAll(roots)
-
- if exitcode == 0 && len(seen) > 0 {
- exitcode = 3 // successfully produced diagnostics
- }
- }
-
- // Print timing info.
- if dbg('t') {
- if !dbg('p') {
- log.Println("Warning: times are mostly GC/scheduler noise; use -debug=tp to disable parallelism")
- }
- var all []*action
- var total time.Duration
- for act := range printed {
- all = append(all, act)
- total += act.duration
- }
- sort.Slice(all, func(i, j int) bool {
- return all[i].duration > all[j].duration
- })
-
- // Print actions accounting for 90% of the total.
- var sum time.Duration
- for _, act := range all {
- fmt.Fprintf(os.Stderr, "%s\t%s\n", act.duration, act)
- sum += act.duration
- if sum >= total*9/10 {
- break
- }
- }
- }
-
- return exitcode
-}
-
-// needFacts reports whether any analysis required by the specified set
-// needs facts. If so, we must load the entire program from source.
-func needFacts(analyzers []*analysis.Analyzer) bool {
- seen := make(map[*analysis.Analyzer]bool)
- var q []*analysis.Analyzer // for BFS
- q = append(q, analyzers...)
- for len(q) > 0 {
- a := q[0]
- q = q[1:]
- if !seen[a] {
- seen[a] = true
- if len(a.FactTypes) > 0 {
- return true
- }
- q = append(q, a.Requires...)
- }
- }
- return false
-}
-
-// An action represents one unit of analysis work: the application of
-// one analysis to one package. Actions form a DAG, both within a
-// package (as different analyzers are applied, either in sequence or
-// parallel), and across packages (as dependencies are analyzed).
-type action struct {
- once sync.Once
- a *analysis.Analyzer
- pkg *packages.Package
- pass *analysis.Pass
- isroot bool
- deps []*action
- objectFacts map[objectFactKey]analysis.Fact
- packageFacts map[packageFactKey]analysis.Fact
- result interface{}
- diagnostics []analysis.Diagnostic
- err error
- duration time.Duration
-}
-
-type objectFactKey struct {
- obj types.Object
- typ reflect.Type
-}
-
-type packageFactKey struct {
- pkg *types.Package
- typ reflect.Type
-}
-
-func (act *action) String() string {
- return fmt.Sprintf("%s@%s", act.a, act.pkg)
-}
-
-func execAll(actions []*action) {
- sequential := dbg('p')
- var wg sync.WaitGroup
- for _, act := range actions {
- wg.Add(1)
- work := func(act *action) {
- act.exec()
- wg.Done()
- }
- if sequential {
- work(act)
- } else {
- go work(act)
- }
- }
- wg.Wait()
-}
-
-func (act *action) exec() { act.once.Do(act.execOnce) }
-
-func (act *action) execOnce() {
- // Analyze dependencies.
- execAll(act.deps)
-
- // TODO(adonovan): uncomment this during profiling.
- // It won't build pre-go1.11 but conditional compilation
- // using build tags isn't warranted.
- //
- // ctx, task := trace.NewTask(context.Background(), "exec")
- // trace.Log(ctx, "pass", act.String())
- // defer task.End()
-
- // Record time spent in this node but not its dependencies.
- // In parallel mode, due to GC/scheduler contention, the
- // time is 5x higher than in sequential mode, even with a
- // semaphore limiting the number of threads here.
- // So use -debug=tp.
- if dbg('t') {
- t0 := time.Now()
- defer func() { act.duration = time.Since(t0) }()
- }
-
- // Report an error if any dependency failed.
- var failed []string
- for _, dep := range act.deps {
- if dep.err != nil {
- failed = append(failed, dep.String())
- }
- }
- if failed != nil {
- sort.Strings(failed)
- act.err = fmt.Errorf("failed prerequisites: %s", strings.Join(failed, ", "))
- return
- }
-
- // Plumb the output values of the dependencies
- // into the inputs of this action. Also facts.
- inputs := make(map[*analysis.Analyzer]interface{})
- act.objectFacts = make(map[objectFactKey]analysis.Fact)
- act.packageFacts = make(map[packageFactKey]analysis.Fact)
- for _, dep := range act.deps {
- if dep.pkg == act.pkg {
- // Same package, different analysis (horizontal edge):
- // in-memory outputs of prerequisite analyzers
- // become inputs to this analysis pass.
- inputs[dep.a] = dep.result
-
- } else if dep.a == act.a { // (always true)
- // Same analysis, different package (vertical edge):
- // serialized facts produced by prerequisite analysis
- // become available to this analysis pass.
- inheritFacts(act, dep)
- }
- }
-
- module := &analysis.Module{} // possibly empty (non nil) in go/analysis drivers.
- if mod := act.pkg.Module; mod != nil {
- module.Path = mod.Path
- module.Version = mod.Version
- module.GoVersion = mod.GoVersion
- }
-
- // Run the analysis.
- pass := &analysis.Pass{
- Analyzer: act.a,
- Fset: act.pkg.Fset,
- Files: act.pkg.Syntax,
- OtherFiles: act.pkg.OtherFiles,
- IgnoredFiles: act.pkg.IgnoredFiles,
- Pkg: act.pkg.Types,
- TypesInfo: act.pkg.TypesInfo,
- TypesSizes: act.pkg.TypesSizes,
- TypeErrors: act.pkg.TypeErrors,
- Module: module,
-
- ResultOf: inputs,
- Report: func(d analysis.Diagnostic) { act.diagnostics = append(act.diagnostics, d) },
- ImportObjectFact: act.importObjectFact,
- ExportObjectFact: act.exportObjectFact,
- ImportPackageFact: act.importPackageFact,
- ExportPackageFact: act.exportPackageFact,
- AllObjectFacts: act.allObjectFacts,
- AllPackageFacts: act.allPackageFacts,
- }
- pass.ReadFile = analysisinternal.MakeReadFile(pass)
- act.pass = pass
-
- var err error
- if act.pkg.IllTyped && !pass.Analyzer.RunDespiteErrors {
- err = fmt.Errorf("analysis skipped due to errors in package")
- } else {
- act.result, err = pass.Analyzer.Run(pass)
- if err == nil {
- if got, want := reflect.TypeOf(act.result), pass.Analyzer.ResultType; got != want {
- err = fmt.Errorf(
- "internal error: on package %s, analyzer %s returned a result of type %v, but declared ResultType %v",
- pass.Pkg.Path(), pass.Analyzer, got, want)
- }
- }
- }
- if err == nil { // resolve diagnostic URLs
- for i := range act.diagnostics {
- if url, uerr := analysisflags.ResolveURL(act.a, act.diagnostics[i]); uerr == nil {
- act.diagnostics[i].URL = url
- } else {
- err = uerr // keep the last error
- }
- }
- }
- act.err = err
-
- // disallow calls after Run
- pass.ExportObjectFact = nil
- pass.ExportPackageFact = nil
-}
-
-// inheritFacts populates act.facts with
-// those it obtains from its dependency, dep.
-func inheritFacts(act, dep *action) {
- serialize := dbg('s')
-
- for key, fact := range dep.objectFacts {
- // Filter out facts related to objects
- // that are irrelevant downstream
- // (equivalently: not in the compiler export data).
- if !exportedFrom(key.obj, dep.pkg.Types) {
- if false {
- log.Printf("%v: discarding %T fact from %s for %s: %s", act, fact, dep, key.obj, fact)
- }
- continue
- }
-
- // Optionally serialize/deserialize fact
- // to verify that it works across address spaces.
- if serialize {
- encodedFact, err := codeFact(fact)
- if err != nil {
- log.Panicf("internal error: encoding of %T fact failed in %v: %v", fact, act, err)
- }
- fact = encodedFact
- }
-
- if false {
- log.Printf("%v: inherited %T fact for %s: %s", act, fact, key.obj, fact)
- }
- act.objectFacts[key] = fact
- }
-
- for key, fact := range dep.packageFacts {
- // TODO: filter out facts that belong to
- // packages not mentioned in the export data
- // to prevent side channels.
-
- // Optionally serialize/deserialize fact
- // to verify that it works across address spaces
- // and is deterministic.
- if serialize {
- encodedFact, err := codeFact(fact)
- if err != nil {
- log.Panicf("internal error: encoding of %T fact failed in %v", fact, act)
- }
- fact = encodedFact
- }
-
- if false {
- log.Printf("%v: inherited %T fact for %s: %s", act, fact, key.pkg.Path(), fact)
- }
- act.packageFacts[key] = fact
- }
-}
-
-// codeFact encodes then decodes a fact,
-// just to exercise that logic.
-func codeFact(fact analysis.Fact) (analysis.Fact, error) {
- // We encode facts one at a time.
- // A real modular driver would emit all facts
- // into one encoder to improve gob efficiency.
- var buf bytes.Buffer
- if err := gob.NewEncoder(&buf).Encode(fact); err != nil {
- return nil, err
- }
-
- // Encode it twice and assert that we get the same bits.
- // This helps detect nondeterministic Gob encoding (e.g. of maps).
- var buf2 bytes.Buffer
- if err := gob.NewEncoder(&buf2).Encode(fact); err != nil {
- return nil, err
- }
- if !bytes.Equal(buf.Bytes(), buf2.Bytes()) {
- return nil, fmt.Errorf("encoding of %T fact is nondeterministic", fact)
- }
-
- new := reflect.New(reflect.TypeOf(fact).Elem()).Interface().(analysis.Fact)
- if err := gob.NewDecoder(&buf).Decode(new); err != nil {
- return nil, err
- }
- return new, nil
-}
-
-// exportedFrom reports whether obj may be visible to a package that imports pkg.
-// This includes not just the exported members of pkg, but also unexported
-// constants, types, fields, and methods, perhaps belonging to other packages,
-// that find there way into the API.
-// This is an overapproximation of the more accurate approach used by
-// gc export data, which walks the type graph, but it's much simpler.
-//
-// TODO(adonovan): do more accurate filtering by walking the type graph.
-func exportedFrom(obj types.Object, pkg *types.Package) bool {
- switch obj := obj.(type) {
- case *types.Func:
- return obj.Exported() && obj.Pkg() == pkg ||
- obj.Type().(*types.Signature).Recv() != nil
- case *types.Var:
- if obj.IsField() {
- return true
- }
- // we can't filter more aggressively than this because we need
- // to consider function parameters exported, but have no way
- // of telling apart function parameters from local variables.
- return obj.Pkg() == pkg
- case *types.TypeName, *types.Const:
- return true
- }
- return false // Nil, Builtin, Label, or PkgName
-}
-
-// importObjectFact implements Pass.ImportObjectFact.
-// Given a non-nil pointer ptr of type *T, where *T satisfies Fact,
-// importObjectFact copies the fact value to *ptr.
-func (act *action) importObjectFact(obj types.Object, ptr analysis.Fact) bool {
- if obj == nil {
- panic("nil object")
- }
- key := objectFactKey{obj, factType(ptr)}
- if v, ok := act.objectFacts[key]; ok {
- reflect.ValueOf(ptr).Elem().Set(reflect.ValueOf(v).Elem())
- return true
- }
- return false
-}
-
-// exportObjectFact implements Pass.ExportObjectFact.
-func (act *action) exportObjectFact(obj types.Object, fact analysis.Fact) {
- if act.pass.ExportObjectFact == nil {
- log.Panicf("%s: Pass.ExportObjectFact(%s, %T) called after Run", act, obj, fact)
- }
-
- if obj.Pkg() != act.pkg.Types {
- log.Panicf("internal error: in analysis %s of package %s: Fact.Set(%s, %T): can't set facts on objects belonging another package",
- act.a, act.pkg, obj, fact)
- }
-
- key := objectFactKey{obj, factType(fact)}
- act.objectFacts[key] = fact // clobber any existing entry
- if dbg('f') {
- objstr := types.ObjectString(obj, (*types.Package).Name)
- fmt.Fprintf(os.Stderr, "%s: object %s has fact %s\n",
- act.pkg.Fset.Position(obj.Pos()), objstr, fact)
- }
-}
-
-// allObjectFacts implements Pass.AllObjectFacts.
-func (act *action) allObjectFacts() []analysis.ObjectFact {
- facts := make([]analysis.ObjectFact, 0, len(act.objectFacts))
- for k := range act.objectFacts {
- facts = append(facts, analysis.ObjectFact{Object: k.obj, Fact: act.objectFacts[k]})
- }
- return facts
-}
-
-// importPackageFact implements Pass.ImportPackageFact.
-// Given a non-nil pointer ptr of type *T, where *T satisfies Fact,
-// fact copies the fact value to *ptr.
-func (act *action) importPackageFact(pkg *types.Package, ptr analysis.Fact) bool {
- if pkg == nil {
- panic("nil package")
- }
- key := packageFactKey{pkg, factType(ptr)}
- if v, ok := act.packageFacts[key]; ok {
- reflect.ValueOf(ptr).Elem().Set(reflect.ValueOf(v).Elem())
- return true
- }
- return false
-}
-
-// exportPackageFact implements Pass.ExportPackageFact.
-func (act *action) exportPackageFact(fact analysis.Fact) {
- if act.pass.ExportPackageFact == nil {
- log.Panicf("%s: Pass.ExportPackageFact(%T) called after Run", act, fact)
- }
-
- key := packageFactKey{act.pass.Pkg, factType(fact)}
- act.packageFacts[key] = fact // clobber any existing entry
- if dbg('f') {
- fmt.Fprintf(os.Stderr, "%s: package %s has fact %s\n",
- act.pkg.Fset.Position(act.pass.Files[0].Pos()), act.pass.Pkg.Path(), fact)
- }
-}
-
-func factType(fact analysis.Fact) reflect.Type {
- t := reflect.TypeOf(fact)
- if t.Kind() != reflect.Ptr {
- log.Fatalf("invalid Fact type: got %T, want pointer", fact)
- }
- return t
-}
-
-// allPackageFacts implements Pass.AllPackageFacts.
-func (act *action) allPackageFacts() []analysis.PackageFact {
- facts := make([]analysis.PackageFact, 0, len(act.packageFacts))
- for k := range act.packageFacts {
- facts = append(facts, analysis.PackageFact{Package: k.pkg, Fact: act.packageFacts[k]})
- }
- return facts
-}
-
-func dbg(b byte) bool { return strings.IndexByte(Debug, b) >= 0 }
diff --git a/vendor/golang.org/x/tools/go/analysis/internal/internal.go b/vendor/golang.org/x/tools/go/analysis/internal/internal.go
new file mode 100644
index 000000000..e7c8247fd
--- /dev/null
+++ b/vendor/golang.org/x/tools/go/analysis/internal/internal.go
@@ -0,0 +1,12 @@
+// Copyright 2023 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 internal
+
+import "golang.org/x/tools/go/analysis"
+
+// This function is set by the checker package to provide
+// backdoor access to the private Pass field
+// of the checker.Action type, for use by analysistest.
+var Pass func(interface{}) *analysis.Pass
diff --git a/vendor/golang.org/x/tools/go/analysis/passes/buildtag/buildtag.go b/vendor/golang.org/x/tools/go/analysis/passes/buildtag/buildtag.go
index b5a2d2775..e7434e8fe 100644
--- a/vendor/golang.org/x/tools/go/analysis/passes/buildtag/buildtag.go
+++ b/vendor/golang.org/x/tools/go/analysis/passes/buildtag/buildtag.go
@@ -15,7 +15,6 @@ import (
"golang.org/x/tools/go/analysis"
"golang.org/x/tools/go/analysis/passes/internal/analysisutil"
- "golang.org/x/tools/internal/versions"
)
const Doc = "check //go:build and // +build directives"
@@ -371,11 +370,6 @@ func (check *checker) finish() {
// tags reports issues in go versions in tags within the expression e.
func (check *checker) tags(pos token.Pos, e constraint.Expr) {
- // Check that constraint.GoVersion is meaningful (>= go1.21).
- if versions.ConstraintGoVersion == nil {
- return
- }
-
// Use Eval to visit each tag.
_ = e.Eval(func(tag string) bool {
if malformedGoTag(tag) {
@@ -393,10 +387,8 @@ func malformedGoTag(tag string) bool {
// Check for close misspellings of the "go1." prefix.
for _, pre := range []string{"go.", "g1.", "go"} {
suffix := strings.TrimPrefix(tag, pre)
- if suffix != tag {
- if valid, ok := validTag("go1." + suffix); ok && valid {
- return true
- }
+ if suffix != tag && validGoVersion("go1."+suffix) {
+ return true
}
}
return false
@@ -404,15 +396,10 @@ func malformedGoTag(tag string) bool {
// The tag starts with "go1" so it is almost certainly a GoVersion.
// Report it if it is not a valid build constraint.
- valid, ok := validTag(tag)
- return ok && !valid
+ return !validGoVersion(tag)
}
-// validTag returns (valid, ok) where valid reports when a tag is valid,
-// and ok reports determining if the tag is valid succeeded.
-func validTag(tag string) (valid bool, ok bool) {
- if versions.ConstraintGoVersion != nil {
- return versions.ConstraintGoVersion(&constraint.TagExpr{Tag: tag}) != "", true
- }
- return false, false
+// validGoVersion reports when a tag is a valid go version.
+func validGoVersion(tag string) bool {
+ return constraint.GoVersion(&constraint.TagExpr{Tag: tag}) != ""
}
diff --git a/vendor/golang.org/x/tools/go/analysis/passes/printf/printf.go b/vendor/golang.org/x/tools/go/analysis/passes/printf/printf.go
index 2d79d0b03..171ad2013 100644
--- a/vendor/golang.org/x/tools/go/analysis/passes/printf/printf.go
+++ b/vendor/golang.org/x/tools/go/analysis/passes/printf/printf.go
@@ -433,6 +433,9 @@ func printfNameAndKind(pass *analysis.Pass, call *ast.CallExpr) (fn *types.Func,
return nil, 0
}
+ // Facts are associated with generic declarations, not instantiations.
+ fn = fn.Origin()
+
_, ok := isPrint[fn.FullName()]
if !ok {
// Next look up just "printf", for use with -printf.funcs.
diff --git a/vendor/golang.org/x/tools/go/analysis/passes/structtag/structtag.go b/vendor/golang.org/x/tools/go/analysis/passes/structtag/structtag.go
index a0beb46bd..4115ef769 100644
--- a/vendor/golang.org/x/tools/go/analysis/passes/structtag/structtag.go
+++ b/vendor/golang.org/x/tools/go/analysis/passes/structtag/structtag.go
@@ -89,7 +89,7 @@ var checkTagSpaces = map[string]bool{"json": true, "xml": true, "asn1": true}
// checkCanonicalFieldTag checks a single struct field tag.
func checkCanonicalFieldTag(pass *analysis.Pass, field *types.Var, tag string, seen *namesSeen) {
switch pass.Pkg.Path() {
- case "encoding/json", "encoding/xml":
+ case "encoding/json", "encoding/json/v2", "encoding/xml":
// These packages know how to use their own APIs.
// Sometimes they are testing what happens to incorrect programs.
return
diff --git a/vendor/golang.org/x/tools/go/ast/inspector/inspector.go b/vendor/golang.org/x/tools/go/ast/inspector/inspector.go
index 958cf38de..cfda89343 100644
--- a/vendor/golang.org/x/tools/go/ast/inspector/inspector.go
+++ b/vendor/golang.org/x/tools/go/ast/inspector/inspector.go
@@ -36,6 +36,7 @@ package inspector
import (
"go/ast"
+ _ "unsafe"
)
// An Inspector provides methods for inspecting
@@ -44,6 +45,9 @@ type Inspector struct {
events []event
}
+//go:linkname events
+func events(in *Inspector) []event { return in.events }
+
// New returns an Inspector for the specified syntax trees.
func New(files []*ast.File) *Inspector {
return &Inspector{traverse(files)}
@@ -52,9 +56,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 (defined for push nodes only)
}
// TODO: Experiment with storing only the second word of event.node (unsafe.Pointer).
@@ -83,7 +88,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 +118,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 +152,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
@@ -196,18 +201,24 @@ func traverse(files []*ast.File) []event {
events := make([]event, 0, capacity)
var stack []event
- stack = append(stack, event{}) // include an extra event so file nodes have a parent
+ stack = append(stack, event{index: -1}) // 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
+ node: n,
+ typ: 0, // temporarily used to accumulate type bits of subtree
+ index: int32(len(events)), // push event temporarily holds own index
+ parent: stack[len(stack)-1].index,
}
stack = append(stack, ev)
events = append(events, ev)
+
+ // 2B nodes ought to be enough for anyone!
+ if int32(len(events)) < 0 {
+ panic("event index exceeded int32")
+ }
} else {
// pop
top := len(stack) - 1
@@ -216,9 +227,9 @@ func traverse(files []*ast.File) []event {
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
+ 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 = int32(len(events)) // make push refer to pop
stack = stack[:top]
events = append(events, ev)
diff --git a/vendor/golang.org/x/tools/go/ast/inspector/iter.go b/vendor/golang.org/x/tools/go/ast/inspector/iter.go
index b7e959114..c576dc70a 100644
--- a/vendor/golang.org/x/tools/go/ast/inspector/iter.go
+++ b/vendor/golang.org/x/tools/go/ast/inspector/iter.go
@@ -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
diff --git a/vendor/golang.org/x/tools/go/ast/inspector/typeof.go b/vendor/golang.org/x/tools/go/ast/inspector/typeof.go
index 2a872f89d..40b1bfd7e 100644
--- a/vendor/golang.org/x/tools/go/ast/inspector/typeof.go
+++ b/vendor/golang.org/x/tools/go/ast/inspector/typeof.go
@@ -12,6 +12,8 @@ package inspector
import (
"go/ast"
"math"
+
+ _ "unsafe"
)
const (
@@ -215,6 +217,7 @@ func typeOf(n ast.Node) uint64 {
return 0
}
+//go:linkname maskOf
func maskOf(nodes []ast.Node) uint64 {
if nodes == nil {
return math.MaxUint64 // match all node types
diff --git a/vendor/golang.org/x/tools/go/gcexportdata/gcexportdata.go b/vendor/golang.org/x/tools/go/gcexportdata/gcexportdata.go
index f3ab0a2e1..65fe2628e 100644
--- a/vendor/golang.org/x/tools/go/gcexportdata/gcexportdata.go
+++ b/vendor/golang.org/x/tools/go/gcexportdata/gcexportdata.go
@@ -106,24 +106,18 @@ func Find(importPath, srcDir string) (filename, path string) {
// additional trailing data beyond the end of the export data.
func NewReader(r io.Reader) (io.Reader, error) {
buf := bufio.NewReader(r)
- _, size, err := gcimporter.FindExportData(buf)
+ size, err := gcimporter.FindExportData(buf)
if err != nil {
return nil, err
}
- if size >= 0 {
- // We were given an archive and found the __.PKGDEF in it.
- // This tells us the size of the export data, and we don't
- // need to return the entire file.
- return &io.LimitedReader{
- R: buf,
- N: size,
- }, nil
- } else {
- // We were given an object file. As such, we don't know how large
- // the export data is and must return the entire file.
- return buf, nil
- }
+ // We were given an archive and found the __.PKGDEF in it.
+ // This tells us the size of the export data, and we don't
+ // need to return the entire file.
+ return &io.LimitedReader{
+ R: buf,
+ N: size,
+ }, nil
}
// readAll works the same way as io.ReadAll, but avoids allocations and copies
diff --git a/vendor/golang.org/x/tools/go/packages/external.go b/vendor/golang.org/x/tools/go/packages/external.go
index 96db9daf3..91bd62e83 100644
--- a/vendor/golang.org/x/tools/go/packages/external.go
+++ b/vendor/golang.org/x/tools/go/packages/external.go
@@ -13,6 +13,7 @@ import (
"fmt"
"os"
"os/exec"
+ "slices"
"strings"
)
@@ -131,7 +132,7 @@ func findExternalDriver(cfg *Config) driver {
// command.
//
// (See similar trick in Invocation.run in ../../internal/gocommand/invoke.go)
- cmd.Env = append(slicesClip(cfg.Env), "PWD="+cfg.Dir)
+ cmd.Env = append(slices.Clip(cfg.Env), "PWD="+cfg.Dir)
cmd.Stdin = bytes.NewReader(req)
cmd.Stdout = buf
cmd.Stderr = stderr
@@ -150,7 +151,3 @@ func findExternalDriver(cfg *Config) driver {
return &response, nil
}
}
-
-// slicesClip removes unused capacity from the slice, returning s[:len(s):len(s)].
-// TODO(adonovan): use go1.21 slices.Clip.
-func slicesClip[S ~[]E, E any](s S) S { return s[:len(s):len(s)] }
diff --git a/vendor/golang.org/x/tools/go/packages/golist.go b/vendor/golang.org/x/tools/go/packages/golist.go
index 76f910ece..0458b4f9c 100644
--- a/vendor/golang.org/x/tools/go/packages/golist.go
+++ b/vendor/golang.org/x/tools/go/packages/golist.go
@@ -322,6 +322,7 @@ type jsonPackage struct {
ImportPath string
Dir string
Name string
+ Target string
Export string
GoFiles []string
CompiledGoFiles []string
@@ -505,13 +506,15 @@ func (state *golistState) createDriverResponse(words ...string) (*DriverResponse
pkg := &Package{
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)...),
EmbedFiles: absJoin(p.Dir, p.EmbedFiles),
EmbedPatterns: absJoin(p.Dir, p.EmbedPatterns),
IgnoredFiles: absJoin(p.Dir, p.IgnoredGoFiles, p.IgnoredOtherFiles),
- forTest: p.ForTest,
+ ForTest: p.ForTest,
depsErrors: p.DepsErrors,
Module: p.Module,
}
@@ -795,7 +798,7 @@ func jsonFlag(cfg *Config, goVersion int) string {
// Request Dir in the unlikely case Export is not absolute.
addFields("Dir", "Export")
}
- if cfg.Mode&needInternalForTest != 0 {
+ if cfg.Mode&NeedForTest != 0 {
addFields("ForTest")
}
if cfg.Mode&needInternalDepsErrors != 0 {
@@ -810,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, ",")
}
diff --git a/vendor/golang.org/x/tools/go/packages/loadmode_string.go b/vendor/golang.org/x/tools/go/packages/loadmode_string.go
index 5fcad6ea6..69eec9f44 100644
--- a/vendor/golang.org/x/tools/go/packages/loadmode_string.go
+++ b/vendor/golang.org/x/tools/go/packages/loadmode_string.go
@@ -23,9 +23,11 @@ var modes = [...]struct {
{NeedSyntax, "NeedSyntax"},
{NeedTypesInfo, "NeedTypesInfo"},
{NeedTypesSizes, "NeedTypesSizes"},
+ {NeedForTest, "NeedForTest"},
{NeedModule, "NeedModule"},
{NeedEmbedFiles, "NeedEmbedFiles"},
{NeedEmbedPatterns, "NeedEmbedPatterns"},
+ {NeedTarget, "NeedTarget"},
}
func (mode LoadMode) String() string {
diff --git a/vendor/golang.org/x/tools/go/packages/packages.go b/vendor/golang.org/x/tools/go/packages/packages.go
index 2ecc64238..0147d9080 100644
--- a/vendor/golang.org/x/tools/go/packages/packages.go
+++ b/vendor/golang.org/x/tools/go/packages/packages.go
@@ -43,6 +43,20 @@ import (
// ID and Errors (if present) will always be filled.
// [Load] may return more information than requested.
//
+// The Mode flag is a union of several bits named NeedName,
+// NeedFiles, and so on, each of which determines whether
+// a given field of Package (Name, Files, etc) should be
+// populated.
+//
+// For convenience, we provide named constants for the most
+// common combinations of Need flags:
+//
+// [LoadFiles] lists of files in each package
+// [LoadImports] ... plus imports
+// [LoadTypes] ... plus type information
+// [LoadSyntax] ... plus type-annotated syntax
+// [LoadAllSyntax] ... for all dependencies
+//
// Unfortunately there are a number of open bugs related to
// interactions among the LoadMode bits:
// - https://github.com/golang/go/issues/56633
@@ -55,7 +69,7 @@ const (
// NeedName adds Name and PkgPath.
NeedName LoadMode = 1 << iota
- // NeedFiles adds GoFiles, OtherFiles, and IgnoredFiles
+ // NeedFiles adds Dir, GoFiles, OtherFiles, and IgnoredFiles
NeedFiles
// NeedCompiledGoFiles adds CompiledGoFiles.
@@ -86,9 +100,10 @@ const (
// needInternalDepsErrors adds the internal deps errors field for use by gopls.
needInternalDepsErrors
- // needInternalForTest adds the internal forTest field.
+ // NeedForTest adds ForTest.
+ //
// Tests must also be set on the context for this field to be populated.
- needInternalForTest
+ NeedForTest
// typecheckCgo enables full support for type checking cgo. Requires Go 1.15+.
// Modifies CompiledGoFiles and Types, and has no effect on its own.
@@ -103,38 +118,26 @@ const (
// NeedEmbedPatterns adds EmbedPatterns.
NeedEmbedPatterns
+ // NeedTarget adds Target.
+ NeedTarget
+
// Be sure to update loadmode_string.go when adding new items!
)
const (
// LoadFiles loads the name and file names for the initial packages.
- //
- // Deprecated: LoadFiles exists for historical compatibility
- // and should not be used. Please directly specify the needed fields using the Need values.
LoadFiles = NeedName | NeedFiles | NeedCompiledGoFiles
// LoadImports loads the name, file names, and import mapping for the initial packages.
- //
- // Deprecated: LoadImports exists for historical compatibility
- // and should not be used. Please directly specify the needed fields using the Need values.
LoadImports = LoadFiles | NeedImports
// LoadTypes loads exported type information for the initial packages.
- //
- // Deprecated: LoadTypes exists for historical compatibility
- // and should not be used. Please directly specify the needed fields using the Need values.
LoadTypes = LoadImports | NeedTypes | NeedTypesSizes
// LoadSyntax loads typed syntax for the initial packages.
- //
- // Deprecated: LoadSyntax exists for historical compatibility
- // and should not be used. Please directly specify the needed fields using the Need values.
LoadSyntax = LoadTypes | NeedSyntax | NeedTypesInfo
// LoadAllSyntax loads typed syntax for the initial packages and all dependencies.
- //
- // Deprecated: LoadAllSyntax exists for historical compatibility
- // and should not be used. Please directly specify the needed fields using the Need values.
LoadAllSyntax = LoadSyntax | NeedDeps
// Deprecated: NeedExportsFile is a historical misspelling of NeedExportFile.
@@ -434,6 +437,12 @@ type Package struct {
// PkgPath is the package path as used by the go/types package.
PkgPath string
+ // Dir is the directory associated with the package, if it exists.
+ //
+ // For packages listed by the go command, this is the directory containing
+ // the package files.
+ Dir string
+
// Errors contains any errors encountered querying the metadata
// of the package, or while parsing or type-checking its files.
Errors []Error
@@ -473,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
@@ -521,8 +534,8 @@ type Package struct {
// -- internal --
- // forTest is the package under test, if any.
- forTest string
+ // ForTest is the package under test, if any.
+ ForTest string
// depsErrors is the DepsErrors field from the go list response, if any.
depsErrors []*packagesinternal.PackageError
@@ -551,9 +564,6 @@ type ModuleError struct {
}
func init() {
- packagesinternal.GetForTest = func(p interface{}) string {
- return p.(*Package).forTest
- }
packagesinternal.GetDepsErrors = func(p interface{}) []*packagesinternal.PackageError {
return p.(*Package).depsErrors
}
@@ -565,7 +575,6 @@ func init() {
}
packagesinternal.TypecheckCgo = int(typecheckCgo)
packagesinternal.DepsErrors = int(needInternalDepsErrors)
- packagesinternal.ForTest = int(needInternalForTest)
}
// An Error describes a problem with a package's metadata, syntax, or types.
diff --git a/vendor/golang.org/x/tools/go/ssa/const.go b/vendor/golang.org/x/tools/go/ssa/const.go
index 865329bfd..764b73529 100644
--- a/vendor/golang.org/x/tools/go/ssa/const.go
+++ b/vendor/golang.org/x/tools/go/ssa/const.go
@@ -12,9 +12,9 @@ import (
"go/token"
"go/types"
"strconv"
- "strings"
"golang.org/x/tools/internal/typeparams"
+ "golang.org/x/tools/internal/typesinternal"
)
// NewConst returns a new constant of the specified value and type.
@@ -78,7 +78,7 @@ func zeroConst(t types.Type) *Const {
func (c *Const) RelString(from *types.Package) string {
var s string
if c.Value == nil {
- s = zeroString(c.typ, from)
+ s, _ = typesinternal.ZeroString(c.typ, types.RelativeTo(from))
} else if c.Value.Kind() == constant.String {
s = constant.StringVal(c.Value)
const max = 20
@@ -93,44 +93,6 @@ func (c *Const) RelString(from *types.Package) string {
return s + ":" + relType(c.Type(), from)
}
-// zeroString returns the string representation of the "zero" value of the type t.
-func zeroString(t types.Type, from *types.Package) string {
- switch t := t.(type) {
- case *types.Basic:
- switch {
- case t.Info()&types.IsBoolean != 0:
- return "false"
- case t.Info()&types.IsNumeric != 0:
- return "0"
- case t.Info()&types.IsString != 0:
- return `""`
- case t.Kind() == types.UnsafePointer:
- fallthrough
- case t.Kind() == types.UntypedNil:
- return "nil"
- default:
- panic(fmt.Sprint("zeroString for unexpected type:", t))
- }
- case *types.Pointer, *types.Slice, *types.Interface, *types.Chan, *types.Map, *types.Signature:
- return "nil"
- case *types.Named, *types.Alias:
- return zeroString(t.Underlying(), from)
- case *types.Array, *types.Struct:
- return relType(t, from) + "{}"
- case *types.Tuple:
- // Tuples are not normal values.
- // We are currently format as "(t[0], ..., t[n])". Could be something else.
- components := make([]string, t.Len())
- for i := 0; i < t.Len(); i++ {
- components[i] = zeroString(t.At(i).Type(), from)
- }
- return "(" + strings.Join(components, ", ") + ")"
- case *types.TypeParam:
- return "*new(" + relType(t, from) + ")"
- }
- panic(fmt.Sprint("zeroString: unexpected ", t))
-}
-
func (c *Const) Name() string {
return c.RelString(nil)
}
diff --git a/vendor/golang.org/x/tools/go/ssa/dom.go b/vendor/golang.org/x/tools/go/ssa/dom.go
index 02c1ae83a..f49098614 100644
--- a/vendor/golang.org/x/tools/go/ssa/dom.go
+++ b/vendor/golang.org/x/tools/go/ssa/dom.go
@@ -318,6 +318,7 @@ func printDomTreeText(buf *bytes.Buffer, v *BasicBlock, indent int) {
// printDomTreeDot prints the dominator tree of f in AT&T GraphViz
// (.dot) format.
+// (unused; retained for debugging)
func printDomTreeDot(buf *bytes.Buffer, f *Function) {
fmt.Fprintln(buf, "//", f)
fmt.Fprintln(buf, "digraph domtree {")
diff --git a/vendor/golang.org/x/tools/go/ssa/util.go b/vendor/golang.org/x/tools/go/ssa/util.go
index cdc46209e..aa070eacd 100644
--- a/vendor/golang.org/x/tools/go/ssa/util.go
+++ b/vendor/golang.org/x/tools/go/ssa/util.go
@@ -14,6 +14,7 @@ import (
"io"
"os"
"sync"
+ _ "unsafe" // for go:linkname hack
"golang.org/x/tools/go/types/typeutil"
"golang.org/x/tools/internal/typeparams"
@@ -408,14 +409,6 @@ func (canon *canonizer) instantiateMethod(m *types.Func, targs []types.Type, ctx
}
// Exposed to ssautil using the linkname hack.
+//
+//go:linkname isSyntactic golang.org/x/tools/go/ssa.isSyntactic
func isSyntactic(pkg *Package) bool { return pkg.syntax }
-
-// mapValues returns a new unordered array of map values.
-func mapValues[K comparable, V any](m map[K]V) []V {
- vals := make([]V, 0, len(m))
- for _, fn := range m {
- vals = append(vals, fn)
- }
- return vals
-
-}
diff --git a/vendor/golang.org/x/tools/go/types/typeutil/map.go b/vendor/golang.org/x/tools/go/types/typeutil/map.go
index 8d824f714..93b3090c6 100644
--- a/vendor/golang.org/x/tools/go/types/typeutil/map.go
+++ b/vendor/golang.org/x/tools/go/types/typeutil/map.go
@@ -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.
-//
-// 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.
+// SetHasher has no effect.
//
-// 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
-
-// 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
-}
+// -- Hasher --
-// MakeHasher returns a new Hasher instance.
-func MakeHasher() Hasher {
- return Hasher{
- memo: make(map[types.Type]uint32),
- ptrMap: make(map[any]uint32),
- sigTParams: nil,
- }
+// 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)
}
+// 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,11 @@ 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,
- }
- }
-
- for i := 0; i < tparams.Len(); i++ {
+ for i := range tparams.Len() {
+ h.inGenericSig = true
tparam := tparams.At(i)
- hash += 7 * h.Hash(tparam.Constraint())
+ hash += 7 * h.hash(tparam.Constraint())
}
return hash + 3*h.hashTuple(t.Params()) + 5*h.hashTuple(t.Results())
@@ -350,17 +294,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 +318,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 +339,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 +352,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 +404,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 +425,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 +458,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))
}
diff --git a/vendor/golang.org/x/tools/internal/analysisinternal/analysis.go b/vendor/golang.org/x/tools/internal/analysisinternal/analysis.go
index 4ccaa210a..58615232f 100644
--- a/vendor/golang.org/x/tools/internal/analysisinternal/analysis.go
+++ b/vendor/golang.org/x/tools/internal/analysisinternal/analysis.go
@@ -15,7 +15,6 @@ import (
"go/types"
"os"
pathpkg "path"
- "strconv"
"golang.org/x/tools/go/analysis"
)
@@ -66,264 +65,6 @@ func TypeErrorEndPos(fset *token.FileSet, src []byte, start token.Pos) token.Pos
return end
}
-func ZeroValue(f *ast.File, pkg *types.Package, typ types.Type) ast.Expr {
- // TODO(adonovan): think about generics, and also generic aliases.
- under := types.Unalias(typ)
- // Don't call Underlying unconditionally: although it removes
- // Named and Alias, it also removes TypeParam.
- if n, ok := under.(*types.Named); ok {
- under = n.Underlying()
- }
- switch under := under.(type) {
- case *types.Basic:
- switch {
- case under.Info()&types.IsNumeric != 0:
- return &ast.BasicLit{Kind: token.INT, Value: "0"}
- case under.Info()&types.IsBoolean != 0:
- return &ast.Ident{Name: "false"}
- case under.Info()&types.IsString != 0:
- return &ast.BasicLit{Kind: token.STRING, Value: `""`}
- default:
- panic(fmt.Sprintf("unknown basic type %v", under))
- }
- case *types.Chan, *types.Interface, *types.Map, *types.Pointer, *types.Signature, *types.Slice, *types.Array:
- return ast.NewIdent("nil")
- case *types.Struct:
- texpr := TypeExpr(f, pkg, typ) // typ because we want the name here.
- if texpr == nil {
- return nil
- }
- return &ast.CompositeLit{
- Type: texpr,
- }
- }
- return nil
-}
-
-// IsZeroValue checks whether the given expression is a 'zero value' (as determined by output of
-// analysisinternal.ZeroValue)
-func IsZeroValue(expr ast.Expr) bool {
- switch e := expr.(type) {
- case *ast.BasicLit:
- return e.Value == "0" || e.Value == `""`
- case *ast.Ident:
- return e.Name == "nil" || e.Name == "false"
- default:
- return false
- }
-}
-
-// 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.
-func TypeExpr(f *ast.File, pkg *types.Package, typ types.Type) ast.Expr {
- switch t := typ.(type) {
- case *types.Basic:
- switch t.Kind() {
- case types.UnsafePointer:
- return &ast.SelectorExpr{X: ast.NewIdent("unsafe"), Sel: ast.NewIdent("Pointer")}
- default:
- return ast.NewIdent(t.Name())
- }
- case *types.Pointer:
- x := TypeExpr(f, pkg, t.Elem())
- if x == nil {
- return nil
- }
- return &ast.UnaryExpr{
- Op: token.MUL,
- X: x,
- }
- case *types.Array:
- elt := TypeExpr(f, pkg, t.Elem())
- if elt == nil {
- return nil
- }
- return &ast.ArrayType{
- Len: &ast.BasicLit{
- Kind: token.INT,
- Value: fmt.Sprintf("%d", t.Len()),
- },
- Elt: elt,
- }
- case *types.Slice:
- elt := TypeExpr(f, pkg, t.Elem())
- if elt == nil {
- return nil
- }
- return &ast.ArrayType{
- Elt: elt,
- }
- case *types.Map:
- key := TypeExpr(f, pkg, t.Key())
- value := TypeExpr(f, pkg, t.Elem())
- if key == nil || value == nil {
- return nil
- }
- return &ast.MapType{
- Key: key,
- Value: value,
- }
- case *types.Chan:
- dir := ast.ChanDir(t.Dir())
- if t.Dir() == types.SendRecv {
- dir = ast.SEND | ast.RECV
- }
- value := TypeExpr(f, pkg, t.Elem())
- if value == nil {
- return nil
- }
- return &ast.ChanType{
- Dir: dir,
- Value: value,
- }
- case *types.Signature:
- var params []*ast.Field
- for i := 0; i < t.Params().Len(); i++ {
- p := TypeExpr(f, pkg, t.Params().At(i).Type())
- if p == nil {
- return nil
- }
- params = append(params, &ast.Field{
- Type: p,
- Names: []*ast.Ident{
- {
- Name: t.Params().At(i).Name(),
- },
- },
- })
- }
- if t.Variadic() {
- last := params[len(params)-1]
- last.Type = &ast.Ellipsis{Elt: last.Type.(*ast.ArrayType).Elt}
- }
- var returns []*ast.Field
- for i := 0; i < t.Results().Len(); i++ {
- r := TypeExpr(f, pkg, t.Results().At(i).Type())
- if r == nil {
- return nil
- }
- returns = append(returns, &ast.Field{
- Type: r,
- })
- }
- return &ast.FuncType{
- Params: &ast.FieldList{
- List: params,
- },
- Results: &ast.FieldList{
- List: returns,
- },
- }
- case interface{ Obj() *types.TypeName }: // *types.{Alias,Named,TypeParam}
- if t.Obj().Pkg() == nil {
- return ast.NewIdent(t.Obj().Name())
- }
- if t.Obj().Pkg() == pkg {
- return ast.NewIdent(t.Obj().Name())
- }
- pkgName := t.Obj().Pkg().Name()
-
- // 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 == "." {
- return ast.NewIdent(t.Obj().Name())
- }
- return &ast.SelectorExpr{
- X: ast.NewIdent(pkgName),
- Sel: ast.NewIdent(t.Obj().Name()),
- }
- case *types.Struct:
- return ast.NewIdent(t.String())
- case *types.Interface:
- return ast.NewIdent(t.String())
- default:
- return nil
- }
-}
-
-// StmtToInsertVarBefore returns the ast.Stmt before which we can safely insert a new variable.
-// Some examples:
-//
-// Basic Example:
-// z := 1
-// y := z + x
-// If x is undeclared, then this function would return `y := z + x`, so that we
-// can insert `x := ` on the line before `y := z + x`.
-//
-// If stmt example:
-// if z == 1 {
-// } else if z == y {}
-// If y is undeclared, then this function would return `if z == 1 {`, because we cannot
-// insert a statement between an if and an else if statement. As a result, we need to find
-// the top of the if chain to insert `y := ` before.
-func StmtToInsertVarBefore(path []ast.Node) ast.Stmt {
- enclosingIndex := -1
- for i, p := range path {
- if _, ok := p.(ast.Stmt); ok {
- enclosingIndex = i
- break
- }
- }
- if enclosingIndex == -1 {
- return nil
- }
- enclosingStmt := path[enclosingIndex]
- switch enclosingStmt.(type) {
- case *ast.IfStmt:
- // The enclosingStmt is inside of the if declaration,
- // We need to check if we are in an else-if stmt and
- // get the base if statement.
- return baseIfStmt(path, enclosingIndex)
- case *ast.CaseClause:
- // Get the enclosing switch stmt if the enclosingStmt is
- // inside of the case statement.
- for i := enclosingIndex + 1; i < len(path); i++ {
- if node, ok := path[i].(*ast.SwitchStmt); ok {
- return node
- } else if node, ok := path[i].(*ast.TypeSwitchStmt); ok {
- return node
- }
- }
- }
- if len(path) <= enclosingIndex+1 {
- return enclosingStmt.(ast.Stmt)
- }
- // Check if the enclosing statement is inside another node.
- switch expr := path[enclosingIndex+1].(type) {
- case *ast.IfStmt:
- // Get the base if statement.
- return baseIfStmt(path, enclosingIndex+1)
- case *ast.ForStmt:
- if expr.Init == enclosingStmt || expr.Post == enclosingStmt {
- return expr
- }
- case *ast.SwitchStmt, *ast.TypeSwitchStmt:
- return expr.(ast.Stmt)
- }
- return enclosingStmt.(ast.Stmt)
-}
-
-// baseIfStmt walks up the if/else-if chain until we get to
-// the top of the current if chain.
-func baseIfStmt(path []ast.Node, index int) ast.Stmt {
- stmt := path[index]
- for i := index + 1; i < len(path); i++ {
- if node, ok := path[i].(*ast.IfStmt); ok && node.Else == stmt {
- stmt = node
- continue
- }
- break
- }
- return stmt.(ast.Stmt)
-}
-
// WalkASTWithParent walks the AST rooted at n. The semantics are
// similar to ast.Inspect except it does not call f(nil).
func WalkASTWithParent(n ast.Node, f func(n ast.Node, parent ast.Node) bool) {
diff --git a/vendor/golang.org/x/tools/internal/diff/lcs/old.go b/vendor/golang.org/x/tools/internal/diff/lcs/old.go
index 4353da15b..7c74b47bb 100644
--- a/vendor/golang.org/x/tools/internal/diff/lcs/old.go
+++ b/vendor/golang.org/x/tools/internal/diff/lcs/old.go
@@ -199,6 +199,7 @@ func (e *editGraph) bdone(D, k int) (bool, lcs) {
}
// run the backward algorithm, until success or up to the limit on D.
+// (used only by tests)
func backward(e *editGraph) lcs {
e.setBackward(0, 0, e.ux)
if ok, ans := e.bdone(0, 0); ok {
diff --git a/vendor/golang.org/x/tools/internal/gcimporter/exportdata.go b/vendor/golang.org/x/tools/internal/gcimporter/exportdata.go
index f6437feb1..5662a311d 100644
--- a/vendor/golang.org/x/tools/internal/gcimporter/exportdata.go
+++ b/vendor/golang.org/x/tools/internal/gcimporter/exportdata.go
@@ -2,49 +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)
+// 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.
+// 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
}
- // leave for debugging
- if false {
- fmt.Printf("header: %s", hdr)
+ 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
}
- 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")
+ 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
}
- name = strings.TrimSpace(string(hdr[:16]))
+
return
}
-// FindExportData positions the reader r at the beginning of the
-// export data section of an underlying GC-created object/archive
-// file by reading from it. The reader must be positioned at the
-// start of the file before calling this function. The hdr result
-// is the string before the export data, either "$$" or "$$B".
-// The size result is the length of the export data in bytes, or -1 if not known.
-func FindExportData(r *bufio.Reader) (hdr string, size int64, err error) {
+// 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 {
@@ -52,48 +186,236 @@ func FindExportData(r *bufio.Reader) (hdr string, size int64, err error) {
return
}
- if string(line) == "!<arch>\n" {
- // Archive file. Scan to __.PKGDEF.
- var name string
- if name, size, err = readGopackHeader(r); err != nil {
- return
- }
+ // Is the first line an archive file signature?
+ if string(line) != "!<arch>\n" {
+ err = fmt.Errorf("not the start of an archive file (%q)", line)
+ return
+ }
+
+ // package export block should be first
+ size = readArchiveHeader(r, "__.PKGDEF")
+ if size <= 0 {
+ err = fmt.Errorf("not a package file")
+ return
+ }
+
+ return
+}
- // First entry should be __.PKGDEF.
- if name != "__.PKGDEF" {
- err = fmt.Errorf("go archive is missing __.PKGDEF")
+// 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 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)
+ // read next header
+ line, err = r.ReadSlice('\n')
+ if err != nil {
return
}
- size -= int64(len(line))
+ headers = append(headers, string(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")
+// 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
}
- // Skip over object header to export data.
- // Begins after first line starting with $$.
- for line[0] != '$' {
- if line, err = r.ReadSlice('\n'); err != nil {
- err = fmt.Errorf("can't find export data (%v)", err)
+ 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
}
- size -= int64(len(line))
- }
- hdr = string(line)
- if size < 0 {
- size = -1
+ // 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))()
+}
diff --git a/vendor/golang.org/x/tools/internal/gcimporter/gcimporter.go b/vendor/golang.org/x/tools/internal/gcimporter/gcimporter.go
index e6c5d51f8..3dbd21d1b 100644
--- a/vendor/golang.org/x/tools/internal/gcimporter/gcimporter.go
+++ b/vendor/golang.org/x/tools/internal/gcimporter/gcimporter.go
@@ -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,125 +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.
-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.
@@ -182,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
@@ -210,62 +94,15 @@ func Import(packages map[string]*types.Package, path, srcDir string, lookup func
}
defer rc.Close()
- var hdr string
- var size int64
buf := bufio.NewReader(rc)
- if hdr, size, err = FindExportData(buf); err != nil {
+ data, err := ReadUnified(buf)
+ if err != nil {
+ err = fmt.Errorf("import %q: %v", path, err)
return
}
- switch hdr {
- case "$$B\n":
- var data []byte
- data, err = io.ReadAll(buf)
- if err != nil {
- break
- }
-
- // TODO(gri): allow clients of go/importer to provide a FileSet.
- // Or, define a new standard go/types/gcexportdata package.
- fset := token.NewFileSet()
-
- // Select appropriate importer.
- if len(data) > 0 {
- 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)
- }
- }
-
- default:
- err = fmt.Errorf("unknown export data header: %q", hdr)
- }
+ // unified: emitted by cmd/compile since go1.20.
+ _, pkg, err = UImportData(fset, packages, data, 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() }
diff --git a/vendor/golang.org/x/tools/internal/gcimporter/iimport.go b/vendor/golang.org/x/tools/internal/gcimporter/iimport.go
index e260c0e8d..69b1d697c 100644
--- a/vendor/golang.org/x/tools/internal/gcimporter/iimport.go
+++ b/vendor/golang.org/x/tools/internal/gcimporter/iimport.go
@@ -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 (
@@ -1111,3 +1109,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() }
diff --git a/vendor/golang.org/x/tools/internal/gcimporter/support.go b/vendor/golang.org/x/tools/internal/gcimporter/support.go
new file mode 100644
index 000000000..4af810dc4
--- /dev/null
+++ b/vendor/golang.org/x/tools/internal/gcimporter/support.go
@@ -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
+}
diff --git a/vendor/golang.org/x/tools/internal/gcimporter/ureader_yes.go b/vendor/golang.org/x/tools/internal/gcimporter/ureader_yes.go
index 1db408613..6cdab448e 100644
--- a/vendor/golang.org/x/tools/internal/gcimporter/ureader_yes.go
+++ b/vendor/golang.org/x/tools/internal/gcimporter/ureader_yes.go
@@ -11,7 +11,6 @@ import (
"go/token"
"go/types"
"sort"
- "strings"
"golang.org/x/tools/internal/aliases"
"golang.org/x/tools/internal/pkgbits"
@@ -71,7 +70,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 +264,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
diff --git a/vendor/golang.org/x/tools/internal/imports/source.go b/vendor/golang.org/x/tools/internal/imports/source.go
index 5d2aeeebc..cbe4f3c5b 100644
--- a/vendor/golang.org/x/tools/internal/imports/source.go
+++ b/vendor/golang.org/x/tools/internal/imports/source.go
@@ -59,5 +59,5 @@ type Source interface {
// candidates satisfy all missing references for that package name. It is up
// to each data source to select the best result for each entry in the
// missing map.
- ResolveReferences(ctx context.Context, filename string, missing References) (map[PackageName]*Result, error)
+ ResolveReferences(ctx context.Context, filename string, missing References) ([]*Result, error)
}
diff --git a/vendor/golang.org/x/tools/internal/imports/source_env.go b/vendor/golang.org/x/tools/internal/imports/source_env.go
index ff9555d28..d14abaa31 100644
--- a/vendor/golang.org/x/tools/internal/imports/source_env.go
+++ b/vendor/golang.org/x/tools/internal/imports/source_env.go
@@ -48,7 +48,7 @@ func (s *ProcessEnvSource) LoadPackageNames(ctx context.Context, srcDir string,
return r.loadPackageNames(unknown, srcDir)
}
-func (s *ProcessEnvSource) ResolveReferences(ctx context.Context, filename string, refs map[string]map[string]bool) (map[string]*Result, error) {
+func (s *ProcessEnvSource) ResolveReferences(ctx context.Context, filename string, refs map[string]map[string]bool) ([]*Result, error) {
var mu sync.Mutex
found := make(map[string][]pkgDistance)
callback := &scanCallback{
@@ -121,5 +121,9 @@ func (s *ProcessEnvSource) ResolveReferences(ctx context.Context, filename strin
if err := g.Wait(); err != nil {
return nil, err
}
- return results, nil
+ var ans []*Result
+ for _, x := range results {
+ ans = append(ans, x)
+ }
+ return ans, nil
}
diff --git a/vendor/golang.org/x/tools/internal/imports/source_modindex.go b/vendor/golang.org/x/tools/internal/imports/source_modindex.go
new file mode 100644
index 000000000..05229f06c
--- /dev/null
+++ b/vendor/golang.org/x/tools/internal/imports/source_modindex.go
@@ -0,0 +1,103 @@
+// Copyright 2024 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package imports
+
+import (
+ "context"
+ "sync"
+ "time"
+
+ "golang.org/x/tools/internal/modindex"
+)
+
+// This code is here rather than in the modindex package
+// to avoid import loops
+
+// implements Source using modindex, so only for module cache.
+//
+// this is perhaps over-engineered. A new Index is read at first use.
+// And then Update is called after every 15 minutes, and a new Index
+// is read if the index changed. It is not clear the Mutex is needed.
+type IndexSource struct {
+ modcachedir string
+ mutex sync.Mutex
+ ix *modindex.Index
+ expires time.Time
+}
+
+// create a new Source. Called from NewView in cache/session.go.
+func NewIndexSource(cachedir string) *IndexSource {
+ return &IndexSource{modcachedir: cachedir}
+}
+
+func (s *IndexSource) LoadPackageNames(ctx context.Context, srcDir string, paths []ImportPath) (map[ImportPath]PackageName, error) {
+ /// This is used by goimports to resolve the package names of imports of the
+ // current package, which is irrelevant for the module cache.
+ return nil, nil
+}
+
+func (s *IndexSource) ResolveReferences(ctx context.Context, filename string, missing References) ([]*Result, error) {
+ if err := s.maybeReadIndex(); err != nil {
+ return nil, err
+ }
+ var cs []modindex.Candidate
+ for pkg, nms := range missing {
+ for nm := range nms {
+ x := s.ix.Lookup(pkg, nm, false)
+ cs = append(cs, x...)
+ }
+ }
+ found := make(map[string]*Result)
+ for _, c := range cs {
+ var x *Result
+ if x = found[c.ImportPath]; x == nil {
+ x = &Result{
+ Import: &ImportInfo{
+ ImportPath: c.ImportPath,
+ Name: "",
+ },
+ Package: &PackageInfo{
+ Name: c.PkgName,
+ Exports: make(map[string]bool),
+ },
+ }
+ found[c.ImportPath] = x
+ }
+ x.Package.Exports[c.Name] = true
+ }
+ var ans []*Result
+ for _, x := range found {
+ ans = append(ans, x)
+ }
+ return ans, nil
+}
+
+func (s *IndexSource) maybeReadIndex() error {
+ s.mutex.Lock()
+ defer s.mutex.Unlock()
+
+ var readIndex bool
+ if time.Now().After(s.expires) {
+ ok, err := modindex.Update(s.modcachedir)
+ if err != nil {
+ return err
+ }
+ if ok {
+ readIndex = true
+ }
+ }
+
+ if readIndex || s.ix == nil {
+ ix, err := modindex.ReadIndex(s.modcachedir)
+ if err != nil {
+ return err
+ }
+ s.ix = ix
+ // for now refresh every 15 minutes
+ s.expires = time.Now().Add(time.Minute * 15)
+ }
+
+ return nil
+}
diff --git a/vendor/golang.org/x/tools/internal/modindex/directories.go b/vendor/golang.org/x/tools/internal/modindex/directories.go
new file mode 100644
index 000000000..1e1a02f23
--- /dev/null
+++ b/vendor/golang.org/x/tools/internal/modindex/directories.go
@@ -0,0 +1,135 @@
+// Copyright 2024 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package modindex
+
+import (
+ "fmt"
+ "log"
+ "os"
+ "path/filepath"
+ "regexp"
+ "slices"
+ "strings"
+ "sync"
+ "time"
+
+ "golang.org/x/mod/semver"
+ "golang.org/x/tools/internal/gopathwalk"
+)
+
+type directory struct {
+ path Relpath
+ importPath string
+ version string // semantic version
+ syms []symbol
+}
+
+// filterDirs groups the directories by import path,
+// sorting the ones with the same import path by semantic version,
+// most recent first.
+func byImportPath(dirs []Relpath) (map[string][]*directory, error) {
+ ans := make(map[string][]*directory) // key is import path
+ for _, d := range dirs {
+ ip, sv, err := DirToImportPathVersion(d)
+ if err != nil {
+ return nil, err
+ }
+ ans[ip] = append(ans[ip], &directory{
+ path: d,
+ importPath: ip,
+ version: sv,
+ })
+ }
+ for k, v := range ans {
+ semanticSort(v)
+ ans[k] = v
+ }
+ return ans, nil
+}
+
+// sort the directories by semantic version, latest first
+func semanticSort(v []*directory) {
+ slices.SortFunc(v, func(l, r *directory) int {
+ if n := semver.Compare(l.version, r.version); n != 0 {
+ return -n // latest first
+ }
+ return strings.Compare(string(l.path), string(r.path))
+ })
+}
+
+// modCacheRegexp splits a relpathpath into module, module version, and package.
+var modCacheRegexp = regexp.MustCompile(`(.*)@([^/\\]*)(.*)`)
+
+// DirToImportPathVersion computes import path and semantic version
+func DirToImportPathVersion(dir Relpath) (string, string, error) {
+ m := modCacheRegexp.FindStringSubmatch(string(dir))
+ // m[1] is the module path
+ // m[2] is the version major.minor.patch(-<pre release identifier)
+ // m[3] is the rest of the package path
+ if len(m) != 4 {
+ return "", "", fmt.Errorf("bad dir %s", dir)
+ }
+ if !semver.IsValid(m[2]) {
+ return "", "", fmt.Errorf("bad semantic version %s", m[2])
+ }
+ // ToSlash is required for Windows.
+ return filepath.ToSlash(m[1] + m[3]), m[2], nil
+}
+
+// a region controls what directories to look at, for
+// updating the index incrementally, and for testing that.
+// (for testing one builds an index as of A, incrementally
+// updates it to B, and compares the result to an index build
+// as of B.)
+type region struct {
+ onlyAfter, onlyBefore time.Time
+ sync.Mutex
+ ans []Relpath
+}
+
+func findDirs(root string, onlyAfter, onlyBefore time.Time) []Relpath {
+ roots := []gopathwalk.Root{{Path: root, Type: gopathwalk.RootModuleCache}}
+ // TODO(PJW): adjust concurrency
+ opts := gopathwalk.Options{ModulesEnabled: true, Concurrency: 1 /* ,Logf: log.Printf*/}
+ betw := &region{
+ onlyAfter: onlyAfter,
+ onlyBefore: onlyBefore,
+ }
+ gopathwalk.WalkSkip(roots, betw.addDir, betw.skipDir, opts)
+ return betw.ans
+}
+
+func (r *region) addDir(rt gopathwalk.Root, dir string) {
+ // do we need to check times?
+ r.Lock()
+ defer r.Unlock()
+ x := filepath.ToSlash(string(toRelpath(Abspath(rt.Path), dir)))
+ r.ans = append(r.ans, toRelpath(Abspath(rt.Path), x))
+}
+
+func (r *region) skipDir(_ gopathwalk.Root, dir string) bool {
+ // The cache directory is already ignored in gopathwalk\
+ if filepath.Base(dir) == "internal" {
+ return true
+ }
+ if strings.Contains(dir, "toolchain@") {
+ return true
+ }
+ // don't look inside @ directories that are too old
+ if strings.Contains(filepath.Base(dir), "@") {
+ st, err := os.Stat(dir)
+ if err != nil {
+ log.Printf("can't stat dir %s %v", dir, err)
+ return true
+ }
+ if st.ModTime().Before(r.onlyAfter) {
+ return true
+ }
+ if st.ModTime().After(r.onlyBefore) {
+ return true
+ }
+ }
+ return false
+}
diff --git a/vendor/golang.org/x/tools/internal/modindex/index.go b/vendor/golang.org/x/tools/internal/modindex/index.go
new file mode 100644
index 000000000..9665356c0
--- /dev/null
+++ b/vendor/golang.org/x/tools/internal/modindex/index.go
@@ -0,0 +1,266 @@
+// Copyright 2024 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package modindex
+
+import (
+ "bufio"
+ "encoding/csv"
+ "errors"
+ "fmt"
+ "hash/crc64"
+ "io"
+ "io/fs"
+ "log"
+ "os"
+ "path/filepath"
+ "strconv"
+ "strings"
+ "testing"
+ "time"
+)
+
+/*
+The on-disk index is a text file.
+The first 3 lines are header information containing CurrentVersion,
+the value of GOMODCACHE, and the validity date of the index.
+(This is when the code started building the index.)
+Following the header are sections of lines, one section for each
+import path. These sections are sorted by package name.
+The first line of each section, marked by a leading :, contains
+the package name, the import path, the name of the directory relative
+to GOMODCACHE, and its semantic version.
+The rest of each section consists of one line per exported symbol.
+The lines are sorted by the symbol's name and contain the name,
+an indication of its lexical type (C, T, V, F), and if it is the
+name of a function, information about the signature.
+
+The fields in the section header lines are separated by commas, and
+in the unlikely event this would be confusing, the csv package is used
+to write (and read) them.
+
+In the lines containing exported names, C=const, V=var, T=type, F=func.
+If it is a func, the next field is the number of returned values,
+followed by pairs consisting of formal parameter names and types.
+All these fields are separated by spaces. Any spaces in a type
+(e.g., chan struct{}) are replaced by $s on the disk. The $s are
+turned back into spaces when read.
+
+Here is an index header (the comments are not part of the index):
+0 // version (of the index format)
+/usr/local/google/home/pjw/go/pkg/mod // GOMODCACHE
+2024-09-11 18:55:09 // validity date of the index
+
+Here is an index section:
+:yaml,gopkg.in/yaml.v1,gopkg.in/yaml.v1@v1.0.0-20140924161607-9f9df34309c0,v1.0.0-20140924161607-9f9df34309c0
+Getter T
+Marshal F 2 in interface{}
+Setter T
+Unmarshal F 1 in []byte out interface{}
+
+The package name is yaml, the import path is gopkg.in/yaml.v1.
+Getter and Setter are types, and Marshal and Unmarshal are functions.
+The latter returns one value and has two arguments, 'in' and 'out'
+whose types are []byte and interface{}.
+*/
+
+// CurrentVersion tells readers about the format of the index.
+const CurrentVersion int = 0
+
+// Index is returned by ReadIndex().
+type Index struct {
+ Version int
+ Cachedir Abspath // The directory containing the module cache
+ Changed time.Time // The index is up to date as of Changed
+ Entries []Entry
+}
+
+// An Entry contains information for an import path.
+type Entry struct {
+ Dir Relpath // directory in modcache
+ ImportPath string
+ PkgName string
+ Version string
+ //ModTime STime // is this useful?
+ 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
+// a non-nil error if the index exists but could not be read.
+func ReadIndex(cachedir string) (*Index, error) {
+ cachedir, err := filepath.Abs(cachedir)
+ if err != nil {
+ return nil, err
+ }
+ cd := Abspath(cachedir)
+ dir := IndexDir
+ base := indexNameBase(cd)
+ iname := filepath.Join(dir, base)
+ buf, err := os.ReadFile(iname)
+ if err != nil {
+ if errors.Is(err, fs.ErrNotExist) {
+ return nil, nil
+ }
+ return nil, fmt.Errorf("cannot read %s: %w", iname, err)
+ }
+ fname := filepath.Join(dir, string(buf))
+ fd, err := os.Open(fname)
+ if err != nil {
+ return nil, err
+ }
+ defer fd.Close()
+ r := bufio.NewReader(fd)
+ ix, err := readIndexFrom(cd, r)
+ if err != nil {
+ return nil, err
+ }
+ return ix, nil
+}
+
+func readIndexFrom(cd Abspath, bx io.Reader) (*Index, error) {
+ b := bufio.NewScanner(bx)
+ var ans Index
+ // header
+ ok := b.Scan()
+ if !ok {
+ return nil, fmt.Errorf("unexpected scan error")
+ }
+ l := b.Text()
+ var err error
+ ans.Version, err = strconv.Atoi(l)
+ if err != nil {
+ return nil, err
+ }
+ if ans.Version != CurrentVersion {
+ return nil, fmt.Errorf("got version %d, expected %d", ans.Version, CurrentVersion)
+ }
+ if ok := b.Scan(); !ok {
+ return nil, fmt.Errorf("scanner error reading cachedir")
+ }
+ ans.Cachedir = Abspath(b.Text())
+ if ok := b.Scan(); !ok {
+ return nil, fmt.Errorf("scanner error reading index creation time")
+ }
+ // TODO(pjw): need to check that this is the expected cachedir
+ // so the tag should be passed in to this function
+ ans.Changed, err = time.ParseInLocation(time.DateTime, b.Text(), time.Local)
+ if err != nil {
+ return nil, err
+ }
+ var curEntry *Entry
+ for b.Scan() {
+ v := b.Text()
+ if v[0] == ':' {
+ if curEntry != nil {
+ ans.Entries = append(ans.Entries, *curEntry)
+ }
+ // as directories may contain commas and quotes, they need to be read as csv.
+ rdr := strings.NewReader(v[1:])
+ cs := csv.NewReader(rdr)
+ flds, err := cs.Read()
+ if err != nil {
+ return nil, err
+ }
+ if len(flds) != 4 {
+ return nil, fmt.Errorf("header contains %d fields, not 4: %q", len(v), v)
+ }
+ curEntry = &Entry{PkgName: flds[0], ImportPath: flds[1], Dir: toRelpath(cd, flds[2]), Version: flds[3]}
+ continue
+ }
+ curEntry.Names = append(curEntry.Names, v)
+ }
+ if curEntry != nil {
+ ans.Entries = append(ans.Entries, *curEntry)
+ }
+ if err := b.Err(); err != nil {
+ return nil, fmt.Errorf("scanner failed %v", err)
+ }
+ return &ans, nil
+}
+
+// write the index as a text file
+func writeIndex(cachedir Abspath, ix *Index) error {
+ ipat := fmt.Sprintf("index-%d-*", CurrentVersion)
+ fd, err := os.CreateTemp(IndexDir, ipat)
+ if err != nil {
+ return err // can this happen?
+ }
+ defer fd.Close()
+ if err := writeIndexToFile(ix, fd); err != nil {
+ return err
+ }
+ content := fd.Name()
+ content = filepath.Base(content)
+ base := indexNameBase(cachedir)
+ nm := filepath.Join(IndexDir, base)
+ err = os.WriteFile(nm, []byte(content), 0666)
+ if err != nil {
+ return err
+ }
+ return nil
+}
+
+func writeIndexToFile(x *Index, fd *os.File) error {
+ cnt := 0
+ w := bufio.NewWriter(fd)
+ fmt.Fprintf(w, "%d\n", x.Version)
+ fmt.Fprintf(w, "%s\n", x.Cachedir)
+ // round the time down
+ tm := x.Changed.Add(-time.Second / 2)
+ fmt.Fprintf(w, "%s\n", tm.Format(time.DateTime))
+ for _, e := range x.Entries {
+ if e.ImportPath == "" {
+ continue // shouldn't happen
+ }
+ // PJW: maybe always write these headers as csv?
+ if strings.ContainsAny(string(e.Dir), ",\"") {
+ log.Printf("DIR: %s", e.Dir)
+ cw := csv.NewWriter(w)
+ cw.Write([]string{":" + e.PkgName, e.ImportPath, string(e.Dir), e.Version})
+ cw.Flush()
+ } else {
+ fmt.Fprintf(w, ":%s,%s,%s,%s\n", e.PkgName, e.ImportPath, e.Dir, e.Version)
+ }
+ for _, x := range e.Names {
+ fmt.Fprintf(w, "%s\n", x)
+ cnt++
+ }
+ }
+ if err := w.Flush(); err != nil {
+ return err
+ }
+ return 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.
+ h := crc64.Checksum([]byte(cachedir), crc64.MakeTable(crc64.ECMA))
+ fname := fmt.Sprintf("index-name-%d-%016x", CurrentVersion, h)
+ return fname
+}
diff --git a/vendor/golang.org/x/tools/internal/modindex/lookup.go b/vendor/golang.org/x/tools/internal/modindex/lookup.go
new file mode 100644
index 000000000..012fdd713
--- /dev/null
+++ b/vendor/golang.org/x/tools/internal/modindex/lookup.go
@@ -0,0 +1,148 @@
+// Copyright 2024 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package modindex
+
+import (
+ "slices"
+ "strconv"
+ "strings"
+)
+
+type Candidate struct {
+ PkgName string
+ Name string
+ Dir string
+ ImportPath string
+ Type LexType
+ Deprecated bool
+ // information for Funcs
+ Results int16 // how many results
+ Sig []Field // arg names and types
+}
+
+type Field struct {
+ Arg, Type string
+}
+
+type LexType int8
+
+const (
+ Const LexType = iota
+ Var
+ Type
+ Func
+)
+
+// 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 {
+ loc, ok := slices.BinarySearchFunc(ix.Entries, pkg, func(e Entry, pkg string) int {
+ return strings.Compare(e.PkgName, pkg)
+ })
+ if !ok {
+ return nil // didn't find the package
+ }
+ var ans []Candidate
+ // loc is the first entry for this package name, but there may be severeal
+ for i := loc; i < len(ix.Entries); i++ {
+ e := ix.Entries[i]
+ if e.PkgName != pkg {
+ break // end of sorted package names
+ }
+ nloc, ok := slices.BinarySearchFunc(e.Names, name, func(s string, name string) int {
+ if strings.HasPrefix(s, name) {
+ return 0
+ }
+ if s < name {
+ return -1
+ }
+ return 1
+ })
+ if !ok {
+ continue // didn't find the name, nor any symbols with name as a prefix
+ }
+ for j := nloc; j < len(e.Names); j++ {
+ nstr := e.Names[j]
+ // benchmarks show this makes a difference when there are a lot of Possibilities
+ flds := fastSplit(nstr)
+ if !(flds[0] == name || prefix && strings.HasPrefix(flds[0], name)) {
+ // past range of matching Names
+ break
+ }
+ if len(flds) < 2 {
+ continue // should never happen
+ }
+ px := Candidate{
+ PkgName: pkg,
+ Name: flds[0],
+ Dir: string(e.Dir),
+ ImportPath: e.ImportPath,
+ Type: asLexType(flds[1][0]),
+ Deprecated: len(flds[1]) > 1 && flds[1][1] == 'D',
+ }
+ if px.Type == Func {
+ n, err := strconv.Atoi(flds[2])
+ if err != nil {
+ continue // should never happen
+ }
+ px.Results = int16(n)
+ if len(flds) >= 4 {
+ sig := strings.Split(flds[3], " ")
+ for i := 0; i < len(sig); i++ {
+ // $ cannot otherwise occur. removing the spaces
+ // almost works, but for chan struct{}, e.g.
+ sig[i] = strings.Replace(sig[i], "$", " ", -1)
+ }
+ px.Sig = toFields(sig)
+ }
+ }
+ ans = append(ans, px)
+ }
+ }
+ return ans
+}
+
+func toFields(sig []string) []Field {
+ ans := make([]Field, len(sig)/2)
+ for i := 0; i < len(ans); i++ {
+ ans[i] = Field{Arg: sig[2*i], Type: sig[2*i+1]}
+ }
+ return ans
+}
+
+// benchmarks show this is measurably better than strings.Split
+// split into first 4 fields separated by single space
+func fastSplit(x string) []string {
+ ans := make([]string, 0, 4)
+ nxt := 0
+ start := 0
+ for i := 0; i < len(x); i++ {
+ if x[i] != ' ' {
+ continue
+ }
+ ans = append(ans, x[start:i])
+ nxt++
+ start = i + 1
+ if nxt >= 3 {
+ break
+ }
+ }
+ ans = append(ans, x[start:])
+ return ans
+}
+
+func asLexType(c byte) LexType {
+ switch c {
+ case 'C':
+ return Const
+ case 'V':
+ return Var
+ case 'T':
+ return Type
+ case 'F':
+ return Func
+ }
+ return -1
+}
diff --git a/vendor/golang.org/x/tools/internal/modindex/modindex.go b/vendor/golang.org/x/tools/internal/modindex/modindex.go
new file mode 100644
index 000000000..355a53e71
--- /dev/null
+++ b/vendor/golang.org/x/tools/internal/modindex/modindex.go
@@ -0,0 +1,164 @@
+// Copyright 2024 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// Package modindex contains code for building and searching an index to
+// the Go module cache. The directory containing the index, returned by
+// IndexDir(), contains a file index-name-<ver> that contains the name
+// of the current index. We believe writing that short file is atomic.
+// ReadIndex reads that file to get the file name of the index.
+// WriteIndex writes an index with a unique name and then
+// writes that name into a new version of index-name-<ver>.
+// (<ver> stands for the CurrentVersion of the index format.)
+package modindex
+
+import (
+ "path/filepath"
+ "slices"
+ "strings"
+ "time"
+
+ "golang.org/x/mod/semver"
+)
+
+// Create always creates a new index for the go module cache that is in cachedir.
+func Create(cachedir string) error {
+ _, err := indexModCache(cachedir, true)
+ return err
+}
+
+// Update the index for the go module cache that is in cachedir,
+// If there is no existing index it will build one.
+// If there are changed directories since the last index, it will
+// write a new one and return true. Otherwise it returns false.
+func Update(cachedir string) (bool, error) {
+ return indexModCache(cachedir, false)
+}
+
+// indexModCache writes an index current as of when it is called.
+// If clear is true the index is constructed from all of GOMODCACHE
+// otherwise the index is constructed from the last previous index
+// and the updates to the cache. It returns true if it wrote an index,
+// false otherwise.
+func indexModCache(cachedir string, clear bool) (bool, error) {
+ cachedir, err := filepath.Abs(cachedir)
+ if err != nil {
+ return false, err
+ }
+ cd := Abspath(cachedir)
+ future := time.Now().Add(24 * time.Hour) // safely in the future
+ ok, err := modindexTimed(future, cd, clear)
+ if err != nil {
+ return false, err
+ }
+ return ok, nil
+}
+
+// modindexTimed writes an index current as of onlyBefore.
+// If clear is true the index is constructed from all of GOMODCACHE
+// otherwise the index is constructed from the last previous index
+// and all the updates to the cache before onlyBefore.
+// It returns true if it wrote a new index, false if it wrote nothing.
+func modindexTimed(onlyBefore time.Time, cachedir Abspath, clear bool) (bool, error) {
+ var curIndex *Index
+ if !clear {
+ var err error
+ curIndex, err = ReadIndex(string(cachedir))
+ if clear && err != nil {
+ return false, err
+ }
+ // TODO(pjw): check that most of those directories still exist
+ }
+ cfg := &work{
+ onlyBefore: onlyBefore,
+ oldIndex: curIndex,
+ cacheDir: cachedir,
+ }
+ if curIndex != nil {
+ cfg.onlyAfter = curIndex.Changed
+ }
+ if err := cfg.buildIndex(); err != nil {
+ return false, err
+ }
+ if len(cfg.newIndex.Entries) == 0 && curIndex != nil {
+ // no changes from existing curIndex, don't write a new index
+ return false, nil
+ }
+ if err := cfg.writeIndex(); err != nil {
+ return false, err
+ }
+ return true, nil
+}
+
+type work struct {
+ onlyBefore time.Time // do not use directories later than this
+ onlyAfter time.Time // only interested in directories after this
+ // directories from before onlyAfter come from oldIndex
+ oldIndex *Index
+ newIndex *Index
+ cacheDir Abspath
+}
+
+func (w *work) buildIndex() error {
+ // The effective date of the new index should be at least
+ // slightly earlier than when the directories are scanned
+ // so set it now.
+ w.newIndex = &Index{Changed: time.Now(), Cachedir: w.cacheDir}
+ dirs := findDirs(string(w.cacheDir), w.onlyAfter, w.onlyBefore)
+ if len(dirs) == 0 {
+ return nil
+ }
+ newdirs, err := byImportPath(dirs)
+ if err != nil {
+ return err
+ }
+ // for each import path it might occur only in newdirs,
+ // only in w.oldIndex, or in both.
+ // If it occurs in both, use the semantically later one
+ if w.oldIndex != nil {
+ for _, e := range w.oldIndex.Entries {
+ found, ok := newdirs[e.ImportPath]
+ if !ok {
+ w.newIndex.Entries = append(w.newIndex.Entries, e)
+ continue // use this one, there is no new one
+ }
+ if semver.Compare(found[0].version, e.Version) > 0 {
+ // use the new one
+ } else {
+ // use the old one, forget the new one
+ w.newIndex.Entries = append(w.newIndex.Entries, e)
+ delete(newdirs, e.ImportPath)
+ }
+ }
+ }
+ // get symbol information for all the new diredtories
+ getSymbols(w.cacheDir, newdirs)
+ // assemble the new index entries
+ for k, v := range newdirs {
+ d := v[0]
+ pkg, names := processSyms(d.syms)
+ if pkg == "" {
+ continue // PJW: does this ever happen?
+ }
+ entry := Entry{
+ PkgName: pkg,
+ Dir: d.path,
+ ImportPath: k,
+ Version: d.version,
+ Names: names,
+ }
+ w.newIndex.Entries = append(w.newIndex.Entries, entry)
+ }
+ // sort the entries in the new index
+ slices.SortFunc(w.newIndex.Entries, func(l, r Entry) int {
+ if n := strings.Compare(l.PkgName, r.PkgName); n != 0 {
+ return n
+ }
+ return strings.Compare(l.ImportPath, r.ImportPath)
+ })
+ return nil
+}
+
+func (w *work) writeIndex() error {
+ return writeIndex(w.cacheDir, w.newIndex)
+}
diff --git a/vendor/golang.org/x/tools/internal/modindex/symbols.go b/vendor/golang.org/x/tools/internal/modindex/symbols.go
new file mode 100644
index 000000000..33bf2641f
--- /dev/null
+++ b/vendor/golang.org/x/tools/internal/modindex/symbols.go
@@ -0,0 +1,217 @@
+// Copyright 2024 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package modindex
+
+import (
+ "fmt"
+ "go/ast"
+ "go/parser"
+ "go/token"
+ "go/types"
+ "os"
+ "path/filepath"
+ "slices"
+ "strings"
+
+ "golang.org/x/sync/errgroup"
+)
+
+// The name of a symbol contains information about the symbol:
+// <name> T for types, TD if the type is deprecated
+// <name> C for consts, CD if the const is deprecated
+// <name> V for vars, VD if the var is deprecated
+// and for funcs: <name> F <num of return values> (<arg-name> <arg-type>)*
+// any spaces in <arg-type> are replaced by $s so that the fields
+// of the name are space separated. F is replaced by FD if the func
+// is deprecated.
+type symbol struct {
+ pkg string // name of the symbols's package
+ name string // declared name
+ kind string // T, C, V, or F
+ 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
+ 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 | parser.ParseComments
+
+ fi, err := os.ReadDir(thedir)
+ if err != nil {
+ return nil // log this someday?
+ }
+ for _, fx := range fi {
+ if !strings.HasSuffix(fx.Name(), ".go") || strings.HasSuffix(fx.Name(), "_test.go") {
+ continue
+ }
+ fname := filepath.Join(thedir, fx.Name())
+ tr, err := parser.ParseFile(token.NewFileSet(), fname, nil, mode)
+ if err != nil {
+ continue // ignore errors, someday log them?
+ }
+ d.syms = append(d.syms, getFileExports(tr)...)
+ }
+ return nil
+ })
+ }
+ g.Wait()
+}
+
+func getFileExports(f *ast.File) []symbol {
+ pkg := f.Name.Name
+ if pkg == "main" {
+ return nil
+ }
+ var ans []symbol
+ // should we look for //go:build ignore?
+ for _, decl := range f.Decls {
+ switch decl := decl.(type) {
+ case *ast.FuncDecl:
+ if decl.Recv != nil {
+ // ignore methods, as we are completing package selections
+ continue
+ }
+ name := decl.Name.Name
+ dtype := decl.Type
+ // not looking at dtype.TypeParams. That is, treating
+ // generic functions just like non-generic ones.
+ sig := dtype.Params
+ kind := "F"
+ if isDeprecated(decl.Doc) {
+ kind += "D"
+ }
+ result := []string{fmt.Sprintf("%d", dtype.Results.NumFields())}
+ for _, x := range sig.List {
+ // This code creates a string representing the type.
+ // TODO(pjw): it may be fragile:
+ // 1. x.Type could be nil, perhaps in ill-formed code
+ // 2. ExprString might someday change incompatibly to
+ // include struct tags, which can be arbitrary strings
+ if x.Type == nil {
+ // Can this happen without a parse error? (Files with parse
+ // errors are ignored in getSymbols)
+ continue // maybe report this someday
+ }
+ tp := types.ExprString(x.Type)
+ if len(tp) == 0 {
+ // Can this happen?
+ continue // maybe report this someday
+ }
+ // This is only safe if ExprString never returns anything with a $
+ // The only place a $ can occur seems to be in a struct tag, which
+ // can be an arbitrary string literal, and ExprString does not presently
+ // print struct tags. So for this to happen the type of a formal parameter
+ // has to be a 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
+ if strings.Contains(tp, "$") {
+ continue
+ }
+ tp = strings.Replace(tp, " ", "$", -1)
+ if len(x.Names) == 0 {
+ result = append(result, "_")
+ result = append(result, tp)
+ } else {
+ for _, y := range x.Names {
+ result = append(result, y.Name)
+ result = append(result, tp)
+ }
+ }
+ }
+ sigs := strings.Join(result, " ")
+ if s := newsym(pkg, name, kind, sigs); s != nil {
+ ans = append(ans, *s)
+ }
+ case *ast.GenDecl:
+ depr := isDeprecated(decl.Doc)
+ switch decl.Tok {
+ case token.CONST, token.VAR:
+ tp := "V"
+ if decl.Tok == token.CONST {
+ tp = "C"
+ }
+ if depr {
+ tp += "D"
+ }
+ for _, sp := range decl.Specs {
+ for _, x := range sp.(*ast.ValueSpec).Names {
+ if s := newsym(pkg, x.Name, tp, ""); s != nil {
+ ans = append(ans, *s)
+ }
+ }
+ }
+ case token.TYPE:
+ tp := "T"
+ if depr {
+ tp += "D"
+ }
+ for _, sp := range decl.Specs {
+ if s := newsym(pkg, sp.(*ast.TypeSpec).Name.Name, tp, ""); s != nil {
+ ans = append(ans, *s)
+ }
+ }
+ }
+ }
+ }
+ return ans
+}
+
+func newsym(pkg, name, kind, sig string) *symbol {
+ if len(name) == 0 || !ast.IsExported(name) {
+ return nil
+ }
+ sym := symbol{pkg: pkg, name: name, kind: kind, sig: sig}
+ return &sym
+}
+
+func isDeprecated(doc *ast.CommentGroup) bool {
+ if doc == nil {
+ return false
+ }
+ // go.dev/wiki/Deprecated Paragraph starting 'Deprecated:'
+ // This code fails for /* Deprecated: */, but it's the code from
+ // gopls/internal/analysis/deprecated
+ 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
+func processSyms(syms []symbol) (string, []string) {
+ if len(syms) == 0 {
+ return "", nil
+ }
+ slices.SortFunc(syms, func(l, r symbol) int {
+ return strings.Compare(l.name, r.name)
+ })
+ pkg := syms[0].pkg
+ var names []string
+ for _, s := range syms {
+ var nx string
+ if s.pkg == pkg {
+ if s.sig != "" {
+ nx = fmt.Sprintf("%s %s %s", s.name, s.kind, s.sig)
+ } else {
+ nx = fmt.Sprintf("%s %s", s.name, s.kind)
+ }
+ names = append(names, nx)
+ } else {
+ continue // PJW: do we want to keep track of these?
+ }
+ }
+ return pkg, names
+}
diff --git a/vendor/golang.org/x/tools/internal/modindex/types.go b/vendor/golang.org/x/tools/internal/modindex/types.go
new file mode 100644
index 000000000..ece448863
--- /dev/null
+++ b/vendor/golang.org/x/tools/internal/modindex/types.go
@@ -0,0 +1,25 @@
+// Copyright 2024 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package modindex
+
+import (
+ "strings"
+)
+
+// some special types to avoid confusions
+
+// distinguish various types of directory names. It's easy to get confused.
+type Abspath string // absolute paths
+type Relpath string // paths with GOMODCACHE prefix removed
+
+func toRelpath(cachedir Abspath, s string) Relpath {
+ if strings.HasPrefix(s, string(cachedir)) {
+ if s == string(cachedir) {
+ return Relpath("")
+ }
+ return Relpath(s[len(cachedir)+1:])
+ }
+ return Relpath(s)
+}
diff --git a/vendor/golang.org/x/tools/internal/packagesinternal/packages.go b/vendor/golang.org/x/tools/internal/packagesinternal/packages.go
index 44719de17..66e69b438 100644
--- a/vendor/golang.org/x/tools/internal/packagesinternal/packages.go
+++ b/vendor/golang.org/x/tools/internal/packagesinternal/packages.go
@@ -5,7 +5,6 @@
// Package packagesinternal exposes internal-only fields from go/packages.
package packagesinternal
-var GetForTest = func(p interface{}) string { return "" }
var GetDepsErrors = func(p interface{}) []*PackageError { return nil }
type PackageError struct {
@@ -16,7 +15,6 @@ type PackageError struct {
var TypecheckCgo int
var DepsErrors int // must be set as a LoadMode to call GetDepsErrors
-var ForTest int // must be set as a LoadMode to call GetForTest
var SetModFlag = func(config interface{}, value string) {}
var SetModFile = func(config interface{}, value string) {}
diff --git a/vendor/golang.org/x/tools/internal/robustio/gopls_windows.go b/vendor/golang.org/x/tools/internal/robustio/gopls_windows.go
deleted file mode 100644
index 949f27816..000000000
--- a/vendor/golang.org/x/tools/internal/robustio/gopls_windows.go
+++ /dev/null
@@ -1,16 +0,0 @@
-// Copyright 2022 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 robustio
-
-import "syscall"
-
-// The robustio package is copied from cmd/go/internal/robustio, a package used
-// by the go command to retry known flaky operations on certain operating systems.
-
-//go:generate go run copyfiles.go
-
-// Since the gopls module cannot access internal/syscall/windows, copy a
-// necessary constant.
-const ERROR_SHARING_VIOLATION syscall.Errno = 32
diff --git a/vendor/golang.org/x/tools/internal/robustio/robustio.go b/vendor/golang.org/x/tools/internal/robustio/robustio.go
deleted file mode 100644
index 0a559fc9b..000000000
--- a/vendor/golang.org/x/tools/internal/robustio/robustio.go
+++ /dev/null
@@ -1,69 +0,0 @@
-// Copyright 2019 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 robustio wraps I/O functions that are prone to failure on Windows,
-// transparently retrying errors up to an arbitrary timeout.
-//
-// Errors are classified heuristically and retries are bounded, so the functions
-// in this package do not completely eliminate spurious errors. However, they do
-// significantly reduce the rate of failure in practice.
-//
-// If so, the error will likely wrap one of:
-// The functions in this package do not completely eliminate spurious errors,
-// but substantially reduce their rate of occurrence in practice.
-package robustio
-
-import "time"
-
-// Rename is like os.Rename, but on Windows retries errors that may occur if the
-// file is concurrently read or overwritten.
-//
-// (See golang.org/issue/31247 and golang.org/issue/32188.)
-func Rename(oldpath, newpath string) error {
- return rename(oldpath, newpath)
-}
-
-// ReadFile is like os.ReadFile, but on Windows retries errors that may
-// occur if the file is concurrently replaced.
-//
-// (See golang.org/issue/31247 and golang.org/issue/32188.)
-func ReadFile(filename string) ([]byte, error) {
- return readFile(filename)
-}
-
-// RemoveAll is like os.RemoveAll, but on Windows retries errors that may occur
-// if an executable file in the directory has recently been executed.
-//
-// (See golang.org/issue/19491.)
-func RemoveAll(path string) error {
- return removeAll(path)
-}
-
-// IsEphemeralError reports whether err is one of the errors that the functions
-// in this package attempt to mitigate.
-//
-// Errors considered ephemeral include:
-// - syscall.ERROR_ACCESS_DENIED
-// - syscall.ERROR_FILE_NOT_FOUND
-// - internal/syscall/windows.ERROR_SHARING_VIOLATION
-//
-// This set may be expanded in the future; programs must not rely on the
-// non-ephemerality of any given error.
-func IsEphemeralError(err error) bool {
- return isEphemeralError(err)
-}
-
-// A FileID uniquely identifies a file in the file system.
-//
-// If GetFileID(name1) returns the same ID as GetFileID(name2), the two file
-// names denote the same file.
-// A FileID is comparable, and thus suitable for use as a map key.
-type FileID struct {
- device, inode uint64
-}
-
-// GetFileID returns the file system's identifier for the file, and its
-// modification time.
-// Like os.Stat, it reads through symbolic links.
-func GetFileID(filename string) (FileID, time.Time, error) { return getFileID(filename) }
diff --git a/vendor/golang.org/x/tools/internal/robustio/robustio_darwin.go b/vendor/golang.org/x/tools/internal/robustio/robustio_darwin.go
deleted file mode 100644
index 99fd8ebc2..000000000
--- a/vendor/golang.org/x/tools/internal/robustio/robustio_darwin.go
+++ /dev/null
@@ -1,21 +0,0 @@
-// Copyright 2019 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 robustio
-
-import (
- "errors"
- "syscall"
-)
-
-const errFileNotFound = syscall.ENOENT
-
-// isEphemeralError returns true if err may be resolved by waiting.
-func isEphemeralError(err error) bool {
- var errno syscall.Errno
- if errors.As(err, &errno) {
- return errno == errFileNotFound
- }
- return false
-}
diff --git a/vendor/golang.org/x/tools/internal/robustio/robustio_flaky.go b/vendor/golang.org/x/tools/internal/robustio/robustio_flaky.go
deleted file mode 100644
index d5c241857..000000000
--- a/vendor/golang.org/x/tools/internal/robustio/robustio_flaky.go
+++ /dev/null
@@ -1,92 +0,0 @@
-// Copyright 2019 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 windows || darwin
-// +build windows darwin
-
-package robustio
-
-import (
- "errors"
- "math/rand"
- "os"
- "syscall"
- "time"
-)
-
-const arbitraryTimeout = 2000 * time.Millisecond
-
-// retry retries ephemeral errors from f up to an arbitrary timeout
-// to work around filesystem flakiness on Windows and Darwin.
-func retry(f func() (err error, mayRetry bool)) error {
- var (
- bestErr error
- lowestErrno syscall.Errno
- start time.Time
- nextSleep time.Duration = 1 * time.Millisecond
- )
- for {
- err, mayRetry := f()
- if err == nil || !mayRetry {
- return err
- }
-
- var errno syscall.Errno
- if errors.As(err, &errno) && (lowestErrno == 0 || errno < lowestErrno) {
- bestErr = err
- lowestErrno = errno
- } else if bestErr == nil {
- bestErr = err
- }
-
- if start.IsZero() {
- start = time.Now()
- } else if d := time.Since(start) + nextSleep; d >= arbitraryTimeout {
- break
- }
- time.Sleep(nextSleep)
- nextSleep += time.Duration(rand.Int63n(int64(nextSleep)))
- }
-
- return bestErr
-}
-
-// rename is like os.Rename, but retries ephemeral errors.
-//
-// On Windows it wraps os.Rename, which (as of 2019-06-04) uses MoveFileEx with
-// MOVEFILE_REPLACE_EXISTING.
-//
-// Windows also provides a different system call, ReplaceFile,
-// that provides similar semantics, but perhaps preserves more metadata. (The
-// documentation on the differences between the two is very sparse.)
-//
-// Empirical error rates with MoveFileEx are lower under modest concurrency, so
-// for now we're sticking with what the os package already provides.
-func rename(oldpath, newpath string) (err error) {
- return retry(func() (err error, mayRetry bool) {
- err = os.Rename(oldpath, newpath)
- return err, isEphemeralError(err)
- })
-}
-
-// readFile is like os.ReadFile, but retries ephemeral errors.
-func readFile(filename string) ([]byte, error) {
- var b []byte
- err := retry(func() (err error, mayRetry bool) {
- b, err = os.ReadFile(filename)
-
- // Unlike in rename, we do not retry errFileNotFound here: it can occur
- // as a spurious error, but the file may also genuinely not exist, so the
- // increase in robustness is probably not worth the extra latency.
- return err, isEphemeralError(err) && !errors.Is(err, errFileNotFound)
- })
- return b, err
-}
-
-func removeAll(path string) error {
- return retry(func() (err error, mayRetry bool) {
- err = os.RemoveAll(path)
- return err, isEphemeralError(err)
- })
-}
diff --git a/vendor/golang.org/x/tools/internal/robustio/robustio_other.go b/vendor/golang.org/x/tools/internal/robustio/robustio_other.go
deleted file mode 100644
index 3a20cac6c..000000000
--- a/vendor/golang.org/x/tools/internal/robustio/robustio_other.go
+++ /dev/null
@@ -1,28 +0,0 @@
-// Copyright 2019 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 !windows && !darwin
-// +build !windows,!darwin
-
-package robustio
-
-import (
- "os"
-)
-
-func rename(oldpath, newpath string) error {
- return os.Rename(oldpath, newpath)
-}
-
-func readFile(filename string) ([]byte, error) {
- return os.ReadFile(filename)
-}
-
-func removeAll(path string) error {
- return os.RemoveAll(path)
-}
-
-func isEphemeralError(err error) bool {
- return false
-}
diff --git a/vendor/golang.org/x/tools/internal/robustio/robustio_plan9.go b/vendor/golang.org/x/tools/internal/robustio/robustio_plan9.go
deleted file mode 100644
index 9fa4cacb5..000000000
--- a/vendor/golang.org/x/tools/internal/robustio/robustio_plan9.go
+++ /dev/null
@@ -1,26 +0,0 @@
-// Copyright 2022 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 plan9
-// +build plan9
-
-package robustio
-
-import (
- "os"
- "syscall"
- "time"
-)
-
-func getFileID(filename string) (FileID, time.Time, error) {
- fi, err := os.Stat(filename)
- if err != nil {
- return FileID{}, time.Time{}, err
- }
- dir := fi.Sys().(*syscall.Dir)
- return FileID{
- device: uint64(dir.Type)<<32 | uint64(dir.Dev),
- inode: dir.Qid.Path,
- }, fi.ModTime(), nil
-}
diff --git a/vendor/golang.org/x/tools/internal/robustio/robustio_posix.go b/vendor/golang.org/x/tools/internal/robustio/robustio_posix.go
deleted file mode 100644
index cf74865d0..000000000
--- a/vendor/golang.org/x/tools/internal/robustio/robustio_posix.go
+++ /dev/null
@@ -1,26 +0,0 @@
-// Copyright 2022 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 !windows && !plan9
-// +build !windows,!plan9
-
-package robustio
-
-import (
- "os"
- "syscall"
- "time"
-)
-
-func getFileID(filename string) (FileID, time.Time, error) {
- fi, err := os.Stat(filename)
- if err != nil {
- return FileID{}, time.Time{}, err
- }
- stat := fi.Sys().(*syscall.Stat_t)
- return FileID{
- device: uint64(stat.Dev), // (int32 on darwin, uint64 on linux)
- inode: stat.Ino,
- }, fi.ModTime(), nil
-}
diff --git a/vendor/golang.org/x/tools/internal/robustio/robustio_windows.go b/vendor/golang.org/x/tools/internal/robustio/robustio_windows.go
deleted file mode 100644
index 616c32883..000000000
--- a/vendor/golang.org/x/tools/internal/robustio/robustio_windows.go
+++ /dev/null
@@ -1,51 +0,0 @@
-// Copyright 2019 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 robustio
-
-import (
- "errors"
- "syscall"
- "time"
-)
-
-const errFileNotFound = syscall.ERROR_FILE_NOT_FOUND
-
-// isEphemeralError returns true if err may be resolved by waiting.
-func isEphemeralError(err error) bool {
- var errno syscall.Errno
- if errors.As(err, &errno) {
- switch errno {
- case syscall.ERROR_ACCESS_DENIED,
- syscall.ERROR_FILE_NOT_FOUND,
- ERROR_SHARING_VIOLATION:
- return true
- }
- }
- return false
-}
-
-// Note: it may be convenient to have this helper return fs.FileInfo, but
-// implementing this is actually quite involved on Windows. Since we only
-// currently use mtime, keep it simple.
-func getFileID(filename string) (FileID, time.Time, error) {
- filename16, err := syscall.UTF16PtrFromString(filename)
- if err != nil {
- return FileID{}, time.Time{}, err
- }
- h, err := syscall.CreateFile(filename16, 0, 0, nil, syscall.OPEN_EXISTING, uint32(syscall.FILE_FLAG_BACKUP_SEMANTICS), 0)
- if err != nil {
- return FileID{}, time.Time{}, err
- }
- defer syscall.CloseHandle(h)
- var i syscall.ByHandleFileInformation
- if err := syscall.GetFileInformationByHandle(h, &i); err != nil {
- return FileID{}, time.Time{}, err
- }
- mtime := time.Unix(0, i.LastWriteTime.Nanoseconds())
- return FileID{
- device: uint64(i.VolumeSerialNumber),
- inode: uint64(i.FileIndexHigh)<<32 | uint64(i.FileIndexLow),
- }, mtime, nil
-}
diff --git a/vendor/golang.org/x/tools/internal/stdlib/manifest.go b/vendor/golang.org/x/tools/internal/stdlib/manifest.go
index cdaac9ab3..9f0b871ff 100644
--- a/vendor/golang.org/x/tools/internal/stdlib/manifest.go
+++ b/vendor/golang.org/x/tools/internal/stdlib/manifest.go
@@ -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},
+ },
}
diff --git a/vendor/golang.org/x/tools/internal/testenv/testenv.go b/vendor/golang.org/x/tools/internal/testenv/testenv.go
index 70c186b13..d217e2846 100644
--- a/vendor/golang.org/x/tools/internal/testenv/testenv.go
+++ b/vendor/golang.org/x/tools/internal/testenv/testenv.go
@@ -364,7 +364,7 @@ func NeedsGo1Point(t testing.TB, x int) {
}
}
-// SkipAfterGo1Point skips t if the ambient go command version in the PATH of
+// SkipAfterGoCommand1Point skips t if the ambient go command version in the PATH of
// the current process is newer than 1.x.
//
// SkipAfterGoCommand1Point memoizes the result of running the go command, so
diff --git a/vendor/golang.org/x/tools/internal/typeparams/common.go b/vendor/golang.org/x/tools/internal/typeparams/common.go
index 0b84acc5c..cdae2b8e8 100644
--- a/vendor/golang.org/x/tools/internal/typeparams/common.go
+++ b/vendor/golang.org/x/tools/internal/typeparams/common.go
@@ -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)
-}
diff --git a/vendor/golang.org/x/tools/internal/typesinternal/qualifier.go b/vendor/golang.org/x/tools/internal/typesinternal/qualifier.go
new file mode 100644
index 000000000..b64f714eb
--- /dev/null
+++ b/vendor/golang.org/x/tools/internal/typesinternal/qualifier.go
@@ -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()
+ }
+}
diff --git a/vendor/golang.org/x/tools/internal/typesinternal/recv.go b/vendor/golang.org/x/tools/internal/typesinternal/recv.go
index ba6f4f4eb..e54accc69 100644
--- a/vendor/golang.org/x/tools/internal/typesinternal/recv.go
+++ b/vendor/golang.org/x/tools/internal/typesinternal/recv.go
@@ -11,6 +11,8 @@ 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 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 {
diff --git a/vendor/golang.org/x/tools/internal/typesinternal/types.go b/vendor/golang.org/x/tools/internal/typesinternal/types.go
index df3ea5212..a93d51f98 100644
--- a/vendor/golang.org/x/tools/internal/typesinternal/types.go
+++ b/vendor/golang.org/x/tools/internal/typesinternal/types.go
@@ -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().
diff --git a/vendor/golang.org/x/tools/internal/typesinternal/zerovalue.go b/vendor/golang.org/x/tools/internal/typesinternal/zerovalue.go
new file mode 100644
index 000000000..d272949c1
--- /dev/null
+++ b/vendor/golang.org/x/tools/internal/typesinternal/zerovalue.go
@@ -0,0 +1,392 @@
+// 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 (
+ "fmt"
+ "go/ast"
+ "go/token"
+ "go/types"
+ "strings"
+)
+
+// 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, qual types.Qualifier) (_ string, isValid bool) {
+ switch t := t.(type) {
+ case *types.Basic:
+ switch {
+ case t.Info()&types.IsBoolean != 0:
+ return "false", true
+ case t.Info()&types.IsNumeric != 0:
+ return "0", true
+ case t.Info()&types.IsString != 0:
+ return `""`, true
+ case t.Kind() == types.UnsafePointer:
+ fallthrough
+ case t.Kind() == types.UntypedNil:
+ return "nil", true
+ case t.Kind() == types.Invalid:
+ return "invalid", false
+ default:
+ panic(fmt.Sprintf("ZeroString for unexpected type %v", t))
+ }
+
+ case *types.Pointer, *types.Slice, *types.Chan, *types.Map, *types.Signature:
+ return "nil", true
+
+ 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, qual) + "{}", true
+ default:
+ 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, qual) + "{}", true
+
+ case *types.TypeParam:
+ // Assumes func new is not shadowed.
+ 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++ {
+ comp, ok := ZeroString(t.At(i).Type(), qual)
+
+ components[i] = comp
+ isValid = isValid && ok
+ }
+ return "(" + strings.Join(components, ", ") + ")", isValid
+
+ case *types.Union:
+ // Variables of these types cannot be created, so it makes
+ // no sense to ask for their zero value.
+ panic(fmt.Sprintf("invalid type for a variable: %v", t))
+
+ default:
+ panic(t) // unreachable.
+ }
+}
+
+// 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(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"}, true
+ case t.Info()&types.IsNumeric != 0:
+ return &ast.BasicLit{Kind: token.INT, Value: "0"}, true
+ case t.Info()&types.IsString != 0:
+ return &ast.BasicLit{Kind: token.STRING, Value: `""`}, true
+ case t.Kind() == types.UnsafePointer:
+ fallthrough
+ case t.Kind() == types.UntypedNil:
+ return ast.NewIdent("nil"), true
+ case t.Kind() == types.Invalid:
+ return &ast.BasicLit{Kind: token.STRING, Value: `"invalid"`}, false
+ default:
+ panic(fmt.Sprintf("ZeroExpr for unexpected type %v", t))
+ }
+
+ case *types.Pointer, *types.Slice, *types.Chan, *types.Map, *types.Signature:
+ return ast.NewIdent("nil"), true
+
+ 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(t, qual),
+ }, true
+ default:
+ 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(t, qual),
+ }, true
+
+ case *types.TypeParam:
+ return &ast.StarExpr{ // *new(T)
+ X: &ast.CallExpr{
+ // Assumes func new is not shadowed.
+ Fun: ast.NewIdent("new"),
+ Args: []ast.Expr{
+ ast.NewIdent(t.Obj().Name()),
+ },
+ },
+ }, true
+
+ case *types.Tuple:
+ // Unlike ZeroString, there is no ast.Expr can express tuple by
+ // "(t[0], ..., t[n])".
+ panic(fmt.Sprintf("invalid type for a variable: %v", t))
+
+ case *types.Union:
+ // Variables of these types cannot be created, so it makes
+ // no sense to ask for their zero value.
+ panic(fmt.Sprintf("invalid type for a variable: %v", t))
+
+ default:
+ panic(t) // unreachable.
+ }
+}
+
+// IsZeroExpr uses simple syntactic heuristics to report whether expr
+// is a obvious zero value, such as 0, "", nil, or false.
+// It cannot do better without type information.
+func IsZeroExpr(expr ast.Expr) bool {
+ switch e := expr.(type) {
+ case *ast.BasicLit:
+ return e.Value == "0" || e.Value == `""`
+ case *ast.Ident:
+ return e.Name == "nil" || e.Name == "false"
+ default:
+ return false
+ }
+}
+
+// TypeExpr returns syntax for the specified type. References to named types
+// are qualified by an appropriate (optional) qualifier function.
+// It may panic for types such as Tuple or Union.
+func TypeExpr(t types.Type, qual types.Qualifier) ast.Expr {
+ switch t := t.(type) {
+ case *types.Basic:
+ switch t.Kind() {
+ case types.UnsafePointer:
+ return &ast.SelectorExpr{X: ast.NewIdent(qual(types.NewPackage("unsafe", "unsafe"))), Sel: ast.NewIdent("Pointer")}
+ default:
+ return ast.NewIdent(t.Name())
+ }
+
+ case *types.Pointer:
+ return &ast.UnaryExpr{
+ Op: token.MUL,
+ X: TypeExpr(t.Elem(), qual),
+ }
+
+ case *types.Array:
+ return &ast.ArrayType{
+ Len: &ast.BasicLit{
+ Kind: token.INT,
+ Value: fmt.Sprintf("%d", t.Len()),
+ },
+ Elt: TypeExpr(t.Elem(), qual),
+ }
+
+ case *types.Slice:
+ return &ast.ArrayType{
+ Elt: TypeExpr(t.Elem(), qual),
+ }
+
+ case *types.Map:
+ return &ast.MapType{
+ Key: TypeExpr(t.Key(), qual),
+ Value: TypeExpr(t.Elem(), qual),
+ }
+
+ case *types.Chan:
+ dir := ast.ChanDir(t.Dir())
+ if t.Dir() == types.SendRecv {
+ dir = ast.SEND | ast.RECV
+ }
+ return &ast.ChanType{
+ Dir: dir,
+ 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(t.Params().At(i).Type(), qual),
+ Names: []*ast.Ident{
+ {
+ Name: t.Params().At(i).Name(),
+ },
+ },
+ })
+ }
+ if t.Variadic() {
+ last := params[len(params)-1]
+ last.Type = &ast.Ellipsis{Elt: last.Type.(*ast.ArrayType).Elt}
+ }
+ var returns []*ast.Field
+ for i := 0; i < t.Results().Len(); i++ {
+ returns = append(returns, &ast.Field{
+ Type: TypeExpr(t.Results().At(i).Type(), qual),
+ })
+ }
+ return &ast.FuncType{
+ Params: &ast.FieldList{
+ List: params,
+ },
+ Results: &ast.FieldList{
+ List: returns,
+ },
+ }
+
+ case *types.TypeParam:
+ pkgName := qual(t.Obj().Pkg())
+ if pkgName == "" || t.Obj().Pkg() == nil {
+ return ast.NewIdent(t.Obj().Name())
+ }
+ return &ast.SelectorExpr{
+ X: ast.NewIdent(pkgName),
+ 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())
+
+ case *types.Interface:
+ return ast.NewIdent(t.String())
+
+ case *types.Union:
+ 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")
+
+ default:
+ panic("unreachable")
+ }
+}
diff --git a/vendor/golang.org/x/tools/internal/versions/constraint.go b/vendor/golang.org/x/tools/internal/versions/constraint.go
deleted file mode 100644
index 179063d48..000000000
--- a/vendor/golang.org/x/tools/internal/versions/constraint.go
+++ /dev/null
@@ -1,13 +0,0 @@
-// Copyright 2024 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-package versions
-
-import "go/build/constraint"
-
-// ConstraintGoVersion is constraint.GoVersion (if built with go1.21+).
-// Otherwise nil.
-//
-// Deprecate once x/tools is after go1.21.
-var ConstraintGoVersion func(x constraint.Expr) string
diff --git a/vendor/modules.txt b/vendor/modules.txt
index 590764155..39a0eaf25 100644
--- a/vendor/modules.txt
+++ b/vendor/modules.txt
@@ -1310,7 +1310,7 @@ go.uber.org/zap/internal/bufferpool
go.uber.org/zap/internal/color
go.uber.org/zap/internal/exit
go.uber.org/zap/zapcore
-# golang.org/x/crypto v0.29.0
+# golang.org/x/crypto v0.32.0
## explicit; go 1.20
golang.org/x/crypto/chacha20
golang.org/x/crypto/chacha20poly1305
@@ -1336,7 +1336,7 @@ golang.org/x/mod/internal/lazyregexp
golang.org/x/mod/modfile
golang.org/x/mod/module
golang.org/x/mod/semver
-# golang.org/x/net v0.31.0
+# golang.org/x/net v0.34.0
## explicit; go 1.18
golang.org/x/net/http/httpguts
golang.org/x/net/http2
@@ -1361,21 +1361,21 @@ golang.org/x/oauth2/jwt
golang.org/x/perf/benchstat
golang.org/x/perf/internal/stats
golang.org/x/perf/storage/benchfmt
-# golang.org/x/sync v0.9.0
+# golang.org/x/sync v0.10.0
## explicit; go 1.18
golang.org/x/sync/errgroup
golang.org/x/sync/semaphore
-# golang.org/x/sys v0.27.0
+# golang.org/x/sys v0.29.0
## explicit; go 1.18
golang.org/x/sys/cpu
golang.org/x/sys/plan9
golang.org/x/sys/unix
golang.org/x/sys/windows
golang.org/x/sys/windows/registry
-# golang.org/x/term v0.26.0
+# golang.org/x/term v0.28.0
## explicit; go 1.18
golang.org/x/term
-# golang.org/x/text v0.20.0
+# golang.org/x/text v0.21.0
## explicit; go 1.18
golang.org/x/text/encoding
golang.org/x/text/encoding/internal
@@ -1392,14 +1392,15 @@ golang.org/x/text/width
# golang.org/x/time v0.7.0
## explicit; go 1.18
golang.org/x/time/rate
-# golang.org/x/tools v0.27.0
+# golang.org/x/tools v0.29.0
## explicit; go 1.22.0
golang.org/x/tools/cmd/goimports
golang.org/x/tools/cmd/stringer
golang.org/x/tools/go/analysis
golang.org/x/tools/go/analysis/analysistest
+golang.org/x/tools/go/analysis/checker
+golang.org/x/tools/go/analysis/internal
golang.org/x/tools/go/analysis/internal/analysisflags
-golang.org/x/tools/go/analysis/internal/checker
golang.org/x/tools/go/analysis/passes/appends
golang.org/x/tools/go/analysis/passes/asmdecl
golang.org/x/tools/go/analysis/passes/assign
@@ -1472,9 +1473,9 @@ golang.org/x/tools/internal/gocommand
golang.org/x/tools/internal/gopathwalk
golang.org/x/tools/internal/goroot
golang.org/x/tools/internal/imports
+golang.org/x/tools/internal/modindex
golang.org/x/tools/internal/packagesinternal
golang.org/x/tools/internal/pkgbits
-golang.org/x/tools/internal/robustio
golang.org/x/tools/internal/stdlib
golang.org/x/tools/internal/testenv
golang.org/x/tools/internal/typeparams