├── .github
└── workflows
│ └── release.yml
├── .gitignore
├── LICENSE
├── README.md
├── Taskfile.yaml
├── cmd
├── cli
│ └── main_cli.go
└── gui
│ ├── icon.ico
│ └── main_gui.go
├── docs
├── build_key.svg
└── clip.svg
├── go.mod
├── go.sum
├── scripts
├── bash
│ ├── checkall.sh
│ └── vercmp.sh
└── git
│ ├── pre-commit
│ └── pre-push
├── server
├── clipboard.go
├── helpers.go
├── server.go
└── uri.go
├── systray
├── LICENSE
├── README.md
├── systray.go
└── systray_windows.go
├── util
├── consts.go
├── files_unix.go
├── files_windows.go
├── keys.go
├── log_unix.go
├── log_windows.go
├── mbox_unix.go
├── mbox_windows.go
└── util_test.go
└── vendor
├── github.com
├── BurntSushi
│ └── toml
│ │ ├── .gitignore
│ │ ├── COPYING
│ │ ├── README.md
│ │ ├── decode.go
│ │ ├── deprecated.go
│ │ ├── doc.go
│ │ ├── encode.go
│ │ ├── error.go
│ │ ├── internal
│ │ └── tz.go
│ │ ├── lex.go
│ │ ├── meta.go
│ │ ├── parse.go
│ │ ├── type_fields.go
│ │ └── type_toml.go
├── allan-simon
│ └── go-singleinstance
│ │ ├── .gitignore
│ │ ├── LICENSE
│ │ ├── README.md
│ │ ├── lock.go
│ │ ├── lock_posix.go
│ │ └── lock_windows.go
├── atotto
│ └── clipboard
│ │ ├── .travis.yml
│ │ ├── LICENSE
│ │ ├── README.md
│ │ ├── clipboard.go
│ │ ├── clipboard_darwin.go
│ │ ├── clipboard_plan9.go
│ │ ├── clipboard_unix.go
│ │ └── clipboard_windows.go
├── jstarks
│ └── npiperelay
│ │ ├── .gitignore
│ │ ├── .goreleaser.yml
│ │ ├── LICENSE
│ │ ├── README.md
│ │ ├── npiperelay.go
│ │ └── overlappedfile.go
└── skratchdot
│ └── open-golang
│ ├── LICENSE
│ └── open
│ ├── exec.go
│ ├── exec_darwin.go
│ ├── exec_windows.go
│ └── open.go
├── golang.org
└── x
│ ├── crypto
│ ├── LICENSE
│ ├── PATENTS
│ ├── internal
│ │ └── alias
│ │ │ ├── alias.go
│ │ │ └── alias_purego.go
│ └── nacl
│ │ └── sign
│ │ └── sign.go
│ ├── exp
│ └── typeparams
│ │ ├── LICENSE
│ │ ├── common.go
│ │ ├── normalize.go
│ │ ├── termlist.go
│ │ ├── typeparams_go117.go
│ │ ├── typeparams_go118.go
│ │ └── typeterm.go
│ ├── mod
│ ├── LICENSE
│ ├── PATENTS
│ └── semver
│ │ └── semver.go
│ ├── sync
│ ├── LICENSE
│ ├── PATENTS
│ └── errgroup
│ │ └── errgroup.go
│ ├── sys
│ ├── LICENSE
│ ├── PATENTS
│ └── windows
│ │ ├── aliases.go
│ │ ├── dll_windows.go
│ │ ├── env_windows.go
│ │ ├── eventlog.go
│ │ ├── exec_windows.go
│ │ ├── memory_windows.go
│ │ ├── mkerrors.bash
│ │ ├── mkknownfolderids.bash
│ │ ├── mksyscall.go
│ │ ├── race.go
│ │ ├── race0.go
│ │ ├── security_windows.go
│ │ ├── service.go
│ │ ├── setupapi_windows.go
│ │ ├── str.go
│ │ ├── syscall.go
│ │ ├── syscall_windows.go
│ │ ├── types_windows.go
│ │ ├── types_windows_386.go
│ │ ├── types_windows_amd64.go
│ │ ├── types_windows_arm.go
│ │ ├── types_windows_arm64.go
│ │ ├── zerrors_windows.go
│ │ ├── zknownfolderids_windows.go
│ │ └── zsyscall_windows.go
│ └── tools
│ ├── LICENSE
│ ├── PATENTS
│ ├── go
│ ├── analysis
│ │ ├── analysis.go
│ │ ├── diagnostic.go
│ │ ├── doc.go
│ │ ├── passes
│ │ │ └── inspect
│ │ │ │ └── inspect.go
│ │ └── validate.go
│ ├── ast
│ │ ├── astutil
│ │ │ ├── enclosing.go
│ │ │ ├── imports.go
│ │ │ ├── rewrite.go
│ │ │ └── util.go
│ │ └── inspector
│ │ │ ├── inspector.go
│ │ │ ├── iter.go
│ │ │ ├── typeof.go
│ │ │ └── walk.go
│ ├── buildutil
│ │ ├── allpackages.go
│ │ ├── fakecontext.go
│ │ ├── overlay.go
│ │ ├── tags.go
│ │ └── util.go
│ ├── gcexportdata
│ │ ├── gcexportdata.go
│ │ └── importer.go
│ ├── internal
│ │ └── cgo
│ │ │ ├── cgo.go
│ │ │ └── cgo_pkgconfig.go
│ ├── loader
│ │ ├── doc.go
│ │ ├── loader.go
│ │ └── util.go
│ ├── packages
│ │ ├── doc.go
│ │ ├── external.go
│ │ ├── golist.go
│ │ ├── golist_overlay.go
│ │ ├── loadmode_string.go
│ │ ├── packages.go
│ │ └── visit.go
│ └── types
│ │ ├── objectpath
│ │ └── objectpath.go
│ │ └── typeutil
│ │ ├── callee.go
│ │ ├── imports.go
│ │ ├── map.go
│ │ ├── methodsetcache.go
│ │ └── ui.go
│ └── internal
│ ├── aliases
│ ├── aliases.go
│ └── aliases_go122.go
│ ├── astutil
│ └── edge
│ │ └── edge.go
│ ├── event
│ ├── core
│ │ ├── event.go
│ │ ├── export.go
│ │ └── fast.go
│ ├── doc.go
│ ├── event.go
│ ├── keys
│ │ ├── keys.go
│ │ ├── standard.go
│ │ └── util.go
│ └── label
│ │ └── label.go
│ ├── gcimporter
│ ├── bimport.go
│ ├── exportdata.go
│ ├── gcimporter.go
│ ├── iexport.go
│ ├── iimport.go
│ ├── iimport_go122.go
│ ├── predeclared.go
│ ├── support.go
│ └── ureader_yes.go
│ ├── gocommand
│ ├── invoke.go
│ ├── invoke_notunix.go
│ ├── invoke_unix.go
│ ├── vendor.go
│ └── version.go
│ ├── packagesinternal
│ └── packages.go
│ ├── pkgbits
│ ├── codes.go
│ ├── decoder.go
│ ├── doc.go
│ ├── encoder.go
│ ├── flags.go
│ ├── reloc.go
│ ├── support.go
│ ├── sync.go
│ ├── syncmarker_string.go
│ └── version.go
│ ├── stdlib
│ ├── deps.go
│ ├── import.go
│ ├── manifest.go
│ └── stdlib.go
│ ├── typeparams
│ ├── common.go
│ ├── coretype.go
│ ├── free.go
│ ├── normalize.go
│ ├── termlist.go
│ └── typeterm.go
│ ├── typesinternal
│ ├── classify_call.go
│ ├── element.go
│ ├── errorcode.go
│ ├── errorcode_string.go
│ ├── qualifier.go
│ ├── recv.go
│ ├── toonew.go
│ ├── types.go
│ ├── varkind.go
│ └── zerovalue.go
│ └── versions
│ ├── features.go
│ ├── gover.go
│ ├── types.go
│ └── versions.go
├── honnef.co
└── go
│ └── tools
│ ├── LICENSE
│ ├── LICENSE-THIRD-PARTY
│ ├── analysis
│ ├── callcheck
│ │ └── callcheck.go
│ ├── code
│ │ ├── code.go
│ │ └── visit.go
│ ├── edit
│ │ └── edit.go
│ ├── facts
│ │ ├── deprecated
│ │ │ └── deprecated.go
│ │ ├── directives
│ │ │ └── directives.go
│ │ ├── generated
│ │ │ └── generated.go
│ │ ├── nilness
│ │ │ └── nilness.go
│ │ ├── purity
│ │ │ └── purity.go
│ │ ├── tokenfile
│ │ │ └── token.go
│ │ └── typedness
│ │ │ └── typedness.go
│ ├── lint
│ │ └── lint.go
│ └── report
│ │ └── report.go
│ ├── cmd
│ └── staticcheck
│ │ ├── README.md
│ │ └── staticcheck.go
│ ├── config
│ ├── config.go
│ └── example.conf
│ ├── go
│ ├── ast
│ │ └── astutil
│ │ │ ├── upstream.go
│ │ │ └── util.go
│ ├── buildid
│ │ ├── UPSTREAM
│ │ ├── buildid.go
│ │ └── note.go
│ ├── ir
│ │ ├── LICENSE
│ │ ├── UPSTREAM
│ │ ├── blockopt.go
│ │ ├── builder.go
│ │ ├── const.go
│ │ ├── create.go
│ │ ├── doc.go
│ │ ├── dom.go
│ │ ├── emit.go
│ │ ├── exits.go
│ │ ├── func.go
│ │ ├── html.go
│ │ ├── irutil
│ │ │ ├── load.go
│ │ │ ├── loops.go
│ │ │ ├── stub.go
│ │ │ ├── switch.go
│ │ │ ├── terminates.go
│ │ │ ├── util.go
│ │ │ └── visit.go
│ │ ├── lift.go
│ │ ├── lvalue.go
│ │ ├── methods.go
│ │ ├── mode.go
│ │ ├── print.go
│ │ ├── sanity.go
│ │ ├── source.go
│ │ ├── ssa.go
│ │ ├── util.go
│ │ ├── wrappers.go
│ │ └── write.go
│ ├── loader
│ │ ├── hash.go
│ │ └── loader.go
│ └── types
│ │ └── typeutil
│ │ ├── ext.go
│ │ ├── typeparams.go
│ │ ├── upstream.go
│ │ └── util.go
│ ├── internal
│ ├── passes
│ │ └── buildir
│ │ │ └── buildir.go
│ ├── renameio
│ │ ├── UPSTREAM
│ │ └── renameio.go
│ ├── robustio
│ │ ├── UPSTREAM
│ │ ├── robustio.go
│ │ ├── robustio_darwin.go
│ │ ├── robustio_flaky.go
│ │ ├── robustio_other.go
│ │ └── robustio_windows.go
│ ├── sharedcheck
│ │ └── lint.go
│ └── sync
│ │ └── sync.go
│ ├── knowledge
│ ├── arg.go
│ ├── deprecated.go
│ ├── doc.go
│ ├── signatures.go
│ └── targets.go
│ ├── lintcmd
│ ├── cache
│ │ ├── UPSTREAM
│ │ ├── cache.go
│ │ ├── default.go
│ │ └── hash.go
│ ├── cmd.go
│ ├── config.go
│ ├── directives.go
│ ├── format.go
│ ├── lint.go
│ ├── runner
│ │ ├── runner.go
│ │ └── stats.go
│ ├── sarif.go
│ ├── stats.go
│ ├── stats_bsd.go
│ ├── stats_posix.go
│ └── version
│ │ ├── buildinfo.go
│ │ └── version.go
│ ├── pattern
│ ├── convert.go
│ ├── doc.go
│ ├── lexer.go
│ ├── match.go
│ ├── parser.go
│ └── pattern.go
│ ├── printf
│ ├── fuzz.go
│ └── printf.go
│ ├── quickfix
│ ├── analysis.go
│ ├── doc.go
│ ├── qf1001
│ │ └── qf1001.go
│ ├── qf1002
│ │ └── qf1002.go
│ ├── qf1003
│ │ └── qf1003.go
│ ├── qf1004
│ │ └── qf1004.go
│ ├── qf1005
│ │ └── qf1005.go
│ ├── qf1006
│ │ └── qf1006.go
│ ├── qf1007
│ │ └── qf1007.go
│ ├── qf1008
│ │ └── qf1008.go
│ ├── qf1009
│ │ └── qf1009.go
│ ├── qf1010
│ │ └── qf1010.go
│ ├── qf1011
│ │ └── qf1011.go
│ └── qf1012
│ │ └── qf1012.go
│ ├── sarif
│ └── sarif.go
│ ├── simple
│ ├── analysis.go
│ ├── doc.go
│ ├── s1000
│ │ └── s1000.go
│ ├── s1001
│ │ └── s1001.go
│ ├── s1002
│ │ └── s1002.go
│ ├── s1003
│ │ └── s1003.go
│ ├── s1004
│ │ └── s1004.go
│ ├── s1005
│ │ └── s1005.go
│ ├── s1006
│ │ └── s1006.go
│ ├── s1007
│ │ └── s1007.go
│ ├── s1008
│ │ └── s1008.go
│ ├── s1009
│ │ └── s1009.go
│ ├── s1010
│ │ └── s1010.go
│ ├── s1011
│ │ └── s1011.go
│ ├── s1012
│ │ └── s1012.go
│ ├── s1016
│ │ └── s1016.go
│ ├── s1017
│ │ └── s1017.go
│ ├── s1018
│ │ └── s1018.go
│ ├── s1019
│ │ └── s1019.go
│ ├── s1020
│ │ └── s1020.go
│ ├── s1021
│ │ └── s1021.go
│ ├── s1023
│ │ └── s1023.go
│ ├── s1024
│ │ └── s1024.go
│ ├── s1025
│ │ └── s1025.go
│ ├── s1028
│ │ └── s1028.go
│ ├── s1029
│ │ └── s1029.go
│ ├── s1030
│ │ └── s1030.go
│ ├── s1031
│ │ └── s1031.go
│ ├── s1032
│ │ └── s1032.go
│ ├── s1033
│ │ └── s1033.go
│ ├── s1034
│ │ └── s1034.go
│ ├── s1035
│ │ └── s1035.go
│ ├── s1036
│ │ └── s1036.go
│ ├── s1037
│ │ └── s1037.go
│ ├── s1038
│ │ └── s1038.go
│ ├── s1039
│ │ └── s1039.go
│ └── s1040
│ │ └── s1040.go
│ ├── staticcheck
│ ├── analysis.go
│ ├── doc.go
│ ├── fakejson
│ │ └── encode.go
│ ├── fakereflect
│ │ └── fakereflect.go
│ ├── fakexml
│ │ ├── marshal.go
│ │ ├── typeinfo.go
│ │ └── xml.go
│ ├── sa1000
│ │ └── sa1000.go
│ ├── sa1001
│ │ └── sa1001.go
│ ├── sa1002
│ │ └── sa1002.go
│ ├── sa1003
│ │ └── sa1003.go
│ ├── sa1004
│ │ └── sa1004.go
│ ├── sa1005
│ │ └── sa1005.go
│ ├── sa1006
│ │ └── sa1006.go
│ ├── sa1007
│ │ └── sa1007.go
│ ├── sa1008
│ │ └── sa1008.go
│ ├── sa1010
│ │ └── sa1010.go
│ ├── sa1011
│ │ └── sa1011.go
│ ├── sa1012
│ │ └── sa1012.go
│ ├── sa1013
│ │ └── sa1013.go
│ ├── sa1014
│ │ └── sa1014.go
│ ├── sa1015
│ │ └── sa1015.go
│ ├── sa1016
│ │ └── sa1016.go
│ ├── sa1017
│ │ └── sa1017.go
│ ├── sa1018
│ │ └── sa1018.go
│ ├── sa1019
│ │ └── sa1019.go
│ ├── sa1020
│ │ └── sa1020.go
│ ├── sa1021
│ │ └── sa1021.go
│ ├── sa1023
│ │ └── sa1023.go
│ ├── sa1024
│ │ └── sa1024.go
│ ├── sa1025
│ │ └── sa1025.go
│ ├── sa1026
│ │ └── sa1026.go
│ ├── sa1027
│ │ └── sa1027.go
│ ├── sa1028
│ │ └── sa1028.go
│ ├── sa1029
│ │ └── sa1029.go
│ ├── sa1030
│ │ └── sa1030.go
│ ├── sa1031
│ │ └── sa1031.go
│ ├── sa1032
│ │ └── sa1032.go
│ ├── sa2000
│ │ └── sa2000.go
│ ├── sa2001
│ │ └── sa2001.go
│ ├── sa2002
│ │ └── sa2002.go
│ ├── sa2003
│ │ └── sa2003.go
│ ├── sa3000
│ │ └── sa3000.go
│ ├── sa3001
│ │ └── sa3001.go
│ ├── sa4000
│ │ └── sa4000.go
│ ├── sa4001
│ │ └── sa4001.go
│ ├── sa4003
│ │ └── sa4003.go
│ ├── sa4004
│ │ └── sa4004.go
│ ├── sa4005
│ │ └── sa4005.go
│ ├── sa4006
│ │ └── sa4006.go
│ ├── sa4008
│ │ └── sa4008.go
│ ├── sa4009
│ │ └── sa4009.go
│ ├── sa4010
│ │ └── sa4010.go
│ ├── sa4011
│ │ └── sa4011.go
│ ├── sa4012
│ │ └── sa4012.go
│ ├── sa4013
│ │ └── sa4013.go
│ ├── sa4014
│ │ └── sa4014.go
│ ├── sa4015
│ │ └── sa4015.go
│ ├── sa4016
│ │ └── sa4016.go
│ ├── sa4017
│ │ └── sa4017.go
│ ├── sa4018
│ │ └── sa4018.go
│ ├── sa4019
│ │ └── sa4019.go
│ ├── sa4020
│ │ └── sa4020.go
│ ├── sa4021
│ │ └── sa4021.go
│ ├── sa4022
│ │ └── sa4022.go
│ ├── sa4023
│ │ └── sa4023.go
│ ├── sa4024
│ │ └── sa4024.go
│ ├── sa4025
│ │ └── sa4025.go
│ ├── sa4026
│ │ └── sa4026.go
│ ├── sa4027
│ │ └── sa4027.go
│ ├── sa4028
│ │ └── sa4028.go
│ ├── sa4029
│ │ └── sa4029.go
│ ├── sa4030
│ │ └── sa4030.go
│ ├── sa4031
│ │ └── sa4031.go
│ ├── sa4032
│ │ └── sa4032.go
│ ├── sa5000
│ │ └── sa5000.go
│ ├── sa5001
│ │ └── sa5001.go
│ ├── sa5002
│ │ └── sa5002.go
│ ├── sa5003
│ │ └── sa5003.go
│ ├── sa5004
│ │ └── sa5004.go
│ ├── sa5005
│ │ └── sa5005.go
│ ├── sa5007
│ │ └── sa5007.go
│ ├── sa5008
│ │ ├── sa5008.go
│ │ └── structtag.go
│ ├── sa5009
│ │ └── sa5009.go
│ ├── sa5010
│ │ └── sa5010.go
│ ├── sa5011
│ │ └── sa5011.go
│ ├── sa5012
│ │ └── sa5012.go
│ ├── sa6000
│ │ └── sa6000.go
│ ├── sa6001
│ │ └── sa6001.go
│ ├── sa6002
│ │ └── sa6002.go
│ ├── sa6003
│ │ └── sa6003.go
│ ├── sa6005
│ │ └── sa6005.go
│ ├── sa6006
│ │ └── sa6006.go
│ ├── sa9001
│ │ └── sa9001.go
│ ├── sa9002
│ │ └── sa9002.go
│ ├── sa9003
│ │ └── sa9003.go
│ ├── sa9004
│ │ └── sa9004.go
│ ├── sa9005
│ │ └── sa9005.go
│ ├── sa9006
│ │ └── sa9006.go
│ ├── sa9007
│ │ └── sa9007.go
│ ├── sa9008
│ │ └── sa9008.go
│ └── sa9009
│ │ └── sa9009.go
│ ├── stylecheck
│ ├── analysis.go
│ ├── doc.go
│ ├── st1000
│ │ └── st1000.go
│ ├── st1001
│ │ └── st1001.go
│ ├── st1003
│ │ └── st1003.go
│ ├── st1005
│ │ └── st1005.go
│ ├── st1006
│ │ └── st1006.go
│ ├── st1008
│ │ └── st1008.go
│ ├── st1011
│ │ └── st1011.go
│ ├── st1012
│ │ └── st1012.go
│ ├── st1013
│ │ └── st1013.go
│ ├── st1015
│ │ └── st1015.go
│ ├── st1016
│ │ └── st1016.go
│ ├── st1017
│ │ └── st1017.go
│ ├── st1018
│ │ └── st1018.go
│ ├── st1019
│ │ └── st1019.go
│ ├── st1020
│ │ └── st1020.go
│ ├── st1021
│ │ └── st1021.go
│ ├── st1022
│ │ └── st1022.go
│ └── st1023
│ │ └── st1023.go
│ └── unused
│ ├── implements.go
│ ├── runtime.go
│ ├── serialize.go
│ └── unused.go
└── modules.txt
/.github/workflows/release.yml:
--------------------------------------------------------------------------------
1 | name: gclpr release
2 |
3 | on:
4 | create:
5 | tags:
6 | - "v*.*.*"
7 |
8 | permissions:
9 | contents: write
10 |
11 | jobs:
12 |
13 | build:
14 | runs-on: ubuntu-latest
15 | steps:
16 |
17 | - name: Checkout sources
18 | uses: actions/checkout@v4
19 |
20 | - name: Install mingw-w64 resource compiler
21 | uses: awalsh128/cache-apt-pkgs-action@latest
22 | with:
23 | packages: mingw-w64 binutils-mingw-w64-x86-64
24 | version: 1.0
25 |
26 | - name: Install Task
27 | uses: arduino/setup-task@v2
28 | with:
29 | version: 3.x
30 |
31 | - name: Set up Go
32 | uses: actions/setup-go@v5
33 | with:
34 | go-version: '1.24.3'
35 |
36 | - name: Build everything
37 | run: task release -v
38 |
39 | - name: Sign release artifacts
40 | # After lunar this could be replaced with "apt install minisign"
41 | uses: thomasdesr/minisign-action@v1
42 | with:
43 | args: -Sm release/gclpr_*.zip
44 | minisign_key: ${{ secrets.minisign_key }}
45 | password: ${{ secrets.minisign_password }}
46 |
47 | - name: List results
48 | run: ls -lah release/
49 |
50 | - name: Upload release
51 | uses: softprops/action-gh-release@v2
52 | if: startsWith(github.ref, 'refs/tags/')
53 | with:
54 | generate_release_notes: true
55 | files: |
56 | gclpr.json
57 | release/gclpr_*.zip
58 | release/gclpr_*.minisig
59 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | *.exe
2 | *.exe~
3 | *.dll
4 | *.so
5 | *.dylib
6 | *.out
7 | *.test
8 | *.prof
9 | *.mprof
10 | *.log
11 | *.syso
12 |
13 | # build specific
14 | build/
15 | release/
16 | build_*/
17 | misc/version.go
18 | cmd/*/resources.rc
19 | cmd/*/manifest.xml
20 | gclpr.json
21 | gclpr_*.zip
22 | gclpr_*.minisig
23 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2021 rupor
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/cmd/gui/icon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rupor-github/gclpr/fbfee1756d4e8def3e94214c9f6c05fe91db0df7/cmd/gui/icon.ico
--------------------------------------------------------------------------------
/docs/clip.svg:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/go.mod:
--------------------------------------------------------------------------------
1 | module github.com/rupor-github/gclpr
2 |
3 | go 1.24.3
4 |
5 | tool (
6 | github.com/jstarks/npiperelay
7 | honnef.co/go/tools/cmd/staticcheck
8 | )
9 |
10 | require (
11 | github.com/allan-simon/go-singleinstance v0.0.0-20210120080615-d0997106ab37
12 | github.com/atotto/clipboard v0.1.4
13 | github.com/skratchdot/open-golang v0.0.0-20200116055534-eef842397966
14 | golang.org/x/crypto v0.38.0
15 | golang.org/x/sys v0.33.0
16 | )
17 |
18 | require (
19 | github.com/BurntSushi/toml v1.5.0 // indirect
20 | github.com/google/go-cmp v0.7.0 // indirect
21 | github.com/jstarks/npiperelay v0.1.0 // indirect
22 | golang.org/x/exp/typeparams v0.0.0-20250506013437-ce4c2cf36ca6 // indirect
23 | golang.org/x/mod v0.24.0 // indirect
24 | golang.org/x/sync v0.14.0 // indirect
25 | golang.org/x/tools v0.33.0 // indirect
26 | honnef.co/go/tools v0.6.1 // indirect
27 | )
28 |
--------------------------------------------------------------------------------
/scripts/bash/checkall.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | for file in $@; do
3 | if [ ! -f $file ]; then
4 | exit 1
5 | fi
6 | done
7 | exit 0
8 |
--------------------------------------------------------------------------------
/scripts/bash/vercmp.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | # source: https://github.com/awslabs/amazon-eks-ami/blob/master/files/bin/vercmp under MIT-0 license
4 |
5 | # Comparison expressions for semantic versions.
6 | # only supports semver standard MAJOR.MINOR.PATCH syntax;
7 | # pre-release or build-metadata extensions have undefined behavior.
8 |
9 | set -o errexit
10 | set -o pipefail
11 |
12 | function usage() {
13 | echo "Comparison expressions for semantic versions."
14 | echo
15 | echo "usage: vercmp VERSION_A OPERATOR VERSION_B"
16 | echo
17 | echo "OPERATORS"
18 | echo
19 | echo " lt - Less than"
20 | echo " lteq - Less than or equal to"
21 | echo " eq - Equal to"
22 | echo " gteq - Grater than or equal to"
23 | echo " gt - Greater than"
24 | echo
25 | }
26 |
27 | if [ "$#" -ne 3 ]; then
28 | usage
29 | exit 1
30 | fi
31 |
32 | LEFT="$1"
33 | OPERATOR="$2"
34 | RIGHT="$3"
35 |
36 | if [ "$LEFT" = "$RIGHT" ]; then
37 | COMPARISON=0
38 | else
39 | SORTED=($(for VER in "$LEFT" "$RIGHT"; do echo "$VER"; done | sort -V))
40 | if [ "${SORTED[0]}" = "$LEFT" ]; then
41 | COMPARISON=-1
42 | else
43 | COMPARISON=1
44 | fi
45 | fi
46 |
47 | OUTCOME=false
48 |
49 | case $OPERATOR in
50 | lt)
51 | if [ "$COMPARISON" -eq -1 ]; then
52 | OUTCOME=true
53 | fi
54 | ;;
55 |
56 | lteq)
57 | if [ "$COMPARISON" -lt 1 ]; then
58 | OUTCOME=true
59 | fi
60 | ;;
61 |
62 | eq)
63 | if [ "$COMPARISON" -eq 0 ]; then
64 | OUTCOME=true
65 | fi
66 | ;;
67 |
68 | gteq)
69 | if [ "$COMPARISON" -gt -1 ]; then
70 | OUTCOME=true
71 | fi
72 | ;;
73 |
74 | gt)
75 | if [ "$COMPARISON" -eq 1 ]; then
76 | OUTCOME=true
77 | fi
78 | ;;
79 |
80 | *)
81 | usage
82 | exit 1
83 | ;;
84 | esac
85 |
86 | VERCMP_QUIET="${VERCMP_QUIET:-false}"
87 | if [ ! "$VERCMP_QUIET" = "true" ]; then
88 | echo "$OUTCOME"
89 | fi
90 |
91 | if [ "$OUTCOME" = "true" ]; then
92 | exit 0
93 | else
94 | exit 1
95 | fi
96 |
--------------------------------------------------------------------------------
/scripts/git/pre-commit:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | # Copyright 2012 The Go Authors. All rights reserved.
3 | # Use of this source code is governed by a BSD-style
4 | # license that can be found in the LICENSE file.
5 |
6 | # git gofmt pre-commit hook
7 | #
8 | # To use, store as .git/hooks/pre-commit inside your repository and make sure
9 | # it has execute permissions.
10 | #
11 | # This script does not handle file names that contain spaces.
12 |
13 | gofiles=$(git diff --cached --name-only --diff-filter=ACM | grep '\.go$')
14 | [ -z "$gofiles" ] && exit 0
15 |
16 | unformatted=$(gofmt -l $gofiles | grep -v 'vendor/')
17 | [ -z "$unformatted" ] && exit 0
18 |
19 | # Some files are not gofmt'd. Print message and fail.
20 |
21 | echo >&2 "Go files must be formatted with gofmt. Please run:"
22 | for fn in $unformatted; do
23 | echo >&2 " gofmt -w $PWD/$fn"
24 | done
25 |
26 | exit 1
27 |
--------------------------------------------------------------------------------
/scripts/git/pre-push:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | # To use, store as .git/hooks/pre-push inside your repository and make sure
3 | # it has execute permissions.
4 |
5 | # run security/vulnerabilities scanner prior to pushing to repo
6 |
7 | scanner=$(command -v trivy || command -v govulncheck)
8 | if [ -z "${scanner}" ]; then
9 | echo "==== No suitable (govulncheck or trivy) vulnerabilities scanner is installed. Make sure it is installed and path is set correctly"
10 | echo
11 | echo " To install govulncheck you could use something similar to \"GOBIN= go install golang.org/x/vuln/cmd/govulncheck@latest\""
12 | echo " and make sure that is added to PATH"
13 | echo
14 | echo " To install trivy follow instructions on https://github.com/aquasecurity/trivy/blob/main/docs/getting-started/installation.md#debianubuntu"
15 | exit 1
16 | fi
17 |
18 | echo "==== running ${scanner} from $0"
19 | if [ "$(basename ${scanner})" = "trivy" ]; then
20 | echo " to accept risks create a .trivyignore file in repo's root"
21 | echo " See https://github.com/aquasecurity/trivy/blob/main/docs/docs/vulnerability/examples/filter.md#by-vulnerability-ids"
22 | # without the --exit-code 1 flag - trivy always exists with 0
23 | ${scanner} --exit-code 1 fs --ignore-unfixed .
24 | elif [ "$(basename ${scanner})" = "govulncheck" ]; then
25 | set -eo pipefail
26 | tmp="$(mktemp)"
27 | ${scanner} -show color,verbose ./... |& tee ${tmp}
28 | # govulncheck ignores vulnerabilities in the imported packages if it thinks our code is not calling relevant functionality
29 | # at the moment we do not want this...
30 | if grep -qE 'Vulnerability.* #' ${tmp}; then
31 | echo
32 | echo $(tput setaf 4)"=== Found vulnerabilities, please fix them before pushing"$(tput sgr0)
33 | exit 1
34 | fi
35 | else
36 | echo "==== WTF is ${scanner}?"
37 | exit 2
38 | fi
39 |
--------------------------------------------------------------------------------
/server/clipboard.go:
--------------------------------------------------------------------------------
1 | package server
2 |
3 | import (
4 | "log"
5 |
6 | "github.com/atotto/clipboard"
7 | )
8 |
9 | // Clipboard is used to rpc clipboard content.
10 | type Clipboard struct {
11 | leOP string
12 | }
13 |
14 | // NewClipboard initializes Clipboard structure.
15 | func NewClipboard(le string) *Clipboard {
16 | return &Clipboard{leOP: le}
17 | }
18 |
19 | // Copy is implementation of rpc "copy" command.
20 | func (c *Clipboard) Copy(text string, _ *struct{}) error {
21 | log.Printf("Copy request received len: %d\n", len(text))
22 | return clipboard.WriteAll(ConvertLE(text, c.leOP))
23 | }
24 |
25 | // Paste is implementation of rpc "paste" command.
26 | func (c *Clipboard) Paste(_ struct{}, resp *string) error {
27 | t, err := clipboard.ReadAll()
28 | log.Printf("Paste request received len: %d, error: '%+v'\n", len(t), err)
29 | *resp = t
30 | return err
31 | }
32 |
--------------------------------------------------------------------------------
/server/helpers.go:
--------------------------------------------------------------------------------
1 | package server
2 |
3 | import (
4 | "regexp"
5 | "strings"
6 | )
7 |
8 | // ConvertLE is used to normaliza line endings when exchanging clipboard content.
9 | func ConvertLE(text, op string) string {
10 | switch {
11 | case strings.EqualFold("lf", op):
12 | text = strings.ReplaceAll(text, "\r\n", "\n")
13 | return strings.ReplaceAll(text, "\r", "\n")
14 | case strings.EqualFold("crlf", op):
15 | text = regexp.MustCompile(`\r(.)|\r$`).ReplaceAllString(text, "\r\n$1")
16 | text = regexp.MustCompile(`([^\r])\n|^\n`).ReplaceAllString(text, "$1\r\n")
17 | return text
18 | default:
19 | return text
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/server/uri.go:
--------------------------------------------------------------------------------
1 | package server
2 |
3 | import (
4 | "log"
5 |
6 | "github.com/skratchdot/open-golang/open"
7 | )
8 |
9 | // URI is used to rpc open command.
10 | type URI struct {
11 | // placeholder
12 | }
13 |
14 | // NewURI initializes URI structure.
15 | func NewURI() *URI {
16 | return &URI{}
17 | }
18 |
19 | // Open is implementation of "lemonade" rpc "open" command.
20 | func (u *URI) Open(uri string, _ *struct{}) error {
21 | log.Printf("URI Open received: '%s'", uri)
22 | return open.Run(uri)
23 | }
24 |
--------------------------------------------------------------------------------
/util/consts.go:
--------------------------------------------------------------------------------
1 | // vim: ft=txt
2 | package util
3 |
4 | // vim-go regexp magic does not like long hex strings, so do not turn on syntax highlighting on this file...
5 | // nolint
6 | const (
7 | ed25519_p = "7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFED"
8 | ed25519_b = "2DFC9311D490018C7338BF8688861767FF8FF5B2BEBE27548A14B235ECA6874A"
9 | ed25519_g = "04216936D3CD6E53FEC0A4E231FDD6DC5C692CC7609525A7B2C9562D608F25D51A6666666666666666666666666666666666666666666666666666666666666658"
10 | ed25519_n = "1000000000000000000000000000000014DEF9DEA2F79CD65812631A5CF5D3ED"
11 | )
12 |
--------------------------------------------------------------------------------
/util/files_unix.go:
--------------------------------------------------------------------------------
1 | //go:build linux || darwin
2 |
3 | package util
4 |
5 | import (
6 | "fmt"
7 | "os"
8 | "syscall"
9 | )
10 |
11 | func checkPermissions(fname string, readOK bool) error {
12 |
13 | fi, err := os.Stat(fname)
14 | if err != nil || !fi.Mode().IsRegular() {
15 | return fmt.Errorf("not a regular file %s", fname)
16 | }
17 |
18 | var uid int
19 | if stat, ok := fi.Sys().(*syscall.Stat_t); ok {
20 | uid = int(stat.Uid)
21 | }
22 | perm := fi.Mode().Perm()
23 | if !readOK && uid == os.Getuid() && (perm&077) != 0 {
24 | return fmt.Errorf("bad permissions %o for file %s", perm, fname)
25 | }
26 | return nil
27 | }
28 |
--------------------------------------------------------------------------------
/util/log_unix.go:
--------------------------------------------------------------------------------
1 | //go:build linux || darwin
2 |
3 | package util
4 |
5 | import (
6 | "io"
7 | "log"
8 | )
9 |
10 | // NewLogWriter redirects all log output depending on debug parameetr.
11 | // When true all output goes to OutputDebugString and you could use debugger or Sysinternals dbgview.exe to collect it.
12 | // When false - everything is discarded.
13 | func NewLogWriter(title string, flags int, debug bool) {
14 |
15 | log.SetPrefix("[" + title + "] ")
16 | log.SetFlags(flags)
17 |
18 | if !debug {
19 | log.SetOutput(io.Discard)
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/util/log_windows.go:
--------------------------------------------------------------------------------
1 | //go:build windows
2 |
3 | package util
4 |
5 | import (
6 | "io"
7 | "log"
8 | "unsafe"
9 |
10 | "golang.org/x/sys/windows"
11 | )
12 |
13 | var kernel = windows.NewLazySystemDLL("kernel32")
14 |
15 | // DebugWriter redirects all output to OutputDebugString().
16 | type logWriter struct {
17 | proc *windows.LazyProc
18 | }
19 |
20 | // NewLogWriter redirects all log output depending on debug parameetr.
21 | // When true all output goes to OutputDebugString and you could use debugger or Sysinternals dbgview.exe to collect it.
22 | // When false - everything is discarded.
23 | func NewLogWriter(title string, flags int, debug bool) {
24 |
25 | log.SetPrefix("[" + title + "] ")
26 | log.SetFlags(flags)
27 |
28 | if debug {
29 | res := &logWriter{proc: kernel.NewProc("OutputDebugStringW")}
30 | log.SetOutput(res)
31 | } else {
32 | log.SetOutput(io.Discard)
33 | }
34 | }
35 |
36 | func (l *logWriter) Write(p []byte) (n int, err error) {
37 |
38 | text, err := windows.UTF16PtrFromString(string(p))
39 | if err != nil {
40 | return 0, err
41 | }
42 | _, _, _ = l.proc.Call(uintptr(unsafe.Pointer(text)))
43 | return len(p), nil
44 | }
45 |
--------------------------------------------------------------------------------
/util/mbox_unix.go:
--------------------------------------------------------------------------------
1 | //go:build linux || darwin
2 |
3 | package util
4 |
--------------------------------------------------------------------------------
/util/util_test.go:
--------------------------------------------------------------------------------
1 | package util
2 |
3 | import (
4 | "encoding/hex"
5 | "strings"
6 | "testing"
7 | )
8 |
9 | func TestKeyGrip(t *testing.T) {
10 |
11 | k, err := hex.DecodeString("773E72848C1FD5F9652B29E2E7AF79571A04990E96F2016BF4E0EC1890C2B7DB")
12 | if err != nil {
13 | t.Fatal(err)
14 | }
15 |
16 | var pk [32]byte
17 | copy(pk[:], k)
18 |
19 | grip := GPGKeyGripED25519(pk)
20 | gstr := strings.ToUpper(hex.EncodeToString(grip))
21 |
22 | t.Logf("GRIP: %s", gstr)
23 |
24 | if gstr != "9DB6C64A38830F4960701789475520BE8C821F47" {
25 | t.Fatal("Bad key grip")
26 | }
27 | }
28 |
29 | /*
30 | func TestCheckWin(t *testing.T) {
31 |
32 | var err error
33 | home, _ := os.UserHomeDir()
34 |
35 | err = checkPermissions(filepath.Join(home, ".gclpr", "trusted"), true)
36 | if err != nil {
37 | t.Fatalf("ERROR: %s", err)
38 | }
39 | err = checkPermissions(filepath.Join("D:/", "trusted"), true)
40 | if err != nil {
41 | t.Logf("EXPECTED ERROR: %s", err)
42 | } else {
43 | t.Fatal("NOT OK")
44 | }
45 | t.Log("OK")
46 | }
47 | */
48 |
--------------------------------------------------------------------------------
/vendor/github.com/BurntSushi/toml/.gitignore:
--------------------------------------------------------------------------------
1 | /toml.test
2 | /toml-test
3 |
--------------------------------------------------------------------------------
/vendor/github.com/BurntSushi/toml/COPYING:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2013 TOML authors
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in
13 | all copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 | THE SOFTWARE.
22 |
--------------------------------------------------------------------------------
/vendor/github.com/BurntSushi/toml/deprecated.go:
--------------------------------------------------------------------------------
1 | package toml
2 |
3 | import (
4 | "encoding"
5 | "io"
6 | )
7 |
8 | // TextMarshaler is an alias for encoding.TextMarshaler.
9 | //
10 | // Deprecated: use encoding.TextMarshaler
11 | type TextMarshaler encoding.TextMarshaler
12 |
13 | // TextUnmarshaler is an alias for encoding.TextUnmarshaler.
14 | //
15 | // Deprecated: use encoding.TextUnmarshaler
16 | type TextUnmarshaler encoding.TextUnmarshaler
17 |
18 | // DecodeReader is an alias for NewDecoder(r).Decode(v).
19 | //
20 | // Deprecated: use NewDecoder(reader).Decode(&value).
21 | func DecodeReader(r io.Reader, v any) (MetaData, error) { return NewDecoder(r).Decode(v) }
22 |
23 | // PrimitiveDecode is an alias for MetaData.PrimitiveDecode().
24 | //
25 | // Deprecated: use MetaData.PrimitiveDecode.
26 | func PrimitiveDecode(primValue Primitive, v any) error {
27 | md := MetaData{decoded: make(map[string]struct{})}
28 | return md.unify(primValue.undecoded, rvalue(v))
29 | }
30 |
--------------------------------------------------------------------------------
/vendor/github.com/BurntSushi/toml/doc.go:
--------------------------------------------------------------------------------
1 | // Package toml implements decoding and encoding of TOML files.
2 | //
3 | // This package supports TOML v1.0.0, as specified at https://toml.io
4 | //
5 | // The github.com/BurntSushi/toml/cmd/tomlv package implements a TOML validator,
6 | // and can be used to verify if TOML document is valid. It can also be used to
7 | // print the type of each key.
8 | package toml
9 |
--------------------------------------------------------------------------------
/vendor/github.com/BurntSushi/toml/internal/tz.go:
--------------------------------------------------------------------------------
1 | package internal
2 |
3 | import "time"
4 |
5 | // Timezones used for local datetime, date, and time TOML types.
6 | //
7 | // The exact way times and dates without a timezone should be interpreted is not
8 | // well-defined in the TOML specification and left to the implementation. These
9 | // defaults to current local timezone offset of the computer, but this can be
10 | // changed by changing these variables before decoding.
11 | //
12 | // TODO:
13 | // Ideally we'd like to offer people the ability to configure the used timezone
14 | // by setting Decoder.Timezone and Encoder.Timezone; however, this is a bit
15 | // tricky: the reason we use three different variables for this is to support
16 | // round-tripping – without these specific TZ names we wouldn't know which
17 | // format to use.
18 | //
19 | // There isn't a good way to encode this right now though, and passing this sort
20 | // of information also ties in to various related issues such as string format
21 | // encoding, encoding of comments, etc.
22 | //
23 | // So, for the time being, just put this in internal until we can write a good
24 | // comprehensive API for doing all of this.
25 | //
26 | // The reason they're exported is because they're referred from in e.g.
27 | // internal/tag.
28 | //
29 | // Note that this behaviour is valid according to the TOML spec as the exact
30 | // behaviour is left up to implementations.
31 | var (
32 | localOffset = func() int { _, o := time.Now().Zone(); return o }()
33 | LocalDatetime = time.FixedZone("datetime-local", localOffset)
34 | LocalDate = time.FixedZone("date-local", localOffset)
35 | LocalTime = time.FixedZone("time-local", localOffset)
36 | )
37 |
--------------------------------------------------------------------------------
/vendor/github.com/allan-simon/go-singleinstance/.gitignore:
--------------------------------------------------------------------------------
1 | # Compiled Object files, Static and Dynamic libs (Shared Objects)
2 | *.o
3 | *.a
4 | *.so
5 |
6 | # Folders
7 | _obj
8 | _test
9 |
10 | # Architecture specific extensions/prefixes
11 | *.[568vq]
12 | [568vq].out
13 |
14 | *.cgo1.go
15 | *.cgo2.c
16 | _cgo_defun.c
17 | _cgo_gotypes.go
18 | _cgo_export.*
19 |
20 | _testmain.go
21 |
22 | *.exe
23 | *.test
24 | *.prof
25 |
--------------------------------------------------------------------------------
/vendor/github.com/allan-simon/go-singleinstance/LICENSE:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2015 Allan Simon
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
23 |
--------------------------------------------------------------------------------
/vendor/github.com/allan-simon/go-singleinstance/README.md:
--------------------------------------------------------------------------------
1 | # go-singleinstance
2 |
3 | Cross plateform library to have only one instance of a software (based on python's [tendo](https://github.com/pycontribs/tendo/blob/master/tendo/singleton.py)).
4 |
5 | ## Usage
6 |
7 | ```go
8 | package main
9 |
10 | import (
11 | "fmt"
12 | "time"
13 |
14 | "github.com/allan-simon/go-singleinstance"
15 | )
16 |
17 | func main() {
18 | lockFile, err := singleinstance.CreateLockFile("plop.lock")
19 | if err != nil {
20 | fmt.Println("An instance already exists")
21 | return
22 | }
23 | defer lockFile.Close()
24 |
25 | fmt.Println("Sleeping...")
26 | time.Sleep(10 * time.Second)
27 | fmt.Println("Done")
28 | }
29 | ```
30 |
31 | If you try to launch it twice, the second instance will fail.
32 |
33 | ## Thanks
34 |
35 | For the python library trendo, from which I've shamelessly adapted the code.
36 |
37 | ## Contribution
38 |
39 | Don't be afraid if it says "last commit 2 years ago", this library is made to be small
40 | and simple so it's unlikely it changes after some times, however I'm pretty reactive
41 | on github overall, so feel free to use issues to ask question, propose patch etc. :)
42 |
43 | ## License
44 |
45 | MIT
46 |
--------------------------------------------------------------------------------
/vendor/github.com/allan-simon/go-singleinstance/lock.go:
--------------------------------------------------------------------------------
1 | package singleinstance
2 |
3 | import (
4 | "io/ioutil"
5 | "strconv"
6 | )
7 |
8 | // If filename is a lock file, returns the PID of the process locking it
9 | func GetLockFilePid(filename string) (pid int, err error) {
10 | contents, err := ioutil.ReadFile(filename)
11 | if err != nil {
12 | return
13 | }
14 |
15 | pid, err = strconv.Atoi(string(contents))
16 | return
17 | }
18 |
--------------------------------------------------------------------------------
/vendor/github.com/allan-simon/go-singleinstance/lock_posix.go:
--------------------------------------------------------------------------------
1 | // +build !windows
2 |
3 | package singleinstance
4 |
5 | import (
6 | "os"
7 | "strconv"
8 | "syscall"
9 | )
10 |
11 | // CreateLockFile tries to create a file with given name and acquire an
12 | // exclusive lock on it. If the file already exists AND is still locked, it will
13 | // fail.
14 | func CreateLockFile(filename string) (*os.File, error) {
15 | file, err := os.OpenFile(filename, os.O_WRONLY|os.O_CREATE, 0600)
16 | if err != nil {
17 | return nil, err
18 | }
19 |
20 | err = syscall.Flock(int(file.Fd()), syscall.LOCK_EX|syscall.LOCK_NB)
21 | if err != nil {
22 | file.Close()
23 | return nil, err
24 | }
25 |
26 | // Write PID to lock file
27 | contents := strconv.Itoa(os.Getpid())
28 | if err := file.Truncate(0); err != nil {
29 | file.Close()
30 | return nil, err
31 | }
32 | if _, err := file.WriteString(contents); err != nil {
33 | file.Close()
34 | return nil, err
35 | }
36 |
37 | return file, nil
38 | }
39 |
--------------------------------------------------------------------------------
/vendor/github.com/allan-simon/go-singleinstance/lock_windows.go:
--------------------------------------------------------------------------------
1 | // +build windows
2 |
3 | package singleinstance
4 |
5 | import (
6 | "os"
7 | "strconv"
8 | )
9 |
10 | // CreateLockFile tries to create a file with given name and acquire an
11 | // exclusive lock on it. If the file already exists AND is still locked, it will
12 | // fail.
13 | func CreateLockFile(filename string) (*os.File, error) {
14 | if _, err := os.Stat(filename); err == nil {
15 | // If the files exists, we first try to remove it
16 | if err = os.Remove(filename); err != nil {
17 | return nil, err
18 | }
19 | } else if !os.IsNotExist(err) {
20 | return nil, err
21 | }
22 |
23 | file, err := os.OpenFile(filename, os.O_CREATE|os.O_EXCL|os.O_WRONLY, 0600)
24 | if err != nil {
25 | return nil, err
26 | }
27 |
28 | // Write PID to lock file
29 | _, err = file.WriteString(strconv.Itoa(os.Getpid()))
30 | if err != nil {
31 | return nil, err
32 | }
33 |
34 | return file, nil
35 | }
36 |
--------------------------------------------------------------------------------
/vendor/github.com/atotto/clipboard/.travis.yml:
--------------------------------------------------------------------------------
1 | language: go
2 |
3 | os:
4 | - linux
5 | - osx
6 | - windows
7 |
8 | go:
9 | - go1.13.x
10 | - go1.x
11 |
12 | services:
13 | - xvfb
14 |
15 | before_install:
16 | - export DISPLAY=:99.0
17 |
18 | script:
19 | - if [ "$TRAVIS_OS_NAME" = "linux" ]; then sudo apt-get install xsel; fi
20 | - go test -v .
21 | - if [ "$TRAVIS_OS_NAME" = "linux" ]; then sudo apt-get install xclip; fi
22 | - go test -v .
23 |
--------------------------------------------------------------------------------
/vendor/github.com/atotto/clipboard/LICENSE:
--------------------------------------------------------------------------------
1 | Copyright (c) 2013 Ato Araki. All rights reserved.
2 |
3 | Redistribution and use in source and binary forms, with or without
4 | modification, are permitted provided that the following conditions are
5 | met:
6 |
7 | * Redistributions of source code must retain the above copyright
8 | notice, this list of conditions and the following disclaimer.
9 | * Redistributions in binary form must reproduce the above
10 | copyright notice, this list of conditions and the following disclaimer
11 | in the documentation and/or other materials provided with the
12 | distribution.
13 | * Neither the name of @atotto. nor the names of its
14 | contributors may be used to endorse or promote products derived from
15 | this software without specific prior written permission.
16 |
17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
19 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
20 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
21 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
22 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
23 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 |
--------------------------------------------------------------------------------
/vendor/github.com/atotto/clipboard/README.md:
--------------------------------------------------------------------------------
1 | [](https://travis-ci.org/atotto/clipboard)
2 |
3 | [](http://godoc.org/github.com/atotto/clipboard)
4 |
5 | # Clipboard for Go
6 |
7 | Provide copying and pasting to the Clipboard for Go.
8 |
9 | Build:
10 |
11 | $ go get github.com/atotto/clipboard
12 |
13 | Platforms:
14 |
15 | * OSX
16 | * Windows 7 (probably work on other Windows)
17 | * Linux, Unix (requires 'xclip' or 'xsel' command to be installed)
18 |
19 |
20 | Document:
21 |
22 | * http://godoc.org/github.com/atotto/clipboard
23 |
24 | Notes:
25 |
26 | * Text string only
27 | * UTF-8 text encoding only (no conversion)
28 |
29 | TODO:
30 |
31 | * Clipboard watcher(?)
32 |
33 | ## Commands:
34 |
35 | paste shell command:
36 |
37 | $ go get github.com/atotto/clipboard/cmd/gopaste
38 | $ # example:
39 | $ gopaste > document.txt
40 |
41 | copy shell command:
42 |
43 | $ go get github.com/atotto/clipboard/cmd/gocopy
44 | $ # example:
45 | $ cat document.txt | gocopy
46 |
47 |
48 |
49 |
--------------------------------------------------------------------------------
/vendor/github.com/atotto/clipboard/clipboard.go:
--------------------------------------------------------------------------------
1 | // Copyright 2013 @atotto. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | // Package clipboard read/write on clipboard
6 | package clipboard
7 |
8 | // ReadAll read string from clipboard
9 | func ReadAll() (string, error) {
10 | return readAll()
11 | }
12 |
13 | // WriteAll write string to clipboard
14 | func WriteAll(text string) error {
15 | return writeAll(text)
16 | }
17 |
18 | // Unsupported might be set true during clipboard init, to help callers decide
19 | // whether or not to offer clipboard options.
20 | var Unsupported bool
21 |
--------------------------------------------------------------------------------
/vendor/github.com/atotto/clipboard/clipboard_darwin.go:
--------------------------------------------------------------------------------
1 | // Copyright 2013 @atotto. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | // +build darwin
6 |
7 | package clipboard
8 |
9 | import (
10 | "os/exec"
11 | )
12 |
13 | var (
14 | pasteCmdArgs = "pbpaste"
15 | copyCmdArgs = "pbcopy"
16 | )
17 |
18 | func getPasteCommand() *exec.Cmd {
19 | return exec.Command(pasteCmdArgs)
20 | }
21 |
22 | func getCopyCommand() *exec.Cmd {
23 | return exec.Command(copyCmdArgs)
24 | }
25 |
26 | func readAll() (string, error) {
27 | pasteCmd := getPasteCommand()
28 | out, err := pasteCmd.Output()
29 | if err != nil {
30 | return "", err
31 | }
32 | return string(out), nil
33 | }
34 |
35 | func writeAll(text string) error {
36 | copyCmd := getCopyCommand()
37 | in, err := copyCmd.StdinPipe()
38 | if err != nil {
39 | return err
40 | }
41 |
42 | if err := copyCmd.Start(); err != nil {
43 | return err
44 | }
45 | if _, err := in.Write([]byte(text)); err != nil {
46 | return err
47 | }
48 | if err := in.Close(); err != nil {
49 | return err
50 | }
51 | return copyCmd.Wait()
52 | }
53 |
--------------------------------------------------------------------------------
/vendor/github.com/atotto/clipboard/clipboard_plan9.go:
--------------------------------------------------------------------------------
1 | // Copyright 2013 @atotto. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | // +build plan9
6 |
7 | package clipboard
8 |
9 | import (
10 | "os"
11 | "io/ioutil"
12 | )
13 |
14 | func readAll() (string, error) {
15 | f, err := os.Open("/dev/snarf")
16 | if err != nil {
17 | return "", err
18 | }
19 | defer f.Close()
20 |
21 | str, err := ioutil.ReadAll(f)
22 | if err != nil {
23 | return "", err
24 | }
25 |
26 | return string(str), nil
27 | }
28 |
29 | func writeAll(text string) error {
30 | f, err := os.OpenFile("/dev/snarf", os.O_WRONLY, 0666)
31 | if err != nil {
32 | return err
33 | }
34 | defer f.Close()
35 |
36 | _, err = f.Write([]byte(text))
37 | if err != nil {
38 | return err
39 | }
40 |
41 | return nil
42 | }
43 |
--------------------------------------------------------------------------------
/vendor/github.com/jstarks/npiperelay/.gitignore:
--------------------------------------------------------------------------------
1 | # Binaries for programs and plugins
2 | *.exe
3 | *.dll
4 | *.so
5 | *.dylib
6 |
7 | # Test binary, build with `go test -c`
8 | *.test
9 |
10 | # Output of the go coverage tool, specifically when used with LiteIDE
11 | *.out
12 |
13 | # Project-local glide cache, RE: https://github.com/Masterminds/glide/issues/736
14 | .glide/
15 |
--------------------------------------------------------------------------------
/vendor/github.com/jstarks/npiperelay/.goreleaser.yml:
--------------------------------------------------------------------------------
1 | builds:
2 | - binary: npiperelay
3 | goos:
4 | - windows
5 | goarch:
6 | - 386
7 | - amd64
8 |
9 | archives:
10 | - id: zip
11 | name_template: "{{ .ProjectName }}_{{ .Os }}_{{ .Arch }}{{ if .Arm }}v{{ .Arm }}{{ end }}"
12 | format_overrides:
13 | - goos: windows
14 | format: zip
15 |
16 | changelog:
17 | sort: asc
18 |
--------------------------------------------------------------------------------
/vendor/github.com/jstarks/npiperelay/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2017 John Starks
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/vendor/github.com/skratchdot/open-golang/LICENSE:
--------------------------------------------------------------------------------
1 | Copyright (c) 2013 skratchdot
2 |
3 | Permission is hereby granted, free of charge, to any person
4 | obtaining a copy of this software and associated documentation
5 | files (the "Software"), to deal in the Software without
6 | restriction, including without limitation the rights to use,
7 | copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | copies of the Software, and to permit persons to whom the
9 | Software is furnished to do so, subject to the following
10 | conditions:
11 |
12 | The above copyright notice and this permission notice shall be
13 | included in all copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
17 | OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
19 | HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
20 | WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21 | FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
22 | OTHER DEALINGS IN THE SOFTWARE.
23 |
--------------------------------------------------------------------------------
/vendor/github.com/skratchdot/open-golang/open/exec.go:
--------------------------------------------------------------------------------
1 | // +build !windows,!darwin
2 |
3 | package open
4 |
5 | import (
6 | "os/exec"
7 | )
8 |
9 | // http://sources.debian.net/src/xdg-utils/1.1.0~rc1%2Bgit20111210-7.1/scripts/xdg-open/
10 | // http://sources.debian.net/src/xdg-utils/1.1.0~rc1%2Bgit20111210-7.1/scripts/xdg-mime/
11 |
12 | func open(input string) *exec.Cmd {
13 | return exec.Command("xdg-open", input)
14 | }
15 |
16 | func openWith(input string, appName string) *exec.Cmd {
17 | return exec.Command(appName, input)
18 | }
19 |
--------------------------------------------------------------------------------
/vendor/github.com/skratchdot/open-golang/open/exec_darwin.go:
--------------------------------------------------------------------------------
1 | // +build darwin
2 |
3 | package open
4 |
5 | import (
6 | "os/exec"
7 | )
8 |
9 | func open(input string) *exec.Cmd {
10 | return exec.Command("open", input)
11 | }
12 |
13 | func openWith(input string, appName string) *exec.Cmd {
14 | return exec.Command("open", "-a", appName, input)
15 | }
16 |
--------------------------------------------------------------------------------
/vendor/github.com/skratchdot/open-golang/open/exec_windows.go:
--------------------------------------------------------------------------------
1 | // +build windows
2 |
3 | package open
4 |
5 | import (
6 | "os"
7 | "os/exec"
8 | "path/filepath"
9 | "strings"
10 | // "syscall"
11 | )
12 |
13 | var (
14 | cmd = "url.dll,FileProtocolHandler"
15 | runDll32 = filepath.Join(os.Getenv("SYSTEMROOT"), "System32", "rundll32.exe")
16 | )
17 |
18 | func cleaninput(input string) string {
19 | r := strings.NewReplacer("&", "^&")
20 | return r.Replace(input)
21 | }
22 |
23 | func open(input string) *exec.Cmd {
24 | cmd := exec.Command(runDll32, cmd, input)
25 | //cmd.SysProcAttr = &syscall.SysProcAttr{HideWindow: true}
26 | return cmd
27 | }
28 |
29 | func openWith(input string, appName string) *exec.Cmd {
30 | cmd := exec.Command("cmd", "/C", "start", "", appName, cleaninput(input))
31 | //cmd.SysProcAttr = &syscall.SysProcAttr{HideWindow: true}
32 | return cmd
33 | }
34 |
--------------------------------------------------------------------------------
/vendor/github.com/skratchdot/open-golang/open/open.go:
--------------------------------------------------------------------------------
1 | /*
2 |
3 | Open a file, directory, or URI using the OS's default
4 | application for that object type. Optionally, you can
5 | specify an application to use.
6 |
7 | This is a proxy for the following commands:
8 |
9 | OSX: "open"
10 | Windows: "start"
11 | Linux/Other: "xdg-open"
12 |
13 | This is a golang port of the node.js module: https://github.com/pwnall/node-open
14 |
15 | */
16 | package open
17 |
18 | /*
19 | Open a file, directory, or URI using the OS's default
20 | application for that object type. Wait for the open
21 | command to complete.
22 | */
23 | func Run(input string) error {
24 | return open(input).Run()
25 | }
26 |
27 | /*
28 | Open a file, directory, or URI using the OS's default
29 | application for that object type. Don't wait for the
30 | open command to complete.
31 | */
32 | func Start(input string) error {
33 | return open(input).Start()
34 | }
35 |
36 | /*
37 | Open a file, directory, or URI using the specified application.
38 | Wait for the open command to complete.
39 | */
40 | func RunWith(input string, appName string) error {
41 | return openWith(input, appName).Run()
42 | }
43 |
44 | /*
45 | Open a file, directory, or URI using the specified application.
46 | Don't wait for the open command to complete.
47 | */
48 | func StartWith(input string, appName string) error {
49 | return openWith(input, appName).Start()
50 | }
51 |
--------------------------------------------------------------------------------
/vendor/golang.org/x/crypto/LICENSE:
--------------------------------------------------------------------------------
1 | Copyright 2009 The Go Authors.
2 |
3 | Redistribution and use in source and binary forms, with or without
4 | modification, are permitted provided that the following conditions are
5 | met:
6 |
7 | * Redistributions of source code must retain the above copyright
8 | notice, this list of conditions and the following disclaimer.
9 | * Redistributions in binary form must reproduce the above
10 | copyright notice, this list of conditions and the following disclaimer
11 | in the documentation and/or other materials provided with the
12 | distribution.
13 | * Neither the name of Google LLC nor the names of its
14 | contributors may be used to endorse or promote products derived from
15 | this software without specific prior written permission.
16 |
17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
19 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
20 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
21 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
22 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
23 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 |
--------------------------------------------------------------------------------
/vendor/golang.org/x/crypto/PATENTS:
--------------------------------------------------------------------------------
1 | Additional IP Rights Grant (Patents)
2 |
3 | "This implementation" means the copyrightable works distributed by
4 | Google as part of the Go project.
5 |
6 | Google hereby grants to You a perpetual, worldwide, non-exclusive,
7 | no-charge, royalty-free, irrevocable (except as stated in this section)
8 | patent license to make, have made, use, offer to sell, sell, import,
9 | transfer and otherwise run, modify and propagate the contents of this
10 | implementation of Go, where such license applies only to those patent
11 | claims, both currently owned or controlled by Google and acquired in
12 | the future, licensable by Google that are necessarily infringed by this
13 | implementation of Go. This grant does not include claims that would be
14 | infringed only as a consequence of further modification of this
15 | implementation. If you or your agent or exclusive licensee institute or
16 | order or agree to the institution of patent litigation against any
17 | entity (including a cross-claim or counterclaim in a lawsuit) alleging
18 | that this implementation of Go or any code incorporated within this
19 | implementation of Go constitutes direct or contributory patent
20 | infringement, or inducement of patent infringement, then any patent
21 | rights granted to you under this License for this implementation of Go
22 | shall terminate as of the date such litigation is filed.
23 |
--------------------------------------------------------------------------------
/vendor/golang.org/x/crypto/internal/alias/alias.go:
--------------------------------------------------------------------------------
1 | // Copyright 2018 The Go Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | //go:build !purego
6 |
7 | // Package alias implements memory aliasing tests.
8 | package alias
9 |
10 | import "unsafe"
11 |
12 | // AnyOverlap reports whether x and y share memory at any (not necessarily
13 | // corresponding) index. The memory beyond the slice length is ignored.
14 | func AnyOverlap(x, y []byte) bool {
15 | return len(x) > 0 && len(y) > 0 &&
16 | uintptr(unsafe.Pointer(&x[0])) <= uintptr(unsafe.Pointer(&y[len(y)-1])) &&
17 | uintptr(unsafe.Pointer(&y[0])) <= uintptr(unsafe.Pointer(&x[len(x)-1]))
18 | }
19 |
20 | // InexactOverlap reports whether x and y share memory at any non-corresponding
21 | // index. The memory beyond the slice length is ignored. Note that x and y can
22 | // have different lengths and still not have any inexact overlap.
23 | //
24 | // InexactOverlap can be used to implement the requirements of the crypto/cipher
25 | // AEAD, Block, BlockMode and Stream interfaces.
26 | func InexactOverlap(x, y []byte) bool {
27 | if len(x) == 0 || len(y) == 0 || &x[0] == &y[0] {
28 | return false
29 | }
30 | return AnyOverlap(x, y)
31 | }
32 |
--------------------------------------------------------------------------------
/vendor/golang.org/x/crypto/internal/alias/alias_purego.go:
--------------------------------------------------------------------------------
1 | // Copyright 2018 The Go Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | //go:build purego
6 |
7 | // Package alias implements memory aliasing tests.
8 | package alias
9 |
10 | // This is the Google App Engine standard variant based on reflect
11 | // because the unsafe package and cgo are disallowed.
12 |
13 | import "reflect"
14 |
15 | // AnyOverlap reports whether x and y share memory at any (not necessarily
16 | // corresponding) index. The memory beyond the slice length is ignored.
17 | func AnyOverlap(x, y []byte) bool {
18 | return len(x) > 0 && len(y) > 0 &&
19 | reflect.ValueOf(&x[0]).Pointer() <= reflect.ValueOf(&y[len(y)-1]).Pointer() &&
20 | reflect.ValueOf(&y[0]).Pointer() <= reflect.ValueOf(&x[len(x)-1]).Pointer()
21 | }
22 |
23 | // InexactOverlap reports whether x and y share memory at any non-corresponding
24 | // index. The memory beyond the slice length is ignored. Note that x and y can
25 | // have different lengths and still not have any inexact overlap.
26 | //
27 | // InexactOverlap can be used to implement the requirements of the crypto/cipher
28 | // AEAD, Block, BlockMode and Stream interfaces.
29 | func InexactOverlap(x, y []byte) bool {
30 | if len(x) == 0 || len(y) == 0 || &x[0] == &y[0] {
31 | return false
32 | }
33 | return AnyOverlap(x, y)
34 | }
35 |
--------------------------------------------------------------------------------
/vendor/golang.org/x/exp/typeparams/LICENSE:
--------------------------------------------------------------------------------
1 | Copyright 2009 The Go Authors.
2 |
3 | Redistribution and use in source and binary forms, with or without
4 | modification, are permitted provided that the following conditions are
5 | met:
6 |
7 | * Redistributions of source code must retain the above copyright
8 | notice, this list of conditions and the following disclaimer.
9 | * Redistributions in binary form must reproduce the above
10 | copyright notice, this list of conditions and the following disclaimer
11 | in the documentation and/or other materials provided with the
12 | distribution.
13 | * Neither the name of Google LLC nor the names of its
14 | contributors may be used to endorse or promote products derived from
15 | this software without specific prior written permission.
16 |
17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
19 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
20 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
21 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
22 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
23 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 |
--------------------------------------------------------------------------------
/vendor/golang.org/x/mod/LICENSE:
--------------------------------------------------------------------------------
1 | Copyright 2009 The Go Authors.
2 |
3 | Redistribution and use in source and binary forms, with or without
4 | modification, are permitted provided that the following conditions are
5 | met:
6 |
7 | * Redistributions of source code must retain the above copyright
8 | notice, this list of conditions and the following disclaimer.
9 | * Redistributions in binary form must reproduce the above
10 | copyright notice, this list of conditions and the following disclaimer
11 | in the documentation and/or other materials provided with the
12 | distribution.
13 | * Neither the name of Google LLC nor the names of its
14 | contributors may be used to endorse or promote products derived from
15 | this software without specific prior written permission.
16 |
17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
19 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
20 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
21 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
22 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
23 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 |
--------------------------------------------------------------------------------
/vendor/golang.org/x/mod/PATENTS:
--------------------------------------------------------------------------------
1 | Additional IP Rights Grant (Patents)
2 |
3 | "This implementation" means the copyrightable works distributed by
4 | Google as part of the Go project.
5 |
6 | Google hereby grants to You a perpetual, worldwide, non-exclusive,
7 | no-charge, royalty-free, irrevocable (except as stated in this section)
8 | patent license to make, have made, use, offer to sell, sell, import,
9 | transfer and otherwise run, modify and propagate the contents of this
10 | implementation of Go, where such license applies only to those patent
11 | claims, both currently owned or controlled by Google and acquired in
12 | the future, licensable by Google that are necessarily infringed by this
13 | implementation of Go. This grant does not include claims that would be
14 | infringed only as a consequence of further modification of this
15 | implementation. If you or your agent or exclusive licensee institute or
16 | order or agree to the institution of patent litigation against any
17 | entity (including a cross-claim or counterclaim in a lawsuit) alleging
18 | that this implementation of Go or any code incorporated within this
19 | implementation of Go constitutes direct or contributory patent
20 | infringement, or inducement of patent infringement, then any patent
21 | rights granted to you under this License for this implementation of Go
22 | shall terminate as of the date such litigation is filed.
23 |
--------------------------------------------------------------------------------
/vendor/golang.org/x/sync/LICENSE:
--------------------------------------------------------------------------------
1 | Copyright 2009 The Go Authors.
2 |
3 | Redistribution and use in source and binary forms, with or without
4 | modification, are permitted provided that the following conditions are
5 | met:
6 |
7 | * Redistributions of source code must retain the above copyright
8 | notice, this list of conditions and the following disclaimer.
9 | * Redistributions in binary form must reproduce the above
10 | copyright notice, this list of conditions and the following disclaimer
11 | in the documentation and/or other materials provided with the
12 | distribution.
13 | * Neither the name of Google LLC nor the names of its
14 | contributors may be used to endorse or promote products derived from
15 | this software without specific prior written permission.
16 |
17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
19 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
20 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
21 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
22 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
23 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 |
--------------------------------------------------------------------------------
/vendor/golang.org/x/sync/PATENTS:
--------------------------------------------------------------------------------
1 | Additional IP Rights Grant (Patents)
2 |
3 | "This implementation" means the copyrightable works distributed by
4 | Google as part of the Go project.
5 |
6 | Google hereby grants to You a perpetual, worldwide, non-exclusive,
7 | no-charge, royalty-free, irrevocable (except as stated in this section)
8 | patent license to make, have made, use, offer to sell, sell, import,
9 | transfer and otherwise run, modify and propagate the contents of this
10 | implementation of Go, where such license applies only to those patent
11 | claims, both currently owned or controlled by Google and acquired in
12 | the future, licensable by Google that are necessarily infringed by this
13 | implementation of Go. This grant does not include claims that would be
14 | infringed only as a consequence of further modification of this
15 | implementation. If you or your agent or exclusive licensee institute or
16 | order or agree to the institution of patent litigation against any
17 | entity (including a cross-claim or counterclaim in a lawsuit) alleging
18 | that this implementation of Go or any code incorporated within this
19 | implementation of Go constitutes direct or contributory patent
20 | infringement, or inducement of patent infringement, then any patent
21 | rights granted to you under this License for this implementation of Go
22 | shall terminate as of the date such litigation is filed.
23 |
--------------------------------------------------------------------------------
/vendor/golang.org/x/sys/LICENSE:
--------------------------------------------------------------------------------
1 | Copyright 2009 The Go Authors.
2 |
3 | Redistribution and use in source and binary forms, with or without
4 | modification, are permitted provided that the following conditions are
5 | met:
6 |
7 | * Redistributions of source code must retain the above copyright
8 | notice, this list of conditions and the following disclaimer.
9 | * Redistributions in binary form must reproduce the above
10 | copyright notice, this list of conditions and the following disclaimer
11 | in the documentation and/or other materials provided with the
12 | distribution.
13 | * Neither the name of Google LLC nor the names of its
14 | contributors may be used to endorse or promote products derived from
15 | this software without specific prior written permission.
16 |
17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
19 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
20 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
21 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
22 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
23 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 |
--------------------------------------------------------------------------------
/vendor/golang.org/x/sys/PATENTS:
--------------------------------------------------------------------------------
1 | Additional IP Rights Grant (Patents)
2 |
3 | "This implementation" means the copyrightable works distributed by
4 | Google as part of the Go project.
5 |
6 | Google hereby grants to You a perpetual, worldwide, non-exclusive,
7 | no-charge, royalty-free, irrevocable (except as stated in this section)
8 | patent license to make, have made, use, offer to sell, sell, import,
9 | transfer and otherwise run, modify and propagate the contents of this
10 | implementation of Go, where such license applies only to those patent
11 | claims, both currently owned or controlled by Google and acquired in
12 | the future, licensable by Google that are necessarily infringed by this
13 | implementation of Go. This grant does not include claims that would be
14 | infringed only as a consequence of further modification of this
15 | implementation. If you or your agent or exclusive licensee institute or
16 | order or agree to the institution of patent litigation against any
17 | entity (including a cross-claim or counterclaim in a lawsuit) alleging
18 | that this implementation of Go or any code incorporated within this
19 | implementation of Go constitutes direct or contributory patent
20 | infringement, or inducement of patent infringement, then any patent
21 | rights granted to you under this License for this implementation of Go
22 | shall terminate as of the date such litigation is filed.
23 |
--------------------------------------------------------------------------------
/vendor/golang.org/x/sys/windows/aliases.go:
--------------------------------------------------------------------------------
1 | // Copyright 2018 The Go Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | //go:build windows
6 |
7 | package windows
8 |
9 | import "syscall"
10 |
11 | type Errno = syscall.Errno
12 | type SysProcAttr = syscall.SysProcAttr
13 |
--------------------------------------------------------------------------------
/vendor/golang.org/x/sys/windows/env_windows.go:
--------------------------------------------------------------------------------
1 | // Copyright 2010 The Go Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | // Windows environment variables.
6 |
7 | package windows
8 |
9 | import (
10 | "syscall"
11 | "unsafe"
12 | )
13 |
14 | func Getenv(key string) (value string, found bool) {
15 | return syscall.Getenv(key)
16 | }
17 |
18 | func Setenv(key, value string) error {
19 | return syscall.Setenv(key, value)
20 | }
21 |
22 | func Clearenv() {
23 | syscall.Clearenv()
24 | }
25 |
26 | func Environ() []string {
27 | return syscall.Environ()
28 | }
29 |
30 | // Returns a default environment associated with the token, rather than the current
31 | // process. If inheritExisting is true, then this environment also inherits the
32 | // environment of the current process.
33 | func (token Token) Environ(inheritExisting bool) (env []string, err error) {
34 | var block *uint16
35 | err = CreateEnvironmentBlock(&block, token, inheritExisting)
36 | if err != nil {
37 | return nil, err
38 | }
39 | defer DestroyEnvironmentBlock(block)
40 | size := unsafe.Sizeof(*block)
41 | for *block != 0 {
42 | // find NUL terminator
43 | end := unsafe.Pointer(block)
44 | for *(*uint16)(end) != 0 {
45 | end = unsafe.Add(end, size)
46 | }
47 |
48 | entry := unsafe.Slice(block, (uintptr(end)-uintptr(unsafe.Pointer(block)))/size)
49 | env = append(env, UTF16ToString(entry))
50 | block = (*uint16)(unsafe.Add(end, size))
51 | }
52 | return env, nil
53 | }
54 |
55 | func Unsetenv(key string) error {
56 | return syscall.Unsetenv(key)
57 | }
58 |
--------------------------------------------------------------------------------
/vendor/golang.org/x/sys/windows/eventlog.go:
--------------------------------------------------------------------------------
1 | // Copyright 2012 The Go Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | //go:build windows
6 |
7 | package windows
8 |
9 | const (
10 | EVENTLOG_SUCCESS = 0
11 | EVENTLOG_ERROR_TYPE = 1
12 | EVENTLOG_WARNING_TYPE = 2
13 | EVENTLOG_INFORMATION_TYPE = 4
14 | EVENTLOG_AUDIT_SUCCESS = 8
15 | EVENTLOG_AUDIT_FAILURE = 16
16 | )
17 |
18 | //sys RegisterEventSource(uncServerName *uint16, sourceName *uint16) (handle Handle, err error) [failretval==0] = advapi32.RegisterEventSourceW
19 | //sys DeregisterEventSource(handle Handle) (err error) = advapi32.DeregisterEventSource
20 | //sys ReportEvent(log Handle, etype uint16, category uint16, eventId uint32, usrSId uintptr, numStrings uint16, dataSize uint32, strings **uint16, rawData *byte) (err error) = advapi32.ReportEventW
21 |
--------------------------------------------------------------------------------
/vendor/golang.org/x/sys/windows/memory_windows.go:
--------------------------------------------------------------------------------
1 | // Copyright 2017 The Go Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | package windows
6 |
7 | const (
8 | MEM_COMMIT = 0x00001000
9 | MEM_RESERVE = 0x00002000
10 | MEM_DECOMMIT = 0x00004000
11 | MEM_RELEASE = 0x00008000
12 | MEM_RESET = 0x00080000
13 | MEM_TOP_DOWN = 0x00100000
14 | MEM_WRITE_WATCH = 0x00200000
15 | MEM_PHYSICAL = 0x00400000
16 | MEM_RESET_UNDO = 0x01000000
17 | MEM_LARGE_PAGES = 0x20000000
18 |
19 | PAGE_NOACCESS = 0x00000001
20 | PAGE_READONLY = 0x00000002
21 | PAGE_READWRITE = 0x00000004
22 | PAGE_WRITECOPY = 0x00000008
23 | PAGE_EXECUTE = 0x00000010
24 | PAGE_EXECUTE_READ = 0x00000020
25 | PAGE_EXECUTE_READWRITE = 0x00000040
26 | PAGE_EXECUTE_WRITECOPY = 0x00000080
27 | PAGE_GUARD = 0x00000100
28 | PAGE_NOCACHE = 0x00000200
29 | PAGE_WRITECOMBINE = 0x00000400
30 | PAGE_TARGETS_INVALID = 0x40000000
31 | PAGE_TARGETS_NO_UPDATE = 0x40000000
32 |
33 | QUOTA_LIMITS_HARDWS_MIN_DISABLE = 0x00000002
34 | QUOTA_LIMITS_HARDWS_MIN_ENABLE = 0x00000001
35 | QUOTA_LIMITS_HARDWS_MAX_DISABLE = 0x00000008
36 | QUOTA_LIMITS_HARDWS_MAX_ENABLE = 0x00000004
37 | )
38 |
39 | type MemoryBasicInformation struct {
40 | BaseAddress uintptr
41 | AllocationBase uintptr
42 | AllocationProtect uint32
43 | PartitionId uint16
44 | RegionSize uintptr
45 | State uint32
46 | Protect uint32
47 | Type uint32
48 | }
49 |
--------------------------------------------------------------------------------
/vendor/golang.org/x/sys/windows/mkknownfolderids.bash:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | # Copyright 2019 The Go Authors. All rights reserved.
4 | # Use of this source code is governed by a BSD-style
5 | # license that can be found in the LICENSE file.
6 |
7 | set -e
8 | shopt -s nullglob
9 |
10 | knownfolders="$(printf '%s\n' "/mnt/c/Program Files (x86)/Windows Kits/"/*/Include/*/um/KnownFolders.h | sort -Vr | head -n 1)"
11 | [[ -n $knownfolders ]] || { echo "Unable to find KnownFolders.h" >&2; exit 1; }
12 |
13 | {
14 | echo "// Code generated by 'mkknownfolderids.bash'; DO NOT EDIT."
15 | echo
16 | echo "package windows"
17 | echo "type KNOWNFOLDERID GUID"
18 | echo "var ("
19 | while read -r line; do
20 | [[ $line =~ DEFINE_KNOWN_FOLDER\((FOLDERID_[^,]+),[\t\ ]*(0x[^,]+),[\t\ ]*(0x[^,]+),[\t\ ]*(0x[^,]+),[\t\ ]*(0x[^,]+),[\t\ ]*(0x[^,]+),[\t\ ]*(0x[^,]+),[\t\ ]*(0x[^,]+),[\t\ ]*(0x[^,]+),[\t\ ]*(0x[^,]+),[\t\ ]*(0x[^,]+),[\t\ ]*(0x[^,]+)\) ]] || continue
21 | printf "%s = &KNOWNFOLDERID{0x%08x, 0x%04x, 0x%04x, [8]byte{0x%02x, 0x%02x, 0x%02x, 0x%02x, 0x%02x, 0x%02x, 0x%02x, 0x%02x}}\n" \
22 | "${BASH_REMATCH[1]}" $(( "${BASH_REMATCH[2]}" )) $(( "${BASH_REMATCH[3]}" )) $(( "${BASH_REMATCH[4]}" )) \
23 | $(( "${BASH_REMATCH[5]}" )) $(( "${BASH_REMATCH[6]}" )) $(( "${BASH_REMATCH[7]}" )) $(( "${BASH_REMATCH[8]}" )) \
24 | $(( "${BASH_REMATCH[9]}" )) $(( "${BASH_REMATCH[10]}" )) $(( "${BASH_REMATCH[11]}" )) $(( "${BASH_REMATCH[12]}" ))
25 | done < "$knownfolders"
26 | echo ")"
27 | } | gofmt > "zknownfolderids_windows.go"
28 |
--------------------------------------------------------------------------------
/vendor/golang.org/x/sys/windows/mksyscall.go:
--------------------------------------------------------------------------------
1 | // Copyright 2009 The Go Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | //go:build generate
6 |
7 | package windows
8 |
9 | //go:generate go run golang.org/x/sys/windows/mkwinsyscall -output zsyscall_windows.go eventlog.go service.go syscall_windows.go security_windows.go setupapi_windows.go
10 |
--------------------------------------------------------------------------------
/vendor/golang.org/x/sys/windows/race.go:
--------------------------------------------------------------------------------
1 | // Copyright 2012 The Go Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | //go:build windows && race
6 |
7 | package windows
8 |
9 | import (
10 | "runtime"
11 | "unsafe"
12 | )
13 |
14 | const raceenabled = true
15 |
16 | func raceAcquire(addr unsafe.Pointer) {
17 | runtime.RaceAcquire(addr)
18 | }
19 |
20 | func raceReleaseMerge(addr unsafe.Pointer) {
21 | runtime.RaceReleaseMerge(addr)
22 | }
23 |
24 | func raceReadRange(addr unsafe.Pointer, len int) {
25 | runtime.RaceReadRange(addr, len)
26 | }
27 |
28 | func raceWriteRange(addr unsafe.Pointer, len int) {
29 | runtime.RaceWriteRange(addr, len)
30 | }
31 |
--------------------------------------------------------------------------------
/vendor/golang.org/x/sys/windows/race0.go:
--------------------------------------------------------------------------------
1 | // Copyright 2012 The Go Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | //go:build windows && !race
6 |
7 | package windows
8 |
9 | import (
10 | "unsafe"
11 | )
12 |
13 | const raceenabled = false
14 |
15 | func raceAcquire(addr unsafe.Pointer) {
16 | }
17 |
18 | func raceReleaseMerge(addr unsafe.Pointer) {
19 | }
20 |
21 | func raceReadRange(addr unsafe.Pointer, len int) {
22 | }
23 |
24 | func raceWriteRange(addr unsafe.Pointer, len int) {
25 | }
26 |
--------------------------------------------------------------------------------
/vendor/golang.org/x/sys/windows/str.go:
--------------------------------------------------------------------------------
1 | // Copyright 2009 The Go Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | //go:build windows
6 |
7 | package windows
8 |
9 | func itoa(val int) string { // do it here rather than with fmt to avoid dependency
10 | if val < 0 {
11 | return "-" + itoa(-val)
12 | }
13 | var buf [32]byte // big enough for int64
14 | i := len(buf) - 1
15 | for val >= 10 {
16 | buf[i] = byte(val%10 + '0')
17 | i--
18 | val /= 10
19 | }
20 | buf[i] = byte(val + '0')
21 | return string(buf[i:])
22 | }
23 |
--------------------------------------------------------------------------------
/vendor/golang.org/x/sys/windows/types_windows_386.go:
--------------------------------------------------------------------------------
1 | // Copyright 2011 The Go Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | package windows
6 |
7 | type WSAData struct {
8 | Version uint16
9 | HighVersion uint16
10 | Description [WSADESCRIPTION_LEN + 1]byte
11 | SystemStatus [WSASYS_STATUS_LEN + 1]byte
12 | MaxSockets uint16
13 | MaxUdpDg uint16
14 | VendorInfo *byte
15 | }
16 |
17 | type Servent struct {
18 | Name *byte
19 | Aliases **byte
20 | Port uint16
21 | Proto *byte
22 | }
23 |
24 | type JOBOBJECT_BASIC_LIMIT_INFORMATION struct {
25 | PerProcessUserTimeLimit int64
26 | PerJobUserTimeLimit int64
27 | LimitFlags uint32
28 | MinimumWorkingSetSize uintptr
29 | MaximumWorkingSetSize uintptr
30 | ActiveProcessLimit uint32
31 | Affinity uintptr
32 | PriorityClass uint32
33 | SchedulingClass uint32
34 | _ uint32 // pad to 8 byte boundary
35 | }
36 |
--------------------------------------------------------------------------------
/vendor/golang.org/x/sys/windows/types_windows_amd64.go:
--------------------------------------------------------------------------------
1 | // Copyright 2011 The Go Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | package windows
6 |
7 | type WSAData struct {
8 | Version uint16
9 | HighVersion uint16
10 | MaxSockets uint16
11 | MaxUdpDg uint16
12 | VendorInfo *byte
13 | Description [WSADESCRIPTION_LEN + 1]byte
14 | SystemStatus [WSASYS_STATUS_LEN + 1]byte
15 | }
16 |
17 | type Servent struct {
18 | Name *byte
19 | Aliases **byte
20 | Proto *byte
21 | Port uint16
22 | }
23 |
24 | type JOBOBJECT_BASIC_LIMIT_INFORMATION struct {
25 | PerProcessUserTimeLimit int64
26 | PerJobUserTimeLimit int64
27 | LimitFlags uint32
28 | MinimumWorkingSetSize uintptr
29 | MaximumWorkingSetSize uintptr
30 | ActiveProcessLimit uint32
31 | Affinity uintptr
32 | PriorityClass uint32
33 | SchedulingClass uint32
34 | }
35 |
--------------------------------------------------------------------------------
/vendor/golang.org/x/sys/windows/types_windows_arm.go:
--------------------------------------------------------------------------------
1 | // Copyright 2018 The Go Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | package windows
6 |
7 | type WSAData struct {
8 | Version uint16
9 | HighVersion uint16
10 | Description [WSADESCRIPTION_LEN + 1]byte
11 | SystemStatus [WSASYS_STATUS_LEN + 1]byte
12 | MaxSockets uint16
13 | MaxUdpDg uint16
14 | VendorInfo *byte
15 | }
16 |
17 | type Servent struct {
18 | Name *byte
19 | Aliases **byte
20 | Port uint16
21 | Proto *byte
22 | }
23 |
24 | type JOBOBJECT_BASIC_LIMIT_INFORMATION struct {
25 | PerProcessUserTimeLimit int64
26 | PerJobUserTimeLimit int64
27 | LimitFlags uint32
28 | MinimumWorkingSetSize uintptr
29 | MaximumWorkingSetSize uintptr
30 | ActiveProcessLimit uint32
31 | Affinity uintptr
32 | PriorityClass uint32
33 | SchedulingClass uint32
34 | _ uint32 // pad to 8 byte boundary
35 | }
36 |
--------------------------------------------------------------------------------
/vendor/golang.org/x/sys/windows/types_windows_arm64.go:
--------------------------------------------------------------------------------
1 | // Copyright 2011 The Go Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | package windows
6 |
7 | type WSAData struct {
8 | Version uint16
9 | HighVersion uint16
10 | MaxSockets uint16
11 | MaxUdpDg uint16
12 | VendorInfo *byte
13 | Description [WSADESCRIPTION_LEN + 1]byte
14 | SystemStatus [WSASYS_STATUS_LEN + 1]byte
15 | }
16 |
17 | type Servent struct {
18 | Name *byte
19 | Aliases **byte
20 | Proto *byte
21 | Port uint16
22 | }
23 |
24 | type JOBOBJECT_BASIC_LIMIT_INFORMATION struct {
25 | PerProcessUserTimeLimit int64
26 | PerJobUserTimeLimit int64
27 | LimitFlags uint32
28 | MinimumWorkingSetSize uintptr
29 | MaximumWorkingSetSize uintptr
30 | ActiveProcessLimit uint32
31 | Affinity uintptr
32 | PriorityClass uint32
33 | SchedulingClass uint32
34 | }
35 |
--------------------------------------------------------------------------------
/vendor/golang.org/x/tools/LICENSE:
--------------------------------------------------------------------------------
1 | Copyright 2009 The Go Authors.
2 |
3 | Redistribution and use in source and binary forms, with or without
4 | modification, are permitted provided that the following conditions are
5 | met:
6 |
7 | * Redistributions of source code must retain the above copyright
8 | notice, this list of conditions and the following disclaimer.
9 | * Redistributions in binary form must reproduce the above
10 | copyright notice, this list of conditions and the following disclaimer
11 | in the documentation and/or other materials provided with the
12 | distribution.
13 | * Neither the name of Google LLC nor the names of its
14 | contributors may be used to endorse or promote products derived from
15 | this software without specific prior written permission.
16 |
17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
19 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
20 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
21 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
22 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
23 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 |
--------------------------------------------------------------------------------
/vendor/golang.org/x/tools/PATENTS:
--------------------------------------------------------------------------------
1 | Additional IP Rights Grant (Patents)
2 |
3 | "This implementation" means the copyrightable works distributed by
4 | Google as part of the Go project.
5 |
6 | Google hereby grants to You a perpetual, worldwide, non-exclusive,
7 | no-charge, royalty-free, irrevocable (except as stated in this section)
8 | patent license to make, have made, use, offer to sell, sell, import,
9 | transfer and otherwise run, modify and propagate the contents of this
10 | implementation of Go, where such license applies only to those patent
11 | claims, both currently owned or controlled by Google and acquired in
12 | the future, licensable by Google that are necessarily infringed by this
13 | implementation of Go. This grant does not include claims that would be
14 | infringed only as a consequence of further modification of this
15 | implementation. If you or your agent or exclusive licensee institute or
16 | order or agree to the institution of patent litigation against any
17 | entity (including a cross-claim or counterclaim in a lawsuit) alleging
18 | that this implementation of Go or any code incorporated within this
19 | implementation of Go constitutes direct or contributory patent
20 | infringement, or inducement of patent infringement, then any patent
21 | rights granted to you under this License for this implementation of Go
22 | shall terminate as of the date such litigation is filed.
23 |
--------------------------------------------------------------------------------
/vendor/golang.org/x/tools/go/analysis/passes/inspect/inspect.go:
--------------------------------------------------------------------------------
1 | // Copyright 2018 The Go Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | // Package inspect defines an Analyzer that provides an AST inspector
6 | // (golang.org/x/tools/go/ast/inspector.Inspector) for the syntax trees
7 | // of a package. It is only a building block for other analyzers.
8 | //
9 | // Example of use in another analysis:
10 | //
11 | // import (
12 | // "golang.org/x/tools/go/analysis"
13 | // "golang.org/x/tools/go/analysis/passes/inspect"
14 | // "golang.org/x/tools/go/ast/inspector"
15 | // )
16 | //
17 | // var Analyzer = &analysis.Analyzer{
18 | // ...
19 | // Requires: []*analysis.Analyzer{inspect.Analyzer},
20 | // }
21 | //
22 | // func run(pass *analysis.Pass) (interface{}, error) {
23 | // inspect := pass.ResultOf[inspect.Analyzer].(*inspector.Inspector)
24 | // inspect.Preorder(nil, func(n ast.Node) {
25 | // ...
26 | // })
27 | // return nil, nil
28 | // }
29 | package inspect
30 |
31 | import (
32 | "reflect"
33 |
34 | "golang.org/x/tools/go/analysis"
35 | "golang.org/x/tools/go/ast/inspector"
36 | )
37 |
38 | var Analyzer = &analysis.Analyzer{
39 | Name: "inspect",
40 | Doc: "optimize AST traversal for later passes",
41 | URL: "https://pkg.go.dev/golang.org/x/tools/go/analysis/passes/inspect",
42 | Run: run,
43 | RunDespiteErrors: true,
44 | ResultType: reflect.TypeOf(new(inspector.Inspector)),
45 | }
46 |
47 | func run(pass *analysis.Pass) (any, error) {
48 | return inspector.New(pass.Files), nil
49 | }
50 |
--------------------------------------------------------------------------------
/vendor/golang.org/x/tools/go/ast/astutil/util.go:
--------------------------------------------------------------------------------
1 | // Copyright 2015 The Go Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | package astutil
6 |
7 | import "go/ast"
8 |
9 | // Unparen returns e with any enclosing parentheses stripped.
10 | // Deprecated: use [ast.Unparen].
11 | //
12 | //go:fix inline
13 | func Unparen(e ast.Expr) ast.Expr { return ast.Unparen(e) }
14 |
--------------------------------------------------------------------------------
/vendor/golang.org/x/tools/go/internal/cgo/cgo_pkgconfig.go:
--------------------------------------------------------------------------------
1 | // Copyright 2013 The Go Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | package cgo
6 |
7 | import (
8 | "errors"
9 | "fmt"
10 | "go/build"
11 | "os/exec"
12 | "strings"
13 | )
14 |
15 | // pkgConfig runs pkg-config with the specified arguments and returns the flags it prints.
16 | func pkgConfig(mode string, pkgs []string) (flags []string, err error) {
17 | cmd := exec.Command("pkg-config", append([]string{mode}, pkgs...)...)
18 | out, err := cmd.Output()
19 | if err != nil {
20 | s := fmt.Sprintf("%s failed: %v", strings.Join(cmd.Args, " "), err)
21 | if len(out) > 0 {
22 | s = fmt.Sprintf("%s: %s", s, out)
23 | }
24 | if err, ok := err.(*exec.ExitError); ok && len(err.Stderr) > 0 {
25 | s = fmt.Sprintf("%s\nstderr:\n%s", s, err.Stderr)
26 | }
27 | return nil, errors.New(s)
28 | }
29 | if len(out) > 0 {
30 | flags = strings.Fields(string(out))
31 | }
32 | return
33 | }
34 |
35 | // pkgConfigFlags calls pkg-config if needed and returns the cflags
36 | // needed to build the package.
37 | func pkgConfigFlags(p *build.Package) (cflags []string, err error) {
38 | if len(p.CgoPkgConfig) == 0 {
39 | return nil, nil
40 | }
41 | return pkgConfig("--cflags", p.CgoPkgConfig)
42 | }
43 |
--------------------------------------------------------------------------------
/vendor/golang.org/x/tools/go/packages/loadmode_string.go:
--------------------------------------------------------------------------------
1 | // Copyright 2019 The Go Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | package packages
6 |
7 | import (
8 | "fmt"
9 | "strings"
10 | )
11 |
12 | var modes = [...]struct {
13 | mode LoadMode
14 | name string
15 | }{
16 | {NeedName, "NeedName"},
17 | {NeedFiles, "NeedFiles"},
18 | {NeedCompiledGoFiles, "NeedCompiledGoFiles"},
19 | {NeedImports, "NeedImports"},
20 | {NeedDeps, "NeedDeps"},
21 | {NeedExportFile, "NeedExportFile"},
22 | {NeedTypes, "NeedTypes"},
23 | {NeedSyntax, "NeedSyntax"},
24 | {NeedTypesInfo, "NeedTypesInfo"},
25 | {NeedTypesSizes, "NeedTypesSizes"},
26 | {NeedForTest, "NeedForTest"},
27 | {NeedModule, "NeedModule"},
28 | {NeedEmbedFiles, "NeedEmbedFiles"},
29 | {NeedEmbedPatterns, "NeedEmbedPatterns"},
30 | {NeedTarget, "NeedTarget"},
31 | }
32 |
33 | func (mode LoadMode) String() string {
34 | if mode == 0 {
35 | return "LoadMode(0)"
36 | }
37 | var out []string
38 | // named bits
39 | for _, item := range modes {
40 | if (mode & item.mode) != 0 {
41 | mode ^= item.mode
42 | out = append(out, item.name)
43 | }
44 | }
45 | // unnamed residue
46 | if mode != 0 {
47 | if out == nil {
48 | return fmt.Sprintf("LoadMode(%#x)", int(mode))
49 | }
50 | out = append(out, fmt.Sprintf("%#x", int(mode)))
51 | }
52 | if len(out) == 1 {
53 | return out[0]
54 | }
55 | return "(" + strings.Join(out, "|") + ")"
56 | }
57 |
--------------------------------------------------------------------------------
/vendor/golang.org/x/tools/go/packages/visit.go:
--------------------------------------------------------------------------------
1 | // Copyright 2018 The Go Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | package packages
6 |
7 | import (
8 | "fmt"
9 | "os"
10 | "sort"
11 | )
12 |
13 | // Visit visits all the packages in the import graph whose roots are
14 | // pkgs, calling the optional pre function the first time each package
15 | // is encountered (preorder), and the optional post function after a
16 | // package's dependencies have been visited (postorder).
17 | // The boolean result of pre(pkg) determines whether
18 | // the imports of package pkg are visited.
19 | func Visit(pkgs []*Package, pre func(*Package) bool, post func(*Package)) {
20 | seen := make(map[*Package]bool)
21 | var visit func(*Package)
22 | visit = func(pkg *Package) {
23 | if !seen[pkg] {
24 | seen[pkg] = true
25 |
26 | if pre == nil || pre(pkg) {
27 | paths := make([]string, 0, len(pkg.Imports))
28 | for path := range pkg.Imports {
29 | paths = append(paths, path)
30 | }
31 | sort.Strings(paths) // Imports is a map, this makes visit stable
32 | for _, path := range paths {
33 | visit(pkg.Imports[path])
34 | }
35 | }
36 |
37 | if post != nil {
38 | post(pkg)
39 | }
40 | }
41 | }
42 | for _, pkg := range pkgs {
43 | visit(pkg)
44 | }
45 | }
46 |
47 | // PrintErrors prints to os.Stderr the accumulated errors of all
48 | // packages in the import graph rooted at pkgs, dependencies first.
49 | // PrintErrors returns the number of errors printed.
50 | func PrintErrors(pkgs []*Package) int {
51 | var n int
52 | errModules := make(map[*Module]bool)
53 | Visit(pkgs, nil, func(pkg *Package) {
54 | for _, err := range pkg.Errors {
55 | fmt.Fprintln(os.Stderr, err)
56 | n++
57 | }
58 |
59 | // Print pkg.Module.Error once if present.
60 | mod := pkg.Module
61 | if mod != nil && mod.Error != nil && !errModules[mod] {
62 | errModules[mod] = true
63 | fmt.Fprintln(os.Stderr, mod.Error.Err)
64 | n++
65 | }
66 | })
67 | return n
68 | }
69 |
--------------------------------------------------------------------------------
/vendor/golang.org/x/tools/go/types/typeutil/imports.go:
--------------------------------------------------------------------------------
1 | // Copyright 2014 The Go Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | package typeutil
6 |
7 | import "go/types"
8 |
9 | // Dependencies returns all dependencies of the specified packages.
10 | //
11 | // Dependent packages appear in topological order: if package P imports
12 | // package Q, Q appears earlier than P in the result.
13 | // The algorithm follows import statements in the order they
14 | // appear in the source code, so the result is a total order.
15 | func Dependencies(pkgs ...*types.Package) []*types.Package {
16 | var result []*types.Package
17 | seen := make(map[*types.Package]bool)
18 | var visit func(pkgs []*types.Package)
19 | visit = func(pkgs []*types.Package) {
20 | for _, p := range pkgs {
21 | if !seen[p] {
22 | seen[p] = true
23 | visit(p.Imports())
24 | result = append(result, p)
25 | }
26 | }
27 | }
28 | visit(pkgs)
29 | return result
30 | }
31 |
--------------------------------------------------------------------------------
/vendor/golang.org/x/tools/go/types/typeutil/ui.go:
--------------------------------------------------------------------------------
1 | // Copyright 2014 The Go Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | package typeutil
6 |
7 | // This file defines utilities for user interfaces that display types.
8 |
9 | import (
10 | "go/types"
11 | )
12 |
13 | // IntuitiveMethodSet returns the intuitive method set of a type T,
14 | // which is the set of methods you can call on an addressable value of
15 | // that type.
16 | //
17 | // The result always contains MethodSet(T), and is exactly MethodSet(T)
18 | // for interface types and for pointer-to-concrete types.
19 | // For all other concrete types T, the result additionally
20 | // contains each method belonging to *T if there is no identically
21 | // named method on T itself.
22 | //
23 | // This corresponds to user intuition about method sets;
24 | // this function is intended only for user interfaces.
25 | //
26 | // The order of the result is as for types.MethodSet(T).
27 | func IntuitiveMethodSet(T types.Type, msets *MethodSetCache) []*types.Selection {
28 | isPointerToConcrete := func(T types.Type) bool {
29 | ptr, ok := types.Unalias(T).(*types.Pointer)
30 | return ok && !types.IsInterface(ptr.Elem())
31 | }
32 |
33 | var result []*types.Selection
34 | mset := msets.MethodSet(T)
35 | if types.IsInterface(T) || isPointerToConcrete(T) {
36 | for i, n := 0, mset.Len(); i < n; i++ {
37 | result = append(result, mset.At(i))
38 | }
39 | } else {
40 | // T is some other concrete type.
41 | // Report methods of T and *T, preferring those of T.
42 | pmset := msets.MethodSet(types.NewPointer(T))
43 | for i, n := 0, pmset.Len(); i < n; i++ {
44 | meth := pmset.At(i)
45 | if m := mset.Lookup(meth.Obj().Pkg(), meth.Obj().Name()); m != nil {
46 | meth = m
47 | }
48 | result = append(result, meth)
49 | }
50 |
51 | }
52 | return result
53 | }
54 |
--------------------------------------------------------------------------------
/vendor/golang.org/x/tools/internal/aliases/aliases.go:
--------------------------------------------------------------------------------
1 | // Copyright 2024 The Go Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | package aliases
6 |
7 | import (
8 | "go/token"
9 | "go/types"
10 | )
11 |
12 | // Package aliases defines backward compatible shims
13 | // for the types.Alias type representation added in 1.22.
14 | // This defines placeholders for x/tools until 1.26.
15 |
16 | // NewAlias creates a new TypeName in Package pkg that
17 | // is an alias for the type rhs.
18 | //
19 | // The enabled parameter determines whether the resulting [TypeName]'s
20 | // type is an [types.Alias]. Its value must be the result of a call to
21 | // [Enabled], which computes the effective value of
22 | // GODEBUG=gotypesalias=... by invoking the type checker. The Enabled
23 | // function is expensive and should be called once per task (e.g.
24 | // package import), not once per call to NewAlias.
25 | //
26 | // Precondition: enabled || len(tparams)==0.
27 | // If materialized aliases are disabled, there must not be any type parameters.
28 | func NewAlias(enabled bool, pos token.Pos, pkg *types.Package, name string, rhs types.Type, tparams []*types.TypeParam) *types.TypeName {
29 | if enabled {
30 | tname := types.NewTypeName(pos, pkg, name, nil)
31 | SetTypeParams(types.NewAlias(tname, rhs), tparams)
32 | return tname
33 | }
34 | if len(tparams) > 0 {
35 | panic("cannot create an alias with type parameters when gotypesalias is not enabled")
36 | }
37 | return types.NewTypeName(pos, pkg, name, rhs)
38 | }
39 |
--------------------------------------------------------------------------------
/vendor/golang.org/x/tools/internal/event/doc.go:
--------------------------------------------------------------------------------
1 | // Copyright 2019 The Go Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | // Package event provides a set of packages that cover the main
6 | // concepts of telemetry in an implementation agnostic way.
7 | package event
8 |
--------------------------------------------------------------------------------
/vendor/golang.org/x/tools/internal/event/keys/standard.go:
--------------------------------------------------------------------------------
1 | // Copyright 2020 The Go Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | package keys
6 |
7 | var (
8 | // Msg is a key used to add message strings to label lists.
9 | Msg = NewString("message", "a readable message")
10 | // Label is a key used to indicate an event adds labels to the context.
11 | Label = NewTag("label", "a label context marker")
12 | // Start is used for things like traces that have a name.
13 | Start = NewString("start", "span start")
14 | // Metric is a key used to indicate an event records metrics.
15 | End = NewTag("end", "a span end marker")
16 | // Metric is a key used to indicate an event records metrics.
17 | Detach = NewTag("detach", "a span detach marker")
18 | // Err is a key used to add error values to label lists.
19 | Err = NewError("error", "an error that occurred")
20 | // Metric is a key used to indicate an event records metrics.
21 | Metric = NewTag("metric", "a metric event marker")
22 | )
23 |
--------------------------------------------------------------------------------
/vendor/golang.org/x/tools/internal/event/keys/util.go:
--------------------------------------------------------------------------------
1 | // Copyright 2023 The Go Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | package keys
6 |
7 | import (
8 | "sort"
9 | "strings"
10 | )
11 |
12 | // Join returns a canonical join of the keys in S:
13 | // a sorted comma-separated string list.
14 | func Join[S ~[]T, T ~string](s S) string {
15 | strs := make([]string, 0, len(s))
16 | for _, v := range s {
17 | strs = append(strs, string(v))
18 | }
19 | sort.Strings(strs)
20 | return strings.Join(strs, ",")
21 | }
22 |
--------------------------------------------------------------------------------
/vendor/golang.org/x/tools/internal/gcimporter/iimport_go122.go:
--------------------------------------------------------------------------------
1 | // Copyright 2024 The Go Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | //go:build go1.22 && !go1.24
6 |
7 | package gcimporter
8 |
9 | import (
10 | "go/token"
11 | "go/types"
12 | "unsafe"
13 | )
14 |
15 | // TODO(rfindley): delete this workaround once go1.24 is assured.
16 |
17 | func init() {
18 | // Update markBlack so that it correctly sets the color
19 | // of imported TypeNames.
20 | //
21 | // See the doc comment for markBlack for details.
22 |
23 | type color uint32
24 | const (
25 | white color = iota
26 | black
27 | grey
28 | )
29 | type object struct {
30 | _ *types.Scope
31 | _ token.Pos
32 | _ *types.Package
33 | _ string
34 | _ types.Type
35 | _ uint32
36 | color_ color
37 | _ token.Pos
38 | }
39 | type typeName struct {
40 | object
41 | }
42 |
43 | // If the size of types.TypeName changes, this will fail to compile.
44 | const delta = int64(unsafe.Sizeof(typeName{})) - int64(unsafe.Sizeof(types.TypeName{}))
45 | var _ [-delta * delta]int
46 |
47 | markBlack = func(obj *types.TypeName) {
48 | type uP = unsafe.Pointer
49 | var ptr *typeName
50 | *(*uP)(uP(&ptr)) = uP(obj)
51 | ptr.color_ = black
52 | }
53 | }
54 |
--------------------------------------------------------------------------------
/vendor/golang.org/x/tools/internal/gcimporter/support.go:
--------------------------------------------------------------------------------
1 | // Copyright 2024 The Go Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | package gcimporter
6 |
7 | import (
8 | "bufio"
9 | "io"
10 | "strconv"
11 | "strings"
12 | )
13 |
14 | // Copy of $GOROOT/src/cmd/internal/archive.ReadHeader.
15 | func readArchiveHeader(b *bufio.Reader, name string) int {
16 | // architecture-independent object file output
17 | const HeaderSize = 60
18 |
19 | var buf [HeaderSize]byte
20 | if _, err := io.ReadFull(b, buf[:]); err != nil {
21 | return -1
22 | }
23 | aname := strings.Trim(string(buf[0:16]), " ")
24 | if !strings.HasPrefix(aname, name) {
25 | return -1
26 | }
27 | asize := strings.Trim(string(buf[48:58]), " ")
28 | i, _ := strconv.Atoi(asize)
29 | return i
30 | }
31 |
--------------------------------------------------------------------------------
/vendor/golang.org/x/tools/internal/gocommand/invoke_notunix.go:
--------------------------------------------------------------------------------
1 | // Copyright 2025 The Go Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | //go:build !unix
6 |
7 | package gocommand
8 |
9 | import "os"
10 |
11 | // sigStuckProcess is the signal to send to kill a hanging subprocess.
12 | // On Unix we send SIGQUIT, but on non-Unix we only have os.Kill.
13 | var sigStuckProcess = os.Kill
14 |
--------------------------------------------------------------------------------
/vendor/golang.org/x/tools/internal/gocommand/invoke_unix.go:
--------------------------------------------------------------------------------
1 | // Copyright 2025 The Go Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | //go:build unix
6 |
7 | package gocommand
8 |
9 | import "syscall"
10 |
11 | // Sigstuckprocess is the signal to send to kill a hanging subprocess.
12 | // Send SIGQUIT to get a stack trace.
13 | var sigStuckProcess = syscall.SIGQUIT
14 |
--------------------------------------------------------------------------------
/vendor/golang.org/x/tools/internal/packagesinternal/packages.go:
--------------------------------------------------------------------------------
1 | // Copyright 2020 The Go Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | // Package packagesinternal exposes internal-only fields from go/packages.
6 | package packagesinternal
7 |
8 | var GetDepsErrors = func(p any) []*PackageError { return nil }
9 |
10 | type PackageError struct {
11 | ImportStack []string // shortest path from package named on command line to this one
12 | Pos string // position of error (if present, file:line:col)
13 | Err string // the error itself
14 | }
15 |
16 | var TypecheckCgo int
17 | var DepsErrors int // must be set as a LoadMode to call GetDepsErrors
18 |
--------------------------------------------------------------------------------
/vendor/golang.org/x/tools/internal/pkgbits/codes.go:
--------------------------------------------------------------------------------
1 | // Copyright 2021 The Go Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | package pkgbits
6 |
7 | // A Code is an enum value that can be encoded into bitstreams.
8 | //
9 | // Code types are preferable for enum types, because they allow
10 | // Decoder to detect desyncs.
11 | type Code interface {
12 | // Marker returns the SyncMarker for the Code's dynamic type.
13 | Marker() SyncMarker
14 |
15 | // Value returns the Code's ordinal value.
16 | Value() int
17 | }
18 |
19 | // A CodeVal distinguishes among go/constant.Value encodings.
20 | type CodeVal int
21 |
22 | func (c CodeVal) Marker() SyncMarker { return SyncVal }
23 | func (c CodeVal) Value() int { return int(c) }
24 |
25 | // Note: These values are public and cannot be changed without
26 | // updating the go/types importers.
27 |
28 | const (
29 | ValBool CodeVal = iota
30 | ValString
31 | ValInt64
32 | ValBigInt
33 | ValBigRat
34 | ValBigFloat
35 | )
36 |
37 | // A CodeType distinguishes among go/types.Type encodings.
38 | type CodeType int
39 |
40 | func (c CodeType) Marker() SyncMarker { return SyncType }
41 | func (c CodeType) Value() int { return int(c) }
42 |
43 | // Note: These values are public and cannot be changed without
44 | // updating the go/types importers.
45 |
46 | const (
47 | TypeBasic CodeType = iota
48 | TypeNamed
49 | TypePointer
50 | TypeSlice
51 | TypeArray
52 | TypeChan
53 | TypeMap
54 | TypeSignature
55 | TypeStruct
56 | TypeInterface
57 | TypeUnion
58 | TypeTypeParam
59 | )
60 |
61 | // A CodeObj distinguishes among go/types.Object encodings.
62 | type CodeObj int
63 |
64 | func (c CodeObj) Marker() SyncMarker { return SyncCodeObj }
65 | func (c CodeObj) Value() int { return int(c) }
66 |
67 | // Note: These values are public and cannot be changed without
68 | // updating the go/types importers.
69 |
70 | const (
71 | ObjAlias CodeObj = iota
72 | ObjConst
73 | ObjType
74 | ObjFunc
75 | ObjVar
76 | ObjStub
77 | )
78 |
--------------------------------------------------------------------------------
/vendor/golang.org/x/tools/internal/pkgbits/doc.go:
--------------------------------------------------------------------------------
1 | // Copyright 2022 The Go Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | // Package pkgbits implements low-level coding abstractions for
6 | // Unified IR's export data format.
7 | //
8 | // At a low-level, a package is a collection of bitstream elements.
9 | // Each element has a "kind" and a dense, non-negative index.
10 | // Elements can be randomly accessed given their kind and index.
11 | //
12 | // Individual elements are sequences of variable-length values (e.g.,
13 | // integers, booleans, strings, go/constant values, cross-references
14 | // to other elements). Package pkgbits provides APIs for encoding and
15 | // decoding these low-level values, but the details of mapping
16 | // higher-level Go constructs into elements is left to higher-level
17 | // abstractions.
18 | //
19 | // Elements may cross-reference each other with "relocations." For
20 | // example, an element representing a pointer type has a relocation
21 | // referring to the element type.
22 | //
23 | // Go constructs may be composed as a constellation of multiple
24 | // elements. For example, a declared function may have one element to
25 | // describe the object (e.g., its name, type, position), and a
26 | // separate element to describe its function body. This allows readers
27 | // some flexibility in efficiently seeking or re-reading data (e.g.,
28 | // inlining requires re-reading the function body for each inlined
29 | // call, without needing to re-read the object-level details).
30 | //
31 | // This is a copy of internal/pkgbits in the Go implementation.
32 | package pkgbits
33 |
--------------------------------------------------------------------------------
/vendor/golang.org/x/tools/internal/pkgbits/flags.go:
--------------------------------------------------------------------------------
1 | // Copyright 2022 The Go Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | package pkgbits
6 |
7 | const (
8 | flagSyncMarkers = 1 << iota // file format contains sync markers
9 | )
10 |
--------------------------------------------------------------------------------
/vendor/golang.org/x/tools/internal/pkgbits/reloc.go:
--------------------------------------------------------------------------------
1 | // Copyright 2021 The Go Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | package pkgbits
6 |
7 | // A RelocKind indicates a particular section within a unified IR export.
8 | type RelocKind int32
9 |
10 | // An Index represents a bitstream element index within a particular
11 | // section.
12 | type Index int32
13 |
14 | // A relocEnt (relocation entry) is an entry in an element's local
15 | // reference table.
16 | //
17 | // TODO(mdempsky): Rename this too.
18 | type RelocEnt struct {
19 | Kind RelocKind
20 | Idx Index
21 | }
22 |
23 | // Reserved indices within the meta relocation section.
24 | const (
25 | PublicRootIdx Index = 0
26 | PrivateRootIdx Index = 1
27 | )
28 |
29 | const (
30 | RelocString RelocKind = iota
31 | RelocMeta
32 | RelocPosBase
33 | RelocPkg
34 | RelocName
35 | RelocType
36 | RelocObj
37 | RelocObjExt
38 | RelocObjDict
39 | RelocBody
40 |
41 | numRelocs = iota
42 | )
43 |
--------------------------------------------------------------------------------
/vendor/golang.org/x/tools/internal/pkgbits/support.go:
--------------------------------------------------------------------------------
1 | // Copyright 2022 The Go Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | package pkgbits
6 |
7 | import "fmt"
8 |
9 | func assert(b bool) {
10 | if !b {
11 | panic("assertion failed")
12 | }
13 | }
14 |
15 | func panicf(format string, args ...any) {
16 | panic(fmt.Errorf(format, args...))
17 | }
18 |
--------------------------------------------------------------------------------
/vendor/golang.org/x/tools/internal/typesinternal/qualifier.go:
--------------------------------------------------------------------------------
1 | // Copyright 2024 The Go Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | package typesinternal
6 |
7 | import (
8 | "go/ast"
9 | "go/types"
10 | "strconv"
11 | )
12 |
13 | // FileQualifier returns a [types.Qualifier] function that qualifies
14 | // imported symbols appropriately based on the import environment of a given
15 | // file.
16 | // If the same package is imported multiple times, the last appearance is
17 | // recorded.
18 | func FileQualifier(f *ast.File, pkg *types.Package) types.Qualifier {
19 | // Construct mapping of import paths to their defined names.
20 | // It is only necessary to look at renaming imports.
21 | imports := make(map[string]string)
22 | for _, imp := range f.Imports {
23 | if imp.Name != nil && imp.Name.Name != "_" {
24 | path, _ := strconv.Unquote(imp.Path.Value)
25 | imports[path] = imp.Name.Name
26 | }
27 | }
28 |
29 | // Define qualifier to replace full package paths with names of the imports.
30 | return func(p *types.Package) string {
31 | if p == nil || p == pkg {
32 | return ""
33 | }
34 |
35 | if name, ok := imports[p.Path()]; ok {
36 | if name == "." {
37 | return ""
38 | } else {
39 | return name
40 | }
41 | }
42 |
43 | // If there is no local renaming, fall back to the package name.
44 | return p.Name()
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/vendor/golang.org/x/tools/internal/typesinternal/recv.go:
--------------------------------------------------------------------------------
1 | // Copyright 2024 The Go Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | package typesinternal
6 |
7 | import (
8 | "go/types"
9 | )
10 |
11 | // ReceiverNamed returns the named type (if any) associated with the
12 | // type of recv, which may be of the form N or *N, or aliases thereof.
13 | // It also reports whether a Pointer was present.
14 | //
15 | // The named result may be nil if recv is from a method on an
16 | // anonymous interface or struct types or in ill-typed code.
17 | func ReceiverNamed(recv *types.Var) (isPtr bool, named *types.Named) {
18 | t := recv.Type()
19 | if ptr, ok := types.Unalias(t).(*types.Pointer); ok {
20 | isPtr = true
21 | t = ptr.Elem()
22 | }
23 | named, _ = types.Unalias(t).(*types.Named)
24 | return
25 | }
26 |
27 | // Unpointer returns T given *T or an alias thereof.
28 | // For all other types it is the identity function.
29 | // It does not look at underlying types.
30 | // The result may be an alias.
31 | //
32 | // Use this function to strip off the optional pointer on a receiver
33 | // in a field or method selection, without losing the named type
34 | // (which is needed to compute the method set).
35 | //
36 | // See also [typeparams.MustDeref], which removes one level of
37 | // indirection from the type, regardless of named types (analogous to
38 | // a LOAD instruction).
39 | func Unpointer(t types.Type) types.Type {
40 | if ptr, ok := types.Unalias(t).(*types.Pointer); ok {
41 | return ptr.Elem()
42 | }
43 | return t
44 | }
45 |
--------------------------------------------------------------------------------
/vendor/golang.org/x/tools/internal/typesinternal/varkind.go:
--------------------------------------------------------------------------------
1 | // Copyright 2024 The Go Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | package typesinternal
6 |
7 | // TODO(adonovan): when CL 645115 lands, define the go1.25 version of
8 | // this API that actually does something.
9 |
10 | import "go/types"
11 |
12 | type VarKind uint8
13 |
14 | const (
15 | _ VarKind = iota // (not meaningful)
16 | PackageVar // a package-level variable
17 | LocalVar // a local variable
18 | RecvVar // a method receiver variable
19 | ParamVar // a function parameter variable
20 | ResultVar // a function result variable
21 | FieldVar // a struct field
22 | )
23 |
24 | func (kind VarKind) String() string {
25 | return [...]string{
26 | 0: "VarKind(0)",
27 | PackageVar: "PackageVar",
28 | LocalVar: "LocalVar",
29 | RecvVar: "RecvVar",
30 | ParamVar: "ParamVar",
31 | ResultVar: "ResultVar",
32 | FieldVar: "FieldVar",
33 | }[kind]
34 | }
35 |
36 | // GetVarKind returns an invalid VarKind.
37 | func GetVarKind(v *types.Var) VarKind { return 0 }
38 |
39 | // SetVarKind has no effect.
40 | func SetVarKind(v *types.Var, kind VarKind) {}
41 |
--------------------------------------------------------------------------------
/vendor/golang.org/x/tools/internal/versions/features.go:
--------------------------------------------------------------------------------
1 | // Copyright 2023 The Go Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | package versions
6 |
7 | // This file contains predicates for working with file versions to
8 | // decide when a tool should consider a language feature enabled.
9 |
10 | // GoVersions that features in x/tools can be gated to.
11 | const (
12 | Go1_18 = "go1.18"
13 | Go1_19 = "go1.19"
14 | Go1_20 = "go1.20"
15 | Go1_21 = "go1.21"
16 | Go1_22 = "go1.22"
17 | )
18 |
19 | // Future is an invalid unknown Go version sometime in the future.
20 | // Do not use directly with Compare.
21 | const Future = ""
22 |
23 | // AtLeast reports whether the file version v comes after a Go release.
24 | //
25 | // Use this predicate to enable a behavior once a certain Go release
26 | // has happened (and stays enabled in the future).
27 | func AtLeast(v, release string) bool {
28 | if v == Future {
29 | return true // an unknown future version is always after y.
30 | }
31 | return Compare(Lang(v), Lang(release)) >= 0
32 | }
33 |
34 | // Before reports whether the file version v is strictly before a Go release.
35 | //
36 | // Use this predicate to disable a behavior once a certain Go release
37 | // has happened (and stays enabled in the future).
38 | func Before(v, release string) bool {
39 | if v == Future {
40 | return false // an unknown future version happens after y.
41 | }
42 | return Compare(Lang(v), Lang(release)) < 0
43 | }
44 |
--------------------------------------------------------------------------------
/vendor/golang.org/x/tools/internal/versions/types.go:
--------------------------------------------------------------------------------
1 | // Copyright 2023 The Go Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | package versions
6 |
7 | import (
8 | "go/ast"
9 | "go/types"
10 | )
11 |
12 | // FileVersion returns a file's Go version.
13 | // The reported version is an unknown Future version if a
14 | // version cannot be determined.
15 | func FileVersion(info *types.Info, file *ast.File) string {
16 | // In tools built with Go >= 1.22, the Go version of a file
17 | // follow a cascades of sources:
18 | // 1) types.Info.FileVersion, which follows the cascade:
19 | // 1.a) file version (ast.File.GoVersion),
20 | // 1.b) the package version (types.Config.GoVersion), or
21 | // 2) is some unknown Future version.
22 | //
23 | // File versions require a valid package version to be provided to types
24 | // in Config.GoVersion. Config.GoVersion is either from the package's module
25 | // or the toolchain (go run). This value should be provided by go/packages
26 | // or unitchecker.Config.GoVersion.
27 | if v := info.FileVersions[file]; IsValid(v) {
28 | return v
29 | }
30 | // Note: we could instead return runtime.Version() [if valid].
31 | // This would act as a max version on what a tool can support.
32 | return Future
33 | }
34 |
--------------------------------------------------------------------------------
/vendor/honnef.co/go/tools/LICENSE:
--------------------------------------------------------------------------------
1 | Copyright (c) 2016 Dominik Honnef
2 |
3 | Permission is hereby granted, free of charge, to any person obtaining
4 | a copy of this software and associated documentation files (the
5 | "Software"), to deal in the Software without restriction, including
6 | without limitation the rights to use, copy, modify, merge, publish,
7 | distribute, sublicense, and/or sell copies of the Software, and to
8 | permit persons to whom the Software is furnished to do so, subject to
9 | the following conditions:
10 |
11 | The above copyright notice and this permission notice shall be
12 | included in all copies or substantial portions of the Software.
13 |
14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21 |
--------------------------------------------------------------------------------
/vendor/honnef.co/go/tools/analysis/code/visit.go:
--------------------------------------------------------------------------------
1 | package code
2 |
3 | import (
4 | "bytes"
5 | "go/ast"
6 | "go/format"
7 |
8 | "honnef.co/go/tools/pattern"
9 |
10 | "golang.org/x/tools/go/analysis"
11 | "golang.org/x/tools/go/analysis/passes/inspect"
12 | "golang.org/x/tools/go/ast/inspector"
13 | )
14 |
15 | func Preorder(pass *analysis.Pass, fn func(ast.Node), types ...ast.Node) {
16 | pass.ResultOf[inspect.Analyzer].(*inspector.Inspector).Preorder(types, fn)
17 | }
18 |
19 | func PreorderStack(pass *analysis.Pass, fn func(ast.Node, []ast.Node), types ...ast.Node) {
20 | pass.ResultOf[inspect.Analyzer].(*inspector.Inspector).WithStack(types, func(n ast.Node, push bool, stack []ast.Node) (proceed bool) {
21 | if push {
22 | fn(n, stack)
23 | }
24 | return true
25 | })
26 | }
27 |
28 | func Match(pass *analysis.Pass, q pattern.Pattern, node ast.Node) (*pattern.Matcher, bool) {
29 | // Note that we ignore q.Relevant – callers of Match usually use
30 | // AST inspectors that already filter on nodes we're interested
31 | // in.
32 | m := &pattern.Matcher{TypesInfo: pass.TypesInfo}
33 | ok := m.Match(q, node)
34 | return m, ok
35 | }
36 |
37 | func MatchAndEdit(pass *analysis.Pass, before, after pattern.Pattern, node ast.Node) (*pattern.Matcher, []analysis.TextEdit, bool) {
38 | m, ok := Match(pass, before, node)
39 | if !ok {
40 | return m, nil, false
41 | }
42 | r := pattern.NodeToAST(after.Root, m.State)
43 | buf := &bytes.Buffer{}
44 | format.Node(buf, pass.Fset, r)
45 | edit := []analysis.TextEdit{{
46 | Pos: node.Pos(),
47 | End: node.End(),
48 | NewText: buf.Bytes(),
49 | }}
50 | return m, edit, true
51 | }
52 |
--------------------------------------------------------------------------------
/vendor/honnef.co/go/tools/analysis/facts/directives/directives.go:
--------------------------------------------------------------------------------
1 | package directives
2 |
3 | import (
4 | "reflect"
5 |
6 | "golang.org/x/tools/go/analysis"
7 | "honnef.co/go/tools/analysis/lint"
8 | )
9 |
10 | func directives(pass *analysis.Pass) (interface{}, error) {
11 | return lint.ParseDirectives(pass.Files, pass.Fset), nil
12 | }
13 |
14 | var Analyzer = &analysis.Analyzer{
15 | Name: "directives",
16 | Doc: "extracts linter directives",
17 | Run: directives,
18 | RunDespiteErrors: true,
19 | ResultType: reflect.TypeOf([]lint.Directive{}),
20 | }
21 |
--------------------------------------------------------------------------------
/vendor/honnef.co/go/tools/analysis/facts/tokenfile/token.go:
--------------------------------------------------------------------------------
1 | package tokenfile
2 |
3 | import (
4 | "go/ast"
5 | "go/token"
6 | "reflect"
7 |
8 | "golang.org/x/tools/go/analysis"
9 | )
10 |
11 | var Analyzer = &analysis.Analyzer{
12 | Name: "tokenfileanalyzer",
13 | Doc: "creates a mapping of *token.File to *ast.File",
14 | Run: func(pass *analysis.Pass) (interface{}, error) {
15 | m := map[*token.File]*ast.File{}
16 | for _, af := range pass.Files {
17 | tf := pass.Fset.File(af.Pos())
18 | m[tf] = af
19 | }
20 | return m, nil
21 | },
22 | RunDespiteErrors: true,
23 | ResultType: reflect.TypeOf(map[*token.File]*ast.File{}),
24 | }
25 |
--------------------------------------------------------------------------------
/vendor/honnef.co/go/tools/cmd/staticcheck/README.md:
--------------------------------------------------------------------------------
1 | # staticcheck
2 |
3 | _staticcheck_ offers extensive analysis of Go code, covering a myriad
4 | of categories. It will detect bugs, suggest code simplifications,
5 | point out dead code, and more.
6 |
7 | ## Installation
8 |
9 | See [the main README](https://github.com/dominikh/go-tools#installation) for installation instructions.
10 |
11 | ## Documentation
12 |
13 | Detailed documentation can be found on
14 | [staticcheck.dev](https://staticcheck.dev/docs/).
15 |
16 |
--------------------------------------------------------------------------------
/vendor/honnef.co/go/tools/cmd/staticcheck/staticcheck.go:
--------------------------------------------------------------------------------
1 | // staticcheck analyses Go code and makes it better.
2 | package main
3 |
4 | import (
5 | "log"
6 | "os"
7 |
8 | "honnef.co/go/tools/lintcmd"
9 | "honnef.co/go/tools/lintcmd/version"
10 | "honnef.co/go/tools/quickfix"
11 | "honnef.co/go/tools/simple"
12 | "honnef.co/go/tools/staticcheck"
13 | "honnef.co/go/tools/stylecheck"
14 | "honnef.co/go/tools/unused"
15 | )
16 |
17 | func main() {
18 | cmd := lintcmd.NewCommand("staticcheck")
19 | cmd.SetVersion(version.Version, version.MachineVersion)
20 |
21 | fs := cmd.FlagSet()
22 | debug := fs.String("debug.unused-graph", "", "Write unused's object graph to `file`")
23 | qf := fs.Bool("debug.run-quickfix-analyzers", false, "Run quickfix analyzers")
24 |
25 | cmd.ParseFlags(os.Args[1:])
26 |
27 | cmd.AddAnalyzers(simple.Analyzers...)
28 | cmd.AddAnalyzers(staticcheck.Analyzers...)
29 | cmd.AddAnalyzers(stylecheck.Analyzers...)
30 | cmd.AddAnalyzers(unused.Analyzer)
31 |
32 | if *qf {
33 | cmd.AddAnalyzers(quickfix.Analyzers...)
34 | }
35 |
36 | if *debug != "" {
37 | f, err := os.OpenFile(*debug, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0666)
38 | if err != nil {
39 | log.Fatal(err)
40 | }
41 | unused.Debug = f
42 | }
43 |
44 | cmd.Run()
45 | }
46 |
--------------------------------------------------------------------------------
/vendor/honnef.co/go/tools/config/example.conf:
--------------------------------------------------------------------------------
1 | checks = ["all", "-SA9003", "-ST1000", "-ST1003", "-ST1016", "-ST1020", "-ST1021", "-ST1022", "-ST1023"]
2 | initialisms = ["ACL", "API", "ASCII", "CPU", "CSS", "DNS",
3 | "EOF", "GUID", "HTML", "HTTP", "HTTPS", "ID",
4 | "IP", "JSON", "QPS", "RAM", "RPC", "SLA",
5 | "SMTP", "SQL", "SSH", "TCP", "TLS", "TTL",
6 | "UDP", "UI", "GID", "UID", "UUID", "URI",
7 | "URL", "UTF8", "VM", "XML", "XMPP", "XSRF",
8 | "XSS", "SIP", "RTP", "AMQP", "DB", "TS"]
9 | dot_import_whitelist = [
10 | "github.com/mmcloughlin/avo/build",
11 | "github.com/mmcloughlin/avo/operand",
12 | "github.com/mmcloughlin/avo/reg",
13 | ]
14 | http_status_code_whitelist = ["200", "400", "404", "500"]
15 |
--------------------------------------------------------------------------------
/vendor/honnef.co/go/tools/go/ast/astutil/upstream.go:
--------------------------------------------------------------------------------
1 | package astutil
2 |
3 | import (
4 | "go/ast"
5 | "go/token"
6 | _ "unsafe"
7 |
8 | "golang.org/x/tools/go/ast/astutil"
9 | )
10 |
11 | type Cursor = astutil.Cursor
12 | type ApplyFunc = astutil.ApplyFunc
13 |
14 | func Apply(root ast.Node, pre, post ApplyFunc) (result ast.Node) {
15 | return astutil.Apply(root, pre, post)
16 | }
17 |
18 | func PathEnclosingInterval(root *ast.File, start, end token.Pos) (path []ast.Node, exact bool) {
19 | return astutil.PathEnclosingInterval(root, start, end)
20 | }
21 |
--------------------------------------------------------------------------------
/vendor/honnef.co/go/tools/go/buildid/UPSTREAM:
--------------------------------------------------------------------------------
1 | This package extracts buildid.go and note.go from cmd/internal/buildid/.
2 |
3 | We have modified it to remove support for AIX big archive files, to cut down on our dependencies.
4 |
5 | The last upstream commit we've looked at was: e8ee1dc4f9e2632ba1018610d1a1187743ae397f
6 |
--------------------------------------------------------------------------------
/vendor/honnef.co/go/tools/go/ir/LICENSE:
--------------------------------------------------------------------------------
1 | Copyright (c) 2009 The Go Authors. All rights reserved.
2 | Copyright (c) 2016 Dominik Honnef. All rights reserved.
3 |
4 | Redistribution and use in source and binary forms, with or without
5 | modification, are permitted provided that the following conditions are
6 | met:
7 |
8 | * Redistributions of source code must retain the above copyright
9 | notice, this list of conditions and the following disclaimer.
10 | * Redistributions in binary form must reproduce the above
11 | copyright notice, this list of conditions and the following disclaimer
12 | in the documentation and/or other materials provided with the
13 | distribution.
14 | * Neither the name of Google Inc. nor the names of its
15 | contributors may be used to endorse or promote products derived from
16 | this software without specific prior written permission.
17 |
18 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 |
--------------------------------------------------------------------------------
/vendor/honnef.co/go/tools/go/ir/UPSTREAM:
--------------------------------------------------------------------------------
1 | This package started as a copy of golang.org/x/tools/go/ssa, imported from an unknown commit in 2016.
2 | It has since been heavily modified to match our own needs in an IR.
3 | The changes are too many to list here, and it is best to consider this package independent of go/ssa.
4 |
5 | Upstream changes still get applied when they address bugs in portions of code we have inherited.
6 |
7 | The last upstream commit we've looked at was:
8 | ac2946029ad3806349fa00546449da9f59320e89
9 |
10 |
--------------------------------------------------------------------------------
/vendor/honnef.co/go/tools/go/ir/irutil/loops.go:
--------------------------------------------------------------------------------
1 | package irutil
2 |
3 | import "honnef.co/go/tools/go/ir"
4 |
5 | type Loop struct{ *ir.BlockSet }
6 |
7 | func FindLoops(fn *ir.Function) []Loop {
8 | if fn.Blocks == nil {
9 | return nil
10 | }
11 | tree := fn.DomPreorder()
12 | var sets []Loop
13 | for _, h := range tree {
14 | for _, n := range h.Preds {
15 | if !h.Dominates(n) {
16 | continue
17 | }
18 | // n is a back-edge to h
19 | // h is the loop header
20 | if n == h {
21 | set := Loop{ir.NewBlockSet(len(fn.Blocks))}
22 | set.Add(n)
23 | sets = append(sets, set)
24 | continue
25 | }
26 | set := Loop{ir.NewBlockSet(len(fn.Blocks))}
27 | set.Add(h)
28 | set.Add(n)
29 | for _, b := range allPredsBut(n, h, nil) {
30 | set.Add(b)
31 | }
32 | sets = append(sets, set)
33 | }
34 | }
35 | return sets
36 | }
37 |
38 | func allPredsBut(b, but *ir.BasicBlock, list []*ir.BasicBlock) []*ir.BasicBlock {
39 | outer:
40 | for _, pred := range b.Preds {
41 | if pred == but {
42 | continue
43 | }
44 | for _, p := range list {
45 | // TODO improve big-o complexity of this function
46 | if pred == p {
47 | continue outer
48 | }
49 | }
50 | list = append(list, pred)
51 | list = allPredsBut(pred, but, list)
52 | }
53 | return list
54 | }
55 |
--------------------------------------------------------------------------------
/vendor/honnef.co/go/tools/go/ir/irutil/stub.go:
--------------------------------------------------------------------------------
1 | package irutil
2 |
3 | import (
4 | "honnef.co/go/tools/go/ir"
5 | )
6 |
7 | // IsStub reports whether a function is a stub. A function is
8 | // considered a stub if it has no instructions or if all it does is
9 | // return a constant value.
10 | func IsStub(fn *ir.Function) bool {
11 | for _, b := range fn.Blocks {
12 | for _, instr := range b.Instrs {
13 | switch instr.(type) {
14 | case *ir.Const:
15 | // const naturally has no side-effects
16 | case *ir.Panic:
17 | // panic is a stub if it only uses constants
18 | case *ir.Return:
19 | // return is a stub if it only uses constants
20 | case *ir.DebugRef:
21 | case *ir.Jump:
22 | // if there are no disallowed instructions, then we're
23 | // only jumping to the exit block (or possibly
24 | // somewhere else that's stubby?)
25 | default:
26 | // all other instructions are assumed to do actual work
27 | return false
28 | }
29 | }
30 | }
31 | return true
32 | }
33 |
--------------------------------------------------------------------------------
/vendor/honnef.co/go/tools/go/ir/irutil/terminates.go:
--------------------------------------------------------------------------------
1 | package irutil
2 |
3 | import (
4 | "go/types"
5 |
6 | "honnef.co/go/tools/go/ir"
7 | )
8 |
9 | // Terminates reports whether fn is supposed to return, that is if it
10 | // has at least one theoretic path that returns from the function.
11 | // Explicit panics do not count as terminating.
12 | func Terminates(fn *ir.Function) bool {
13 | if fn.Blocks == nil {
14 | // assuming that a function terminates is the conservative
15 | // choice
16 | return true
17 | }
18 |
19 | for _, block := range fn.Blocks {
20 | if _, ok := block.Control().(*ir.Return); ok {
21 | if len(block.Preds) == 0 {
22 | return true
23 | }
24 | for _, pred := range block.Preds {
25 | switch ctrl := pred.Control().(type) {
26 | case *ir.Panic:
27 | // explicit panics do not count as terminating
28 | case *ir.If:
29 | // Check if we got here by receiving from a closed
30 | // time.Tick channel – this cannot happen at
31 | // runtime and thus doesn't constitute termination
32 | iff := ctrl
33 | if !ok {
34 | return true
35 | }
36 | ex, ok := iff.Cond.(*ir.Extract)
37 | if !ok {
38 | return true
39 | }
40 | if ex.Index != 1 {
41 | return true
42 | }
43 | recv, ok := ex.Tuple.(*ir.Recv)
44 | if !ok {
45 | return true
46 | }
47 | call, ok := recv.Chan.(*ir.Call)
48 | if !ok {
49 | return true
50 | }
51 | fn, ok := call.Common().Value.(*ir.Function)
52 | if !ok {
53 | return true
54 | }
55 | fn2, ok := fn.Object().(*types.Func)
56 | if !ok {
57 | return true
58 | }
59 | if fn2.FullName() != "time.Tick" {
60 | return true
61 | }
62 | default:
63 | // we've reached the exit block
64 | return true
65 | }
66 | }
67 | }
68 | }
69 | return false
70 | }
71 |
--------------------------------------------------------------------------------
/vendor/honnef.co/go/tools/go/ir/write.go:
--------------------------------------------------------------------------------
1 | package ir
2 |
3 | func NewJump(parent *BasicBlock) *Jump {
4 | return &Jump{anInstruction{block: parent}}
5 | }
6 |
--------------------------------------------------------------------------------
/vendor/honnef.co/go/tools/go/types/typeutil/ext.go:
--------------------------------------------------------------------------------
1 | package typeutil
2 |
3 | import (
4 | "fmt"
5 | "go/types"
6 | )
7 |
8 | type Iterator struct {
9 | elem types.Type
10 | }
11 |
12 | func (t *Iterator) Underlying() types.Type { return t }
13 | func (t *Iterator) String() string { return fmt.Sprintf("iterator(%s)", t.elem) }
14 | func (t *Iterator) Elem() types.Type { return t.elem }
15 |
16 | func NewIterator(elem types.Type) *Iterator {
17 | return &Iterator{elem: elem}
18 | }
19 |
20 | type DeferStack struct{}
21 |
22 | func (t *DeferStack) Underlying() types.Type { return t }
23 | func (t *DeferStack) String() string { return "deferStack" }
24 |
25 | func NewDeferStack() *DeferStack {
26 | return &DeferStack{}
27 | }
28 |
--------------------------------------------------------------------------------
/vendor/honnef.co/go/tools/go/types/typeutil/upstream.go:
--------------------------------------------------------------------------------
1 | package typeutil
2 |
3 | import (
4 | "go/ast"
5 | "go/types"
6 | _ "unsafe"
7 |
8 | "golang.org/x/tools/go/types/typeutil"
9 | )
10 |
11 | type MethodSetCache = typeutil.MethodSetCache
12 | type Hasher = typeutil.Hasher
13 |
14 | func Callee(info *types.Info, call *ast.CallExpr) types.Object {
15 | return typeutil.Callee(info, call)
16 | }
17 |
18 | func IntuitiveMethodSet(T types.Type, msets *MethodSetCache) []*types.Selection {
19 | return typeutil.IntuitiveMethodSet(T, msets)
20 | }
21 |
22 | func MakeHasher() Hasher {
23 | return typeutil.MakeHasher()
24 | }
25 |
26 | type Map[V any] struct {
27 | m typeutil.Map
28 | }
29 |
30 | func (m *Map[V]) Delete(key types.Type) bool { return m.m.Delete(key) }
31 | func (m *Map[V]) At(key types.Type) (V, bool) {
32 | v := m.m.At(key)
33 | if v == nil {
34 | var zero V
35 | return zero, false
36 | } else {
37 | return v.(V), true
38 | }
39 | }
40 | func (m *Map[V]) Set(key types.Type, value V) { m.m.Set(key, value) }
41 | func (m *Map[V]) Len() int { return m.m.Len() }
42 | func (m *Map[V]) Iterate(f func(key types.Type, value V)) {
43 | ff := func(key types.Type, value interface{}) {
44 | f(key, value.(V))
45 | }
46 | m.m.Iterate(ff)
47 |
48 | }
49 | func (m *Map[V]) Keys() []types.Type { return m.m.Keys() }
50 | func (m *Map[V]) String() string { return m.m.String() }
51 | func (m *Map[V]) KeysString() string { return m.m.KeysString() }
52 | func (m *Map[V]) SetHasher(h typeutil.Hasher) { m.m.SetHasher(h) }
53 |
--------------------------------------------------------------------------------
/vendor/honnef.co/go/tools/internal/renameio/UPSTREAM:
--------------------------------------------------------------------------------
1 | This package is a copy of cmd/go/internal/renameio.
2 | The upstream package no longer exists, as the Go project replaced all of its uses with the lockedfile package.
3 |
--------------------------------------------------------------------------------
/vendor/honnef.co/go/tools/internal/robustio/UPSTREAM:
--------------------------------------------------------------------------------
1 | This package is a copy of cmd/go/internal/robustio.
2 | It is mostly in sync with upstream according to the last commit we've looked at,
3 | with the exception of still using I/O functions that work with older Go versions.
4 |
5 | The last upstream commit we've looked at was:
6 | dc04f3ba1f25313bc9c97e728620206c235db9ee
7 |
--------------------------------------------------------------------------------
/vendor/honnef.co/go/tools/internal/robustio/robustio_darwin.go:
--------------------------------------------------------------------------------
1 | // Copyright 2019 The Go Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | package robustio
6 |
7 | import (
8 | "errors"
9 | "syscall"
10 | )
11 |
12 | const errFileNotFound = syscall.ENOENT
13 |
14 | // isEphemeralError returns true if err may be resolved by waiting.
15 | func isEphemeralError(err error) bool {
16 | var errno syscall.Errno
17 | if errors.As(err, &errno) {
18 | return errno == errFileNotFound
19 | }
20 | return false
21 | }
22 |
--------------------------------------------------------------------------------
/vendor/honnef.co/go/tools/internal/robustio/robustio_other.go:
--------------------------------------------------------------------------------
1 | // Copyright 2019 The Go Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | //go:build !windows && !darwin
6 |
7 | package robustio
8 |
9 | import (
10 | "os"
11 | )
12 |
13 | func rename(oldpath, newpath string) error {
14 | return os.Rename(oldpath, newpath)
15 | }
16 |
17 | func readFile(filename string) ([]byte, error) {
18 | return os.ReadFile(filename)
19 | }
20 |
21 | func removeAll(path string) error {
22 | return os.RemoveAll(path)
23 | }
24 |
25 | func isEphemeralError(err error) bool {
26 | return false
27 | }
28 |
--------------------------------------------------------------------------------
/vendor/honnef.co/go/tools/internal/robustio/robustio_windows.go:
--------------------------------------------------------------------------------
1 | // Copyright 2019 The Go Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | package robustio
6 |
7 | import (
8 | "errors"
9 | "syscall"
10 | )
11 |
12 | const ERROR_SHARING_VIOLATION = 32
13 | const errFileNotFound = syscall.ERROR_FILE_NOT_FOUND
14 |
15 | // isEphemeralError returns true if err may be resolved by waiting.
16 | func isEphemeralError(err error) bool {
17 | var errno syscall.Errno
18 | if errors.As(err, &errno) {
19 | switch errno {
20 | case syscall.ERROR_ACCESS_DENIED,
21 | syscall.ERROR_FILE_NOT_FOUND,
22 | ERROR_SHARING_VIOLATION:
23 | return true
24 | }
25 | }
26 | return false
27 | }
28 |
--------------------------------------------------------------------------------
/vendor/honnef.co/go/tools/internal/sync/sync.go:
--------------------------------------------------------------------------------
1 | package sync
2 |
3 | type Semaphore struct {
4 | ch chan struct{}
5 | }
6 |
7 | func NewSemaphore(size int) Semaphore {
8 | return Semaphore{
9 | ch: make(chan struct{}, size),
10 | }
11 | }
12 |
13 | func (sem Semaphore) Acquire() {
14 | sem.ch <- struct{}{}
15 | }
16 |
17 | func (sem Semaphore) AcquireMaybe() bool {
18 | select {
19 | case sem.ch <- struct{}{}:
20 | return true
21 | default:
22 | return false
23 | }
24 | }
25 |
26 | func (sem Semaphore) Release() {
27 | <-sem.ch
28 | }
29 |
30 | func (sem Semaphore) Len() int {
31 | return len(sem.ch)
32 | }
33 |
34 | func (sem Semaphore) Cap() int {
35 | return cap(sem.ch)
36 | }
37 |
--------------------------------------------------------------------------------
/vendor/honnef.co/go/tools/knowledge/doc.go:
--------------------------------------------------------------------------------
1 | // Package knowledge contains manually collected information about Go APIs.
2 | package knowledge
3 |
--------------------------------------------------------------------------------
/vendor/honnef.co/go/tools/knowledge/targets.go:
--------------------------------------------------------------------------------
1 | package knowledge
2 |
3 | var KnownGOOS = map[string]struct{}{
4 | "aix": {},
5 | "android": {},
6 | "darwin": {},
7 | "dragonfly": {},
8 | "freebsd": {},
9 | "hurd": {},
10 | "illumos": {},
11 | "ios": {},
12 | "js": {},
13 | "linux": {},
14 | "netbsd": {},
15 | "openbsd": {},
16 | "plan9": {},
17 | "solaris": {},
18 | "wasip1": {},
19 | "windows": {},
20 | }
21 |
22 | var KnownGOARCH = map[string]struct{}{
23 | "386": {},
24 | "amd64": {},
25 | "arm": {},
26 | "arm64": {},
27 | "loong64": {},
28 | "mips": {},
29 | "mipsle": {},
30 | "mips64": {},
31 | "mips64le": {},
32 | "ppc64": {},
33 | "ppc64le": {},
34 | "riscv64": {},
35 | "s390x": {},
36 | "sparc64": {},
37 | "wasm": {},
38 | }
39 |
--------------------------------------------------------------------------------
/vendor/honnef.co/go/tools/lintcmd/cache/UPSTREAM:
--------------------------------------------------------------------------------
1 | This package is a copy of cmd/go/internal/cache.
2 |
3 | Differences from upstream:
4 | - we continue to use renameio instead of lockedfile for writing trim.txt
5 | - we still use I/O helpers that work with earlier versions of Go.
6 | - we use a cache directory specific to Staticcheck
7 | - we use a Staticcheck-specific salt
8 |
9 | The last upstream commit we've looked at was:
10 | 06ac303f6a14b133254f757e54599c48e3c2a4ad
11 |
--------------------------------------------------------------------------------
/vendor/honnef.co/go/tools/lintcmd/directives.go:
--------------------------------------------------------------------------------
1 | package lintcmd
2 |
3 | import (
4 | "strings"
5 |
6 | "honnef.co/go/tools/lintcmd/runner"
7 | )
8 |
9 | func parseDirectives(dirs []runner.SerializedDirective) ([]ignore, []diagnostic) {
10 | var ignores []ignore
11 | var diagnostics []diagnostic
12 |
13 | for _, dir := range dirs {
14 | cmd := dir.Command
15 | args := dir.Arguments
16 | switch cmd {
17 | case "ignore", "file-ignore":
18 | if len(args) < 2 {
19 | p := diagnostic{
20 | Diagnostic: runner.Diagnostic{
21 | Position: dir.NodePosition,
22 | Message: "malformed linter directive; missing the required reason field?",
23 | Category: "compile",
24 | },
25 | Severity: severityError,
26 | }
27 | diagnostics = append(diagnostics, p)
28 | continue
29 | }
30 | default:
31 | // unknown directive, ignore
32 | continue
33 | }
34 | checks := strings.Split(args[0], ",")
35 | pos := dir.NodePosition
36 | var ig ignore
37 | switch cmd {
38 | case "ignore":
39 | ig = &lineIgnore{
40 | File: pos.Filename,
41 | Line: pos.Line,
42 | Checks: checks,
43 | Pos: dir.DirectivePosition,
44 | }
45 | case "file-ignore":
46 | ig = &fileIgnore{
47 | File: pos.Filename,
48 | Checks: checks,
49 | }
50 | }
51 | ignores = append(ignores, ig)
52 | }
53 |
54 | return ignores, diagnostics
55 | }
56 |
--------------------------------------------------------------------------------
/vendor/honnef.co/go/tools/lintcmd/runner/stats.go:
--------------------------------------------------------------------------------
1 | package runner
2 |
3 | import (
4 | "sync/atomic"
5 | "time"
6 |
7 | "honnef.co/go/tools/go/loader"
8 |
9 | "golang.org/x/tools/go/analysis"
10 | )
11 |
12 | const (
13 | StateInitializing = iota
14 | StateLoadPackageGraph
15 | StateBuildActionGraph
16 | StateProcessing
17 | StateFinalizing
18 | )
19 |
20 | type Stats struct {
21 | state uint32
22 | initialPackages uint32
23 | totalPackages uint32
24 | processedPackages uint32
25 | processedInitialPackages uint32
26 |
27 | // optional function to call every time an analyzer has finished analyzing a package.
28 | PrintAnalyzerMeasurement func(*analysis.Analyzer, *loader.PackageSpec, time.Duration)
29 | }
30 |
31 | func (s *Stats) setState(state uint32) { atomic.StoreUint32(&s.state, state) }
32 | func (s *Stats) State() int { return int(atomic.LoadUint32(&s.state)) }
33 | func (s *Stats) setInitialPackages(n int) { atomic.StoreUint32(&s.initialPackages, uint32(n)) }
34 | func (s *Stats) InitialPackages() int { return int(atomic.LoadUint32(&s.initialPackages)) }
35 | func (s *Stats) setTotalPackages(n int) { atomic.StoreUint32(&s.totalPackages, uint32(n)) }
36 | func (s *Stats) TotalPackages() int { return int(atomic.LoadUint32(&s.totalPackages)) }
37 |
38 | func (s *Stats) finishPackage() { atomic.AddUint32(&s.processedPackages, 1) }
39 | func (s *Stats) finishInitialPackage() { atomic.AddUint32(&s.processedInitialPackages, 1) }
40 | func (s *Stats) ProcessedPackages() int { return int(atomic.LoadUint32(&s.processedPackages)) }
41 | func (s *Stats) ProcessedInitialPackages() int {
42 | return int(atomic.LoadUint32(&s.processedInitialPackages))
43 | }
44 |
45 | func (s *Stats) measureAnalyzer(analysis *analysis.Analyzer, pkg *loader.PackageSpec, d time.Duration) {
46 | if s.PrintAnalyzerMeasurement != nil {
47 | s.PrintAnalyzerMeasurement(analysis, pkg, d)
48 | }
49 | }
50 |
--------------------------------------------------------------------------------
/vendor/honnef.co/go/tools/lintcmd/stats.go:
--------------------------------------------------------------------------------
1 | //go:build !aix && !android && !darwin && !dragonfly && !freebsd && !linux && !netbsd && !openbsd && !solaris
2 | // +build !aix,!android,!darwin,!dragonfly,!freebsd,!linux,!netbsd,!openbsd,!solaris
3 |
4 | package lintcmd
5 |
6 | import "os"
7 |
8 | var infoSignals = []os.Signal{}
9 |
--------------------------------------------------------------------------------
/vendor/honnef.co/go/tools/lintcmd/stats_bsd.go:
--------------------------------------------------------------------------------
1 | //go:build darwin || dragonfly || freebsd || netbsd || openbsd
2 | // +build darwin dragonfly freebsd netbsd openbsd
3 |
4 | package lintcmd
5 |
6 | import (
7 | "os"
8 | "syscall"
9 | )
10 |
11 | var infoSignals = []os.Signal{syscall.SIGINFO}
12 |
--------------------------------------------------------------------------------
/vendor/honnef.co/go/tools/lintcmd/stats_posix.go:
--------------------------------------------------------------------------------
1 | //go:build aix || android || linux || solaris
2 | // +build aix android linux solaris
3 |
4 | package lintcmd
5 |
6 | import (
7 | "os"
8 | "syscall"
9 | )
10 |
11 | var infoSignals = []os.Signal{syscall.SIGUSR1}
12 |
--------------------------------------------------------------------------------
/vendor/honnef.co/go/tools/lintcmd/version/buildinfo.go:
--------------------------------------------------------------------------------
1 | package version
2 |
3 | import (
4 | "fmt"
5 | "runtime/debug"
6 | )
7 |
8 | func printBuildInfo() {
9 | if info, ok := debug.ReadBuildInfo(); ok {
10 | fmt.Println("Main module:")
11 | printModule(&info.Main)
12 | fmt.Println("Dependencies:")
13 | for _, dep := range info.Deps {
14 | printModule(dep)
15 | }
16 | } else {
17 | fmt.Println("Built without Go modules")
18 | }
19 | }
20 |
21 | func buildInfoVersion() (string, bool) {
22 | info, ok := debug.ReadBuildInfo()
23 | if !ok {
24 | return "", false
25 | }
26 | if info.Main.Version == "(devel)" {
27 | return "", false
28 | }
29 | return info.Main.Version, true
30 | }
31 |
32 | func printModule(m *debug.Module) {
33 | fmt.Printf("\t%s", m.Path)
34 | if m.Version != "(devel)" {
35 | fmt.Printf("@%s", m.Version)
36 | }
37 | if m.Sum != "" {
38 | fmt.Printf(" (sum: %s)", m.Sum)
39 | }
40 | if m.Replace != nil {
41 | fmt.Printf(" (replace: %s)", m.Replace.Path)
42 | }
43 | fmt.Println()
44 | }
45 |
--------------------------------------------------------------------------------
/vendor/honnef.co/go/tools/lintcmd/version/version.go:
--------------------------------------------------------------------------------
1 | package version
2 |
3 | import (
4 | "fmt"
5 | "os"
6 | "path/filepath"
7 | "runtime"
8 | )
9 |
10 | const Version = "2025.1.1"
11 | const MachineVersion = "0.6.1"
12 |
13 | // version returns a version descriptor and reports whether the
14 | // version is a known release.
15 | func version(human, machine string) (human_, machine_ string, known bool) {
16 | if human != "devel" {
17 | return human, machine, true
18 | }
19 | v, ok := buildInfoVersion()
20 | if ok {
21 | return v, "", false
22 | }
23 | return "devel", "", false
24 | }
25 |
26 | func Print(human, machine string) {
27 | human, machine, release := version(human, machine)
28 |
29 | if release {
30 | fmt.Printf("%s %s (%s)\n", filepath.Base(os.Args[0]), human, machine)
31 | } else if human == "devel" {
32 | fmt.Printf("%s (no version)\n", filepath.Base(os.Args[0]))
33 | } else {
34 | fmt.Printf("%s (devel, %s)\n", filepath.Base(os.Args[0]), human)
35 | }
36 | }
37 |
38 | func Verbose(human, machine string) {
39 | Print(human, machine)
40 | fmt.Println()
41 | fmt.Println("Compiled with Go version:", runtime.Version())
42 | printBuildInfo()
43 | }
44 |
--------------------------------------------------------------------------------
/vendor/honnef.co/go/tools/printf/fuzz.go:
--------------------------------------------------------------------------------
1 | //go:build gofuzz
2 | // +build gofuzz
3 |
4 | package printf
5 |
6 | func Fuzz(data []byte) int {
7 | _, err := Parse(string(data))
8 | if err == nil {
9 | return 1
10 | }
11 | return 0
12 | }
13 |
--------------------------------------------------------------------------------
/vendor/honnef.co/go/tools/quickfix/analysis.go:
--------------------------------------------------------------------------------
1 | // Code generated by generate.go. DO NOT EDIT.
2 |
3 | package quickfix
4 |
5 | import (
6 | "honnef.co/go/tools/analysis/lint"
7 | "honnef.co/go/tools/quickfix/qf1001"
8 | "honnef.co/go/tools/quickfix/qf1002"
9 | "honnef.co/go/tools/quickfix/qf1003"
10 | "honnef.co/go/tools/quickfix/qf1004"
11 | "honnef.co/go/tools/quickfix/qf1005"
12 | "honnef.co/go/tools/quickfix/qf1006"
13 | "honnef.co/go/tools/quickfix/qf1007"
14 | "honnef.co/go/tools/quickfix/qf1008"
15 | "honnef.co/go/tools/quickfix/qf1009"
16 | "honnef.co/go/tools/quickfix/qf1010"
17 | "honnef.co/go/tools/quickfix/qf1011"
18 | "honnef.co/go/tools/quickfix/qf1012"
19 | )
20 |
21 | var Analyzers = []*lint.Analyzer{
22 | qf1001.SCAnalyzer,
23 | qf1002.SCAnalyzer,
24 | qf1003.SCAnalyzer,
25 | qf1004.SCAnalyzer,
26 | qf1005.SCAnalyzer,
27 | qf1006.SCAnalyzer,
28 | qf1007.SCAnalyzer,
29 | qf1008.SCAnalyzer,
30 | qf1009.SCAnalyzer,
31 | qf1010.SCAnalyzer,
32 | qf1011.SCAnalyzer,
33 | qf1012.SCAnalyzer,
34 | }
35 |
--------------------------------------------------------------------------------
/vendor/honnef.co/go/tools/quickfix/doc.go:
--------------------------------------------------------------------------------
1 | //go:generate go run ../generate.go
2 |
3 | // Package quickfix contains analyzes that implement code refactorings.
4 | // None of these analyzers produce diagnostics that have to be followed.
5 | // Most of the time, they only provide alternative ways of doing things,
6 | // requiring users to make informed decisions.
7 | //
8 | // None of these analyzes should fail a build, and they are likely useless in CI as a whole.
9 | package quickfix
10 |
--------------------------------------------------------------------------------
/vendor/honnef.co/go/tools/quickfix/qf1006/qf1006.go:
--------------------------------------------------------------------------------
1 | package qf1006
2 |
3 | import (
4 | "go/ast"
5 | "go/token"
6 |
7 | "honnef.co/go/tools/analysis/code"
8 | "honnef.co/go/tools/analysis/edit"
9 | "honnef.co/go/tools/analysis/lint"
10 | "honnef.co/go/tools/analysis/report"
11 | "honnef.co/go/tools/go/ast/astutil"
12 | "honnef.co/go/tools/pattern"
13 |
14 | "golang.org/x/tools/go/analysis"
15 | "golang.org/x/tools/go/analysis/passes/inspect"
16 | )
17 |
18 | var SCAnalyzer = lint.InitializeAnalyzer(&lint.Analyzer{
19 | Analyzer: &analysis.Analyzer{
20 | Name: "QF1006",
21 | Run: run,
22 | Requires: []*analysis.Analyzer{inspect.Analyzer},
23 | },
24 | Doc: &lint.RawDocumentation{
25 | Title: `Lift \'if\'+\'break\' into loop condition`,
26 | Before: `
27 | for {
28 | if done {
29 | break
30 | }
31 | ...
32 | }`,
33 |
34 | After: `
35 | for !done {
36 | ...
37 | }`,
38 | Since: "2021.1",
39 | Severity: lint.SeverityHint,
40 | },
41 | })
42 |
43 | var Analyzer = SCAnalyzer.Analyzer
44 |
45 | var checkForLoopIfBreak = pattern.MustParse(`(ForStmt nil nil nil if@(IfStmt nil cond (BranchStmt "BREAK" nil) nil):_)`)
46 |
47 | func run(pass *analysis.Pass) (interface{}, error) {
48 | fn := func(node ast.Node) {
49 | m, ok := code.Match(pass, checkForLoopIfBreak, node)
50 | if !ok {
51 | return
52 | }
53 |
54 | pos := node.Pos() + token.Pos(len("for"))
55 | r := astutil.NegateDeMorgan(m.State["cond"].(ast.Expr), false)
56 |
57 | // FIXME(dh): we're leaving behind an empty line when we
58 | // delete the old if statement. However, we can't just delete
59 | // an additional character, in case there closing curly brace
60 | // is followed by a comment, or Windows newlines.
61 | report.Report(pass, m.State["if"].(ast.Node), "could lift into loop condition",
62 | report.Fixes(edit.Fix("Lift into loop condition",
63 | edit.ReplaceWithString(edit.Range{pos, pos}, " "+report.Render(pass, r)),
64 | edit.Delete(m.State["if"].(ast.Node)))))
65 | }
66 | code.Preorder(pass, fn, (*ast.ForStmt)(nil))
67 | return nil, nil
68 | }
69 |
--------------------------------------------------------------------------------
/vendor/honnef.co/go/tools/quickfix/qf1009/qf1009.go:
--------------------------------------------------------------------------------
1 | package qf1009
2 |
3 | import (
4 | "go/ast"
5 | "go/token"
6 |
7 | "honnef.co/go/tools/analysis/code"
8 | "honnef.co/go/tools/analysis/edit"
9 | "honnef.co/go/tools/analysis/lint"
10 | "honnef.co/go/tools/analysis/report"
11 | "honnef.co/go/tools/pattern"
12 |
13 | "golang.org/x/tools/go/analysis"
14 | "golang.org/x/tools/go/analysis/passes/inspect"
15 | )
16 |
17 | var SCAnalyzer = lint.InitializeAnalyzer(&lint.Analyzer{
18 | Analyzer: &analysis.Analyzer{
19 | Name: "QF1009",
20 | Run: run,
21 | Requires: []*analysis.Analyzer{inspect.Analyzer},
22 | },
23 | Doc: &lint.RawDocumentation{
24 | Title: `Use \'time.Time.Equal\' instead of \'==\' operator`,
25 | Since: "2021.1",
26 | Severity: lint.SeverityInfo,
27 | },
28 | })
29 |
30 | var Analyzer = SCAnalyzer.Analyzer
31 |
32 | var timeEqualR = pattern.MustParse(`(CallExpr (SelectorExpr lhs (Ident "Equal")) rhs)`)
33 |
34 | func run(pass *analysis.Pass) (interface{}, error) {
35 | // FIXME(dh): create proper suggested fix for renamed import
36 |
37 | fn := func(node ast.Node) {
38 | expr := node.(*ast.BinaryExpr)
39 | if expr.Op != token.EQL {
40 | return
41 | }
42 | if !code.IsOfTypeWithName(pass, expr.X, "time.Time") || !code.IsOfTypeWithName(pass, expr.Y, "time.Time") {
43 | return
44 | }
45 | report.Report(pass, node, "probably want to use time.Time.Equal instead",
46 | report.Fixes(edit.Fix("Use time.Time.Equal method",
47 | edit.ReplaceWithPattern(pass.Fset, node, timeEqualR, pattern.State{"lhs": expr.X, "rhs": expr.Y}))))
48 | }
49 | code.Preorder(pass, fn, (*ast.BinaryExpr)(nil))
50 | return nil, nil
51 | }
52 |
--------------------------------------------------------------------------------
/vendor/honnef.co/go/tools/quickfix/qf1011/qf1011.go:
--------------------------------------------------------------------------------
1 | package qf1011
2 |
3 | import (
4 | "honnef.co/go/tools/analysis/lint"
5 | "honnef.co/go/tools/internal/sharedcheck"
6 | )
7 |
8 | func init() {
9 | SCAnalyzer.Analyzer.Name = "QF1011"
10 | }
11 |
12 | var SCAnalyzer = lint.InitializeAnalyzer(&lint.Analyzer{
13 | Analyzer: sharedcheck.RedundantTypeInDeclarationChecker("could", true),
14 | Doc: &lint.RawDocumentation{
15 | Title: "Omit redundant type from variable declaration",
16 | Since: "2021.1",
17 | Severity: lint.SeverityHint,
18 | },
19 | })
20 |
21 | var Analyzer = SCAnalyzer.Analyzer
22 |
--------------------------------------------------------------------------------
/vendor/honnef.co/go/tools/simple/doc.go:
--------------------------------------------------------------------------------
1 | //go:generate go run ../generate.go
2 |
3 | // Package simple contains analyzes that simplify code.
4 | // All suggestions made by these analyzes are intended to result in objectively simpler code,
5 | // and following their advice is recommended.
6 | package simple
7 |
--------------------------------------------------------------------------------
/vendor/honnef.co/go/tools/simple/s1006/s1006.go:
--------------------------------------------------------------------------------
1 | package s1006
2 |
3 | import (
4 | "go/ast"
5 |
6 | "honnef.co/go/tools/analysis/code"
7 | "honnef.co/go/tools/analysis/facts/generated"
8 | "honnef.co/go/tools/analysis/lint"
9 | "honnef.co/go/tools/analysis/report"
10 |
11 | "golang.org/x/tools/go/analysis"
12 | "golang.org/x/tools/go/analysis/passes/inspect"
13 | )
14 |
15 | var SCAnalyzer = lint.InitializeAnalyzer(&lint.Analyzer{
16 | Analyzer: &analysis.Analyzer{
17 | Name: "S1006",
18 | Run: run,
19 | Requires: []*analysis.Analyzer{inspect.Analyzer, generated.Analyzer},
20 | },
21 | Doc: &lint.RawDocumentation{
22 | Title: `Use \"for { ... }\" for infinite loops`,
23 | Text: `For infinite loops, using \'for { ... }\' is the most idiomatic choice.`,
24 | Since: "2017.1",
25 | MergeIf: lint.MergeIfAny,
26 | },
27 | })
28 |
29 | var Analyzer = SCAnalyzer.Analyzer
30 |
31 | func run(pass *analysis.Pass) (interface{}, error) {
32 | fn := func(node ast.Node) {
33 | loop := node.(*ast.ForStmt)
34 | if loop.Init != nil || loop.Post != nil {
35 | return
36 | }
37 | if !code.IsBoolConst(pass, loop.Cond) || !code.BoolConst(pass, loop.Cond) {
38 | return
39 | }
40 | report.Report(pass, loop, "should use for {} instead of for true {}",
41 | report.ShortRange(),
42 | report.FilterGenerated())
43 | }
44 | code.Preorder(pass, fn, (*ast.ForStmt)(nil))
45 | return nil, nil
46 | }
47 |
--------------------------------------------------------------------------------
/vendor/honnef.co/go/tools/simple/s1010/s1010.go:
--------------------------------------------------------------------------------
1 | package s1010
2 |
3 | import (
4 | "go/ast"
5 |
6 | "honnef.co/go/tools/analysis/code"
7 | "honnef.co/go/tools/analysis/edit"
8 | "honnef.co/go/tools/analysis/facts/generated"
9 | "honnef.co/go/tools/analysis/lint"
10 | "honnef.co/go/tools/analysis/report"
11 | "honnef.co/go/tools/pattern"
12 |
13 | "golang.org/x/tools/go/analysis"
14 | "golang.org/x/tools/go/analysis/passes/inspect"
15 | )
16 |
17 | var SCAnalyzer = lint.InitializeAnalyzer(&lint.Analyzer{
18 | Analyzer: &analysis.Analyzer{
19 | Name: "S1010",
20 | Run: run,
21 | Requires: []*analysis.Analyzer{inspect.Analyzer, generated.Analyzer},
22 | },
23 | Doc: &lint.RawDocumentation{
24 | Title: `Omit default slice index`,
25 | Text: `When slicing, the second index defaults to the length of the value,
26 | making \'s[n:len(s)]\' and \'s[n:]\' equivalent.`,
27 | Since: "2017.1",
28 | MergeIf: lint.MergeIfAny,
29 | },
30 | })
31 |
32 | var Analyzer = SCAnalyzer.Analyzer
33 |
34 | var checkSlicingQ = pattern.MustParse(`(SliceExpr x@(Object _) low (CallExpr (Builtin "len") [x]) nil)`)
35 |
36 | func run(pass *analysis.Pass) (interface{}, error) {
37 | fn := func(node ast.Node) {
38 | if _, ok := code.Match(pass, checkSlicingQ, node); ok {
39 | expr := node.(*ast.SliceExpr)
40 | report.Report(pass, expr.High,
41 | "should omit second index in slice, s[a:len(s)] is identical to s[a:]",
42 | report.FilterGenerated(),
43 | report.Fixes(edit.Fix("simplify slice expression", edit.Delete(expr.High))))
44 | }
45 | }
46 | code.Preorder(pass, fn, (*ast.SliceExpr)(nil))
47 | return nil, nil
48 | }
49 |
--------------------------------------------------------------------------------
/vendor/honnef.co/go/tools/simple/s1012/s1012.go:
--------------------------------------------------------------------------------
1 | package s1012
2 |
3 | import (
4 | "go/ast"
5 |
6 | "honnef.co/go/tools/analysis/code"
7 | "honnef.co/go/tools/analysis/edit"
8 | "honnef.co/go/tools/analysis/facts/generated"
9 | "honnef.co/go/tools/analysis/lint"
10 | "honnef.co/go/tools/analysis/report"
11 | "honnef.co/go/tools/pattern"
12 |
13 | "golang.org/x/tools/go/analysis"
14 | "golang.org/x/tools/go/analysis/passes/inspect"
15 | )
16 |
17 | var SCAnalyzer = lint.InitializeAnalyzer(&lint.Analyzer{
18 | Analyzer: &analysis.Analyzer{
19 | Name: "S1012",
20 | Run: run,
21 | Requires: []*analysis.Analyzer{inspect.Analyzer, generated.Analyzer},
22 | },
23 | Doc: &lint.RawDocumentation{
24 | Title: `Replace \'time.Now().Sub(x)\' with \'time.Since(x)\'`,
25 | Text: `The \'time.Since\' helper has the same effect as using \'time.Now().Sub(x)\'
26 | but is easier to read.`,
27 | Before: `time.Now().Sub(x)`,
28 | After: `time.Since(x)`,
29 | Since: "2017.1",
30 | MergeIf: lint.MergeIfAny,
31 | },
32 | })
33 |
34 | var Analyzer = SCAnalyzer.Analyzer
35 |
36 | var (
37 | checkTimeSinceQ = pattern.MustParse(`(CallExpr (SelectorExpr (CallExpr (Symbol "time.Now") []) (Symbol "(time.Time).Sub")) [arg])`)
38 | checkTimeSinceR = pattern.MustParse(`(CallExpr (SelectorExpr (Ident "time") (Ident "Since")) [arg])`)
39 | )
40 |
41 | func run(pass *analysis.Pass) (interface{}, error) {
42 | fn := func(node ast.Node) {
43 | if _, edits, ok := code.MatchAndEdit(pass, checkTimeSinceQ, checkTimeSinceR, node); ok {
44 | report.Report(pass, node, "should use time.Since instead of time.Now().Sub",
45 | report.FilterGenerated(),
46 | report.Fixes(edit.Fix("replace with call to time.Since", edits...)))
47 | }
48 | }
49 | code.Preorder(pass, fn, (*ast.CallExpr)(nil))
50 | return nil, nil
51 | }
52 |
--------------------------------------------------------------------------------
/vendor/honnef.co/go/tools/simple/s1028/s1028.go:
--------------------------------------------------------------------------------
1 | package s1028
2 |
3 | import (
4 | "go/ast"
5 |
6 | "honnef.co/go/tools/analysis/code"
7 | "honnef.co/go/tools/analysis/edit"
8 | "honnef.co/go/tools/analysis/facts/generated"
9 | "honnef.co/go/tools/analysis/lint"
10 | "honnef.co/go/tools/analysis/report"
11 | "honnef.co/go/tools/pattern"
12 |
13 | "golang.org/x/tools/go/analysis"
14 | "golang.org/x/tools/go/analysis/passes/inspect"
15 | )
16 |
17 | var SCAnalyzer = lint.InitializeAnalyzer(&lint.Analyzer{
18 | Analyzer: &analysis.Analyzer{
19 | Name: "S1028",
20 | Run: run,
21 | Requires: []*analysis.Analyzer{inspect.Analyzer, generated.Analyzer},
22 | },
23 | Doc: &lint.RawDocumentation{
24 | Title: `Simplify error construction with \'fmt.Errorf\'`,
25 | Before: `errors.New(fmt.Sprintf(...))`,
26 | After: `fmt.Errorf(...)`,
27 | Since: "2017.1",
28 | MergeIf: lint.MergeIfAny,
29 | },
30 | })
31 |
32 | var Analyzer = SCAnalyzer.Analyzer
33 |
34 | var (
35 | checkErrorsNewSprintfQ = pattern.MustParse(`(CallExpr (Symbol "errors.New") [(CallExpr (Symbol "fmt.Sprintf") args)])`)
36 | checkErrorsNewSprintfR = pattern.MustParse(`(CallExpr (SelectorExpr (Ident "fmt") (Ident "Errorf")) args)`)
37 | )
38 |
39 | func run(pass *analysis.Pass) (interface{}, error) {
40 | fn := func(node ast.Node) {
41 | if _, edits, ok := code.MatchAndEdit(pass, checkErrorsNewSprintfQ, checkErrorsNewSprintfR, node); ok {
42 | // TODO(dh): the suggested fix may leave an unused import behind
43 | report.Report(pass, node, "should use fmt.Errorf(...) instead of errors.New(fmt.Sprintf(...))",
44 | report.FilterGenerated(),
45 | report.Fixes(edit.Fix("use fmt.Errorf", edits...)))
46 | }
47 | }
48 | code.Preorder(pass, fn, (*ast.CallExpr)(nil))
49 | return nil, nil
50 | }
51 |
--------------------------------------------------------------------------------
/vendor/honnef.co/go/tools/simple/s1029/s1029.go:
--------------------------------------------------------------------------------
1 | package s1029
2 |
3 | import (
4 | "honnef.co/go/tools/analysis/lint"
5 | "honnef.co/go/tools/internal/passes/buildir"
6 | "honnef.co/go/tools/internal/sharedcheck"
7 |
8 | "golang.org/x/tools/go/analysis"
9 | )
10 |
11 | var SCAnalyzer = lint.InitializeAnalyzer(&lint.Analyzer{
12 | Analyzer: &analysis.Analyzer{
13 | Name: "S1029",
14 | Run: sharedcheck.CheckRangeStringRunes,
15 | Requires: []*analysis.Analyzer{buildir.Analyzer},
16 | },
17 | Doc: &lint.RawDocumentation{
18 | Title: `Range over the string directly`,
19 | Text: `Ranging over a string will yield byte offsets and runes. If the offset
20 | isn't used, this is functionally equivalent to converting the string
21 | to a slice of runes and ranging over that. Ranging directly over the
22 | string will be more performant, however, as it avoids allocating a new
23 | slice, the size of which depends on the length of the string.`,
24 | Before: `for _, r := range []rune(s) {}`,
25 | After: `for _, r := range s {}`,
26 | Since: "2017.1",
27 | MergeIf: lint.MergeIfAny,
28 | },
29 | })
30 |
31 | var Analyzer = SCAnalyzer.Analyzer
32 |
--------------------------------------------------------------------------------
/vendor/honnef.co/go/tools/simple/s1033/s1033.go:
--------------------------------------------------------------------------------
1 | package s1033
2 |
3 | import (
4 | "go/ast"
5 |
6 | "honnef.co/go/tools/analysis/code"
7 | "honnef.co/go/tools/analysis/edit"
8 | "honnef.co/go/tools/analysis/facts/generated"
9 | "honnef.co/go/tools/analysis/lint"
10 | "honnef.co/go/tools/analysis/report"
11 | "honnef.co/go/tools/pattern"
12 |
13 | "golang.org/x/tools/go/analysis"
14 | "golang.org/x/tools/go/analysis/passes/inspect"
15 | )
16 |
17 | var SCAnalyzer = lint.InitializeAnalyzer(&lint.Analyzer{
18 | Analyzer: &analysis.Analyzer{
19 | Name: "S1033",
20 | Run: run,
21 | Requires: []*analysis.Analyzer{inspect.Analyzer, generated.Analyzer},
22 | },
23 | Doc: &lint.RawDocumentation{
24 | Title: `Unnecessary guard around call to \"delete\"`,
25 | Text: `Calling \'delete\' on a nil map is a no-op.`,
26 | Since: "2019.2",
27 | MergeIf: lint.MergeIfAny,
28 | },
29 | })
30 |
31 | var Analyzer = SCAnalyzer.Analyzer
32 |
33 | var checkGuardedDeleteQ = pattern.MustParse(`
34 | (IfStmt
35 | (AssignStmt
36 | [(Ident "_") ok@(Ident _)]
37 | ":="
38 | (IndexExpr m key))
39 | ok
40 | [call@(CallExpr (Builtin "delete") [m key])]
41 | nil)`)
42 |
43 | func run(pass *analysis.Pass) (interface{}, error) {
44 | fn := func(node ast.Node) {
45 | if m, ok := code.Match(pass, checkGuardedDeleteQ, node); ok {
46 | report.Report(pass, node, "unnecessary guard around call to delete",
47 | report.ShortRange(),
48 | report.FilterGenerated(),
49 | report.Fixes(edit.Fix("remove guard", edit.ReplaceWithNode(pass.Fset, node, m.State["call"].(ast.Node)))))
50 | }
51 | }
52 |
53 | code.Preorder(pass, fn, (*ast.IfStmt)(nil))
54 | return nil, nil
55 | }
56 |
--------------------------------------------------------------------------------
/vendor/honnef.co/go/tools/simple/s1035/s1035.go:
--------------------------------------------------------------------------------
1 | package s1035
2 |
3 | import (
4 | "fmt"
5 | "go/ast"
6 |
7 | "honnef.co/go/tools/analysis/code"
8 | "honnef.co/go/tools/analysis/edit"
9 | "honnef.co/go/tools/analysis/facts/generated"
10 | "honnef.co/go/tools/analysis/lint"
11 | "honnef.co/go/tools/analysis/report"
12 |
13 | "golang.org/x/tools/go/analysis"
14 | "golang.org/x/tools/go/analysis/passes/inspect"
15 | )
16 |
17 | var SCAnalyzer = lint.InitializeAnalyzer(&lint.Analyzer{
18 | Analyzer: &analysis.Analyzer{
19 | Name: "S1035",
20 | Run: run,
21 | Requires: []*analysis.Analyzer{inspect.Analyzer, generated.Analyzer},
22 | },
23 | Doc: &lint.RawDocumentation{
24 | Title: `Redundant call to \'net/http.CanonicalHeaderKey\' in method call on \'net/http.Header\'`,
25 | Text: `
26 | The methods on \'net/http.Header\', namely \'Add\', \'Del\', \'Get\'
27 | and \'Set\', already canonicalize the given header name.`,
28 | Since: "2020.1",
29 | MergeIf: lint.MergeIfAny,
30 | },
31 | })
32 |
33 | var Analyzer = SCAnalyzer.Analyzer
34 |
35 | func run(pass *analysis.Pass) (interface{}, error) {
36 | fn := func(node ast.Node) {
37 | call := node.(*ast.CallExpr)
38 | callName := code.CallName(pass, call)
39 | switch callName {
40 | case "(net/http.Header).Add", "(net/http.Header).Del", "(net/http.Header).Get", "(net/http.Header).Set":
41 | default:
42 | return
43 | }
44 |
45 | if !code.IsCallTo(pass, call.Args[0], "net/http.CanonicalHeaderKey") {
46 | return
47 | }
48 |
49 | report.Report(pass, call,
50 | fmt.Sprintf("calling net/http.CanonicalHeaderKey on the 'key' argument of %s is redundant", callName),
51 | report.FilterGenerated(),
52 | report.Fixes(edit.Fix("remove call to CanonicalHeaderKey", edit.ReplaceWithNode(pass.Fset, call.Args[0], call.Args[0].(*ast.CallExpr).Args[0]))))
53 | }
54 | code.Preorder(pass, fn, (*ast.CallExpr)(nil))
55 | return nil, nil
56 | }
57 |
--------------------------------------------------------------------------------
/vendor/honnef.co/go/tools/staticcheck/doc.go:
--------------------------------------------------------------------------------
1 | //go:generate go run ../generate.go
2 |
3 | // Package staticcheck contains analyzes that find bugs and performance issues.
4 | // Barring the rare false positive, any code flagged by these analyzes needs to be fixed.
5 | package staticcheck
6 |
--------------------------------------------------------------------------------
/vendor/honnef.co/go/tools/staticcheck/fakexml/xml.go:
--------------------------------------------------------------------------------
1 | // Copyright 2009 The Go Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | package fakexml
6 |
7 | // References:
8 | // Annotated XML spec: https://www.xml.com/axml/testaxml.htm
9 | // XML name spaces: https://www.w3.org/TR/REC-xml-names/
10 |
11 | // TODO(rsc):
12 | // Test error handling.
13 |
14 | // A Name represents an XML name (Local) annotated
15 | // with a name space identifier (Space).
16 | // In tokens returned by Decoder.Token, the Space identifier
17 | // is given as a canonical URL, not the short prefix used
18 | // in the document being parsed.
19 | type Name struct {
20 | Space, Local string
21 | }
22 |
23 | // An Attr represents an attribute in an XML element (Name=Value).
24 | type Attr struct {
25 | Name Name
26 | Value string
27 | }
28 |
29 | // A StartElement represents an XML start element.
30 | type StartElement struct {
31 | Name Name
32 | Attr []Attr
33 | }
34 |
--------------------------------------------------------------------------------
/vendor/honnef.co/go/tools/staticcheck/sa1000/sa1000.go:
--------------------------------------------------------------------------------
1 | package sa1000
2 |
3 | import (
4 | "go/constant"
5 | "regexp"
6 |
7 | "honnef.co/go/tools/analysis/callcheck"
8 | "honnef.co/go/tools/analysis/lint"
9 | "honnef.co/go/tools/internal/passes/buildir"
10 |
11 | "golang.org/x/tools/go/analysis"
12 | )
13 |
14 | var SCAnalyzer = lint.InitializeAnalyzer(&lint.Analyzer{
15 | Analyzer: &analysis.Analyzer{
16 | Name: "SA1000",
17 | Requires: []*analysis.Analyzer{buildir.Analyzer},
18 | Run: callcheck.Analyzer(rules),
19 | },
20 | Doc: &lint.RawDocumentation{
21 | Title: `Invalid regular expression`,
22 | Since: "2017.1",
23 | Severity: lint.SeverityError,
24 | MergeIf: lint.MergeIfAny,
25 | },
26 | })
27 |
28 | var Analyzer = SCAnalyzer.Analyzer
29 |
30 | var rules = map[string]callcheck.Check{
31 | "regexp.MustCompile": check,
32 | "regexp.Compile": check,
33 | "regexp.Match": check,
34 | "regexp.MatchReader": check,
35 | "regexp.MatchString": check,
36 | }
37 |
38 | func check(call *callcheck.Call) {
39 | arg := call.Args[0]
40 | if c := callcheck.ExtractConstExpectKind(arg.Value, constant.String); c != nil {
41 | s := constant.StringVal(c.Value)
42 | if _, err := regexp.Compile(s); err != nil {
43 | arg.Invalid(err.Error())
44 | }
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/vendor/honnef.co/go/tools/staticcheck/sa1002/sa1002.go:
--------------------------------------------------------------------------------
1 | package sa1002
2 |
3 | import (
4 | "go/constant"
5 | "strings"
6 | "time"
7 |
8 | "honnef.co/go/tools/analysis/callcheck"
9 | "honnef.co/go/tools/analysis/lint"
10 | "honnef.co/go/tools/internal/passes/buildir"
11 | "honnef.co/go/tools/knowledge"
12 |
13 | "golang.org/x/tools/go/analysis"
14 | )
15 |
16 | var SCAnalyzer = lint.InitializeAnalyzer(&lint.Analyzer{
17 | Analyzer: &analysis.Analyzer{
18 | Name: "SA1002",
19 | Requires: []*analysis.Analyzer{buildir.Analyzer},
20 | Run: callcheck.Analyzer(rules),
21 | },
22 | Doc: &lint.RawDocumentation{
23 | Title: `Invalid format in \'time.Parse\'`,
24 | Since: "2017.1",
25 | Severity: lint.SeverityError,
26 | MergeIf: lint.MergeIfAny,
27 | },
28 | })
29 |
30 | var Analyzer = SCAnalyzer.Analyzer
31 |
32 | var rules = map[string]callcheck.Check{
33 | "time.Parse": func(call *callcheck.Call) {
34 | arg := call.Args[knowledge.Arg("time.Parse.layout")]
35 | if c := callcheck.ExtractConstExpectKind(arg.Value, constant.String); c != nil {
36 | s := constant.StringVal(c.Value)
37 | s = strings.Replace(s, "_", " ", -1)
38 | s = strings.Replace(s, "Z", "-", -1)
39 | _, err := time.Parse(s, s)
40 | if err != nil {
41 | arg.Invalid(err.Error())
42 | }
43 | }
44 | },
45 | }
46 |
--------------------------------------------------------------------------------
/vendor/honnef.co/go/tools/staticcheck/sa1007/sa1007.go:
--------------------------------------------------------------------------------
1 | package sa1007
2 |
3 | import (
4 | "fmt"
5 | "go/constant"
6 | "net/url"
7 |
8 | "honnef.co/go/tools/analysis/callcheck"
9 | "honnef.co/go/tools/analysis/lint"
10 | "honnef.co/go/tools/internal/passes/buildir"
11 | "honnef.co/go/tools/knowledge"
12 |
13 | "golang.org/x/tools/go/analysis"
14 | )
15 |
16 | var SCAnalyzer = lint.InitializeAnalyzer(&lint.Analyzer{
17 | Analyzer: &analysis.Analyzer{
18 | Name: "SA1007",
19 | Requires: []*analysis.Analyzer{buildir.Analyzer},
20 | Run: callcheck.Analyzer(rules),
21 | },
22 | Doc: &lint.RawDocumentation{
23 | Title: `Invalid URL in \'net/url.Parse\'`,
24 | Since: "2017.1",
25 | Severity: lint.SeverityError,
26 | MergeIf: lint.MergeIfAny,
27 | },
28 | })
29 |
30 | var Analyzer = SCAnalyzer.Analyzer
31 |
32 | var rules = map[string]callcheck.Check{
33 | "net/url.Parse": func(call *callcheck.Call) {
34 | arg := call.Args[knowledge.Arg("net/url.Parse.rawurl")]
35 | if c := callcheck.ExtractConstExpectKind(arg.Value, constant.String); c != nil {
36 | s := constant.StringVal(c.Value)
37 | _, err := url.Parse(s)
38 | if err != nil {
39 | arg.Invalid(fmt.Sprintf("%q is not a valid URL: %s", s, err))
40 | }
41 | }
42 | },
43 | }
44 |
--------------------------------------------------------------------------------
/vendor/honnef.co/go/tools/staticcheck/sa1011/sa1011.go:
--------------------------------------------------------------------------------
1 | package sa1011
2 |
3 | import (
4 | "go/constant"
5 | "unicode/utf8"
6 |
7 | "honnef.co/go/tools/analysis/callcheck"
8 | "honnef.co/go/tools/analysis/lint"
9 | "honnef.co/go/tools/internal/passes/buildir"
10 |
11 | "golang.org/x/tools/go/analysis"
12 | )
13 |
14 | var SCAnalyzer = lint.InitializeAnalyzer(&lint.Analyzer{
15 | Analyzer: &analysis.Analyzer{
16 | Name: "SA1011",
17 | Requires: []*analysis.Analyzer{buildir.Analyzer},
18 | Run: callcheck.Analyzer(checkUTF8CutsetRules),
19 | },
20 | Doc: &lint.RawDocumentation{
21 | Title: `Various methods in the \"strings\" package expect valid UTF-8, but invalid input is provided`,
22 | Since: "2017.1",
23 | Severity: lint.SeverityError,
24 | MergeIf: lint.MergeIfAny,
25 | },
26 | })
27 |
28 | var Analyzer = SCAnalyzer.Analyzer
29 |
30 | var checkUTF8CutsetRules = map[string]callcheck.Check{
31 | "strings.IndexAny": check,
32 | "strings.LastIndexAny": check,
33 | "strings.ContainsAny": check,
34 | "strings.Trim": check,
35 | "strings.TrimLeft": check,
36 | "strings.TrimRight": check,
37 | }
38 |
39 | func check(call *callcheck.Call) {
40 | arg := call.Args[1]
41 | if c := callcheck.ExtractConstExpectKind(arg.Value, constant.String); c != nil {
42 | s := constant.StringVal(c.Value)
43 | if !utf8.ValidString(s) {
44 | arg.Invalid("argument is not a valid UTF-8 encoded string")
45 | }
46 | }
47 | }
48 |
--------------------------------------------------------------------------------
/vendor/honnef.co/go/tools/staticcheck/sa1013/sa1013.go:
--------------------------------------------------------------------------------
1 | package sa1013
2 |
3 | import (
4 | "go/ast"
5 |
6 | "honnef.co/go/tools/analysis/code"
7 | "honnef.co/go/tools/analysis/edit"
8 | "honnef.co/go/tools/analysis/lint"
9 | "honnef.co/go/tools/analysis/report"
10 | "honnef.co/go/tools/knowledge"
11 | "honnef.co/go/tools/pattern"
12 |
13 | "golang.org/x/tools/go/analysis"
14 | "golang.org/x/tools/go/analysis/passes/inspect"
15 | )
16 |
17 | var SCAnalyzer = lint.InitializeAnalyzer(&lint.Analyzer{
18 | Analyzer: &analysis.Analyzer{
19 | Name: "SA1013",
20 | Run: run,
21 | Requires: []*analysis.Analyzer{inspect.Analyzer},
22 | },
23 | Doc: &lint.RawDocumentation{
24 | Title: `\'io.Seeker.Seek\' is being called with the whence constant as the first argument, but it should be the second`,
25 | Since: "2017.1",
26 | Severity: lint.SeverityWarning,
27 | MergeIf: lint.MergeIfAny,
28 | },
29 | })
30 |
31 | var Analyzer = SCAnalyzer.Analyzer
32 |
33 | var (
34 | checkSeekerQ = pattern.MustParse(`(CallExpr fun@(SelectorExpr _ (Ident "Seek")) [arg1@(SelectorExpr _ (Symbol (Or "io.SeekStart" "io.SeekCurrent" "io.SeekEnd"))) arg2])`)
35 | checkSeekerR = pattern.MustParse(`(CallExpr fun [arg2 arg1])`)
36 | )
37 |
38 | func run(pass *analysis.Pass) (interface{}, error) {
39 | fn := func(node ast.Node) {
40 | if m, edits, ok := code.MatchAndEdit(pass, checkSeekerQ, checkSeekerR, node); ok {
41 | if !code.IsMethod(pass, m.State["fun"].(*ast.SelectorExpr), "Seek", knowledge.Signatures["(io.Seeker).Seek"]) {
42 | return
43 | }
44 | report.Report(pass, node, "the first argument of io.Seeker is the offset, but an io.Seek* constant is being used instead",
45 | report.Fixes(edit.Fix("swap arguments", edits...)))
46 | }
47 | }
48 | code.Preorder(pass, fn, (*ast.CallExpr)(nil))
49 | return nil, nil
50 | }
51 |
--------------------------------------------------------------------------------
/vendor/honnef.co/go/tools/staticcheck/sa1014/sa1014.go:
--------------------------------------------------------------------------------
1 | package sa1014
2 |
3 | import (
4 | "fmt"
5 | "go/types"
6 |
7 | "honnef.co/go/tools/analysis/callcheck"
8 | "honnef.co/go/tools/analysis/lint"
9 | "honnef.co/go/tools/internal/passes/buildir"
10 |
11 | "golang.org/x/tools/go/analysis"
12 | )
13 |
14 | var SCAnalyzer = lint.InitializeAnalyzer(&lint.Analyzer{
15 | Analyzer: &analysis.Analyzer{
16 | Name: "SA1014",
17 | Requires: []*analysis.Analyzer{buildir.Analyzer},
18 | Run: callcheck.Analyzer(checkUnmarshalPointerRules),
19 | },
20 | Doc: &lint.RawDocumentation{
21 | Title: `Non-pointer value passed to \'Unmarshal\' or \'Decode\'`,
22 | Since: "2017.1",
23 | Severity: lint.SeverityError,
24 | MergeIf: lint.MergeIfAny,
25 | },
26 | })
27 |
28 | var Analyzer = SCAnalyzer.Analyzer
29 |
30 | var checkUnmarshalPointerRules = map[string]callcheck.Check{
31 | "encoding/xml.Unmarshal": unmarshalPointer("xml.Unmarshal", 1),
32 | "(*encoding/xml.Decoder).Decode": unmarshalPointer("Decode", 0),
33 | "(*encoding/xml.Decoder).DecodeElement": unmarshalPointer("DecodeElement", 0),
34 | "encoding/json.Unmarshal": unmarshalPointer("json.Unmarshal", 1),
35 | "(*encoding/json.Decoder).Decode": unmarshalPointer("Decode", 0),
36 | }
37 |
38 | func unmarshalPointer(name string, arg int) callcheck.Check {
39 | return func(call *callcheck.Call) {
40 | if !Pointer(call.Args[arg].Value) {
41 | call.Args[arg].Invalid(fmt.Sprintf("%s expects to unmarshal into a pointer, but the provided value is not a pointer", name))
42 | }
43 | }
44 | }
45 |
46 | func Pointer(v callcheck.Value) bool {
47 | switch v.Value.Type().Underlying().(type) {
48 | case *types.Pointer, *types.Interface:
49 | return true
50 | }
51 | return false
52 | }
53 |
--------------------------------------------------------------------------------
/vendor/honnef.co/go/tools/staticcheck/sa1018/sa1018.go:
--------------------------------------------------------------------------------
1 | package sa1018
2 |
3 | import (
4 | "fmt"
5 | "go/constant"
6 |
7 | "honnef.co/go/tools/analysis/callcheck"
8 | "honnef.co/go/tools/analysis/lint"
9 | "honnef.co/go/tools/go/ir"
10 | "honnef.co/go/tools/internal/passes/buildir"
11 |
12 | "golang.org/x/tools/go/analysis"
13 | )
14 |
15 | var SCAnalyzer = lint.InitializeAnalyzer(&lint.Analyzer{
16 | Analyzer: &analysis.Analyzer{
17 | Name: "SA1018",
18 | Requires: []*analysis.Analyzer{buildir.Analyzer},
19 | Run: callcheck.Analyzer(rules),
20 | },
21 | Doc: &lint.RawDocumentation{
22 | Title: `\'strings.Replace\' called with \'n == 0\', which does nothing`,
23 | Text: `With \'n == 0\', zero instances will be replaced. To replace all
24 | instances, use a negative number, or use \'strings.ReplaceAll\'.`,
25 | Since: "2017.1",
26 | Severity: lint.SeverityWarning,
27 | MergeIf: lint.MergeIfAny, // MergeIfAny if we only flag literals, not named constants
28 | },
29 | })
30 |
31 | var Analyzer = SCAnalyzer.Analyzer
32 |
33 | var rules = map[string]callcheck.Check{
34 | "strings.Replace": check("strings.Replace", 3),
35 | "bytes.Replace": check("bytes.Replace", 3),
36 | }
37 |
38 | func check(name string, arg int) callcheck.Check {
39 | return func(call *callcheck.Call) {
40 | arg := call.Args[arg]
41 | if k, ok := arg.Value.Value.(*ir.Const); ok && k.Value.Kind() == constant.Int {
42 | if v, ok := constant.Int64Val(k.Value); ok && v == 0 {
43 | arg.Invalid(fmt.Sprintf("calling %s with n == 0 will return no results, did you mean -1?", name))
44 | }
45 | }
46 | }
47 | }
48 |
--------------------------------------------------------------------------------
/vendor/honnef.co/go/tools/staticcheck/sa1021/sa1021.go:
--------------------------------------------------------------------------------
1 | package sa1021
2 |
3 | import (
4 | "go/types"
5 |
6 | "honnef.co/go/tools/analysis/callcheck"
7 | "honnef.co/go/tools/analysis/lint"
8 | "honnef.co/go/tools/go/ir"
9 | "honnef.co/go/tools/internal/passes/buildir"
10 | "honnef.co/go/tools/knowledge"
11 |
12 | "golang.org/x/tools/go/analysis"
13 | )
14 |
15 | var SCAnalyzer = lint.InitializeAnalyzer(&lint.Analyzer{
16 | Analyzer: &analysis.Analyzer{
17 | Name: "SA1021",
18 | Requires: []*analysis.Analyzer{buildir.Analyzer},
19 | Run: callcheck.Analyzer(rules),
20 | },
21 | Doc: &lint.RawDocumentation{
22 | Title: `Using \'bytes.Equal\' to compare two \'net.IP\'`,
23 | Text: `A \'net.IP\' stores an IPv4 or IPv6 address as a slice of bytes. The
24 | length of the slice for an IPv4 address, however, can be either 4 or
25 | 16 bytes long, using different ways of representing IPv4 addresses. In
26 | order to correctly compare two \'net.IP\'s, the \'net.IP.Equal\' method should
27 | be used, as it takes both representations into account.`,
28 | Since: "2017.1",
29 | Severity: lint.SeverityWarning,
30 | MergeIf: lint.MergeIfAny,
31 | },
32 | })
33 |
34 | var Analyzer = SCAnalyzer.Analyzer
35 |
36 | var rules = map[string]callcheck.Check{
37 | "bytes.Equal": func(call *callcheck.Call) {
38 | if isConvertedFrom(call.Args[knowledge.Arg("bytes.Equal.a")].Value, "net.IP") &&
39 | isConvertedFrom(call.Args[knowledge.Arg("bytes.Equal.b")].Value, "net.IP") {
40 | call.Invalid("use net.IP.Equal to compare net.IPs, not bytes.Equal")
41 | }
42 | },
43 | }
44 |
45 | // ConvertedFrom reports whether value v was converted from type typ.
46 | func isConvertedFrom(v callcheck.Value, typ string) bool {
47 | change, ok := v.Value.(*ir.ChangeType)
48 | return ok && types.TypeString(types.Unalias(change.X.Type()), nil) == typ
49 | }
50 |
--------------------------------------------------------------------------------
/vendor/honnef.co/go/tools/staticcheck/sa1028/sa1028.go:
--------------------------------------------------------------------------------
1 | package sa1028
2 |
3 | import (
4 | "fmt"
5 | "go/types"
6 |
7 | "honnef.co/go/tools/analysis/callcheck"
8 | "honnef.co/go/tools/analysis/lint"
9 | "honnef.co/go/tools/go/ir"
10 | "honnef.co/go/tools/internal/passes/buildir"
11 |
12 | "golang.org/x/tools/go/analysis"
13 | )
14 |
15 | var SCAnalyzer = lint.InitializeAnalyzer(&lint.Analyzer{
16 | Analyzer: &analysis.Analyzer{
17 | Name: "SA1028",
18 | Requires: []*analysis.Analyzer{buildir.Analyzer},
19 | Run: callcheck.Analyzer(rules),
20 | },
21 | Doc: &lint.RawDocumentation{
22 | Title: `\'sort.Slice\' can only be used on slices`,
23 | Text: `The first argument of \'sort.Slice\' must be a slice.`,
24 | Since: "2020.1",
25 | Severity: lint.SeverityError,
26 | MergeIf: lint.MergeIfAny,
27 | },
28 | })
29 |
30 | var Analyzer = SCAnalyzer.Analyzer
31 |
32 | var rules = map[string]callcheck.Check{
33 | "sort.Slice": check,
34 | "sort.SliceIsSorted": check,
35 | "sort.SliceStable": check,
36 | }
37 |
38 | func check(call *callcheck.Call) {
39 | c := call.Instr.Common().StaticCallee()
40 | arg := call.Args[0]
41 |
42 | T := arg.Value.Value.Type().Underlying()
43 | switch T.(type) {
44 | case *types.Interface:
45 | // we don't know.
46 | // TODO(dh): if the value is a phi node we can look at its edges
47 | if k, ok := arg.Value.Value.(*ir.Const); ok && k.Value == nil {
48 | // literal nil, e.g. sort.Sort(nil, ...)
49 | arg.Invalid(fmt.Sprintf("cannot call %s on nil literal", c))
50 | }
51 | case *types.Slice:
52 | // this is fine
53 | default:
54 | // this is not fine
55 | arg.Invalid(fmt.Sprintf("%s must only be called on slices, was called on %s", c, T))
56 | }
57 | }
58 |
--------------------------------------------------------------------------------
/vendor/honnef.co/go/tools/staticcheck/sa2000/sa2000.go:
--------------------------------------------------------------------------------
1 | package sa2000
2 |
3 | import (
4 | "fmt"
5 | "go/ast"
6 |
7 | "honnef.co/go/tools/analysis/code"
8 | "honnef.co/go/tools/analysis/lint"
9 | "honnef.co/go/tools/analysis/report"
10 | "honnef.co/go/tools/pattern"
11 |
12 | "golang.org/x/tools/go/analysis"
13 | "golang.org/x/tools/go/analysis/passes/inspect"
14 | )
15 |
16 | var SCAnalyzer = lint.InitializeAnalyzer(&lint.Analyzer{
17 | Analyzer: &analysis.Analyzer{
18 | Name: "SA2000",
19 | Run: run,
20 | Requires: []*analysis.Analyzer{inspect.Analyzer},
21 | },
22 | Doc: &lint.RawDocumentation{
23 | Title: `\'sync.WaitGroup.Add\' called inside the goroutine, leading to a race condition`,
24 | Since: "2017.1",
25 | Severity: lint.SeverityWarning,
26 | MergeIf: lint.MergeIfAny,
27 | },
28 | })
29 |
30 | var Analyzer = SCAnalyzer.Analyzer
31 |
32 | var checkWaitgroupAddQ = pattern.MustParse(`
33 | (GoStmt
34 | (CallExpr
35 | (FuncLit
36 | _
37 | call@(CallExpr (Symbol "(*sync.WaitGroup).Add") _):_) _))`)
38 |
39 | func run(pass *analysis.Pass) (interface{}, error) {
40 | fn := func(node ast.Node) {
41 | if m, ok := code.Match(pass, checkWaitgroupAddQ, node); ok {
42 | call := m.State["call"].(ast.Node)
43 | report.Report(pass, call, fmt.Sprintf("should call %s before starting the goroutine to avoid a race", report.Render(pass, call)))
44 | }
45 | }
46 | code.Preorder(pass, fn, (*ast.GoStmt)(nil))
47 | return nil, nil
48 | }
49 |
--------------------------------------------------------------------------------
/vendor/honnef.co/go/tools/staticcheck/sa3001/sa3001.go:
--------------------------------------------------------------------------------
1 | package sa3001
2 |
3 | import (
4 | "fmt"
5 | "go/ast"
6 |
7 | "honnef.co/go/tools/analysis/code"
8 | "honnef.co/go/tools/analysis/lint"
9 | "honnef.co/go/tools/analysis/report"
10 |
11 | "golang.org/x/tools/go/analysis"
12 | "golang.org/x/tools/go/analysis/passes/inspect"
13 | )
14 |
15 | var SCAnalyzer = lint.InitializeAnalyzer(&lint.Analyzer{
16 | Analyzer: &analysis.Analyzer{
17 | Name: "SA3001",
18 | Run: run,
19 | Requires: []*analysis.Analyzer{inspect.Analyzer},
20 | },
21 | Doc: &lint.RawDocumentation{
22 | Title: `Assigning to \'b.N\' in benchmarks distorts the results`,
23 | Text: `The testing package dynamically sets \'b.N\' to improve the reliability of
24 | benchmarks and uses it in computations to determine the duration of a
25 | single operation. Benchmark code must not alter \'b.N\' as this would
26 | falsify results.`,
27 | Since: "2017.1",
28 | Severity: lint.SeverityError,
29 | MergeIf: lint.MergeIfAny,
30 | },
31 | })
32 |
33 | var Analyzer = SCAnalyzer.Analyzer
34 |
35 | func run(pass *analysis.Pass) (interface{}, error) {
36 | fn := func(node ast.Node) {
37 | assign := node.(*ast.AssignStmt)
38 | if len(assign.Lhs) != 1 || len(assign.Rhs) != 1 {
39 | return
40 | }
41 | sel, ok := assign.Lhs[0].(*ast.SelectorExpr)
42 | if !ok {
43 | return
44 | }
45 | if sel.Sel.Name != "N" {
46 | return
47 | }
48 | if !code.IsOfPointerToTypeWithName(pass, sel.X, "testing.B") {
49 | return
50 | }
51 | report.Report(pass, assign, fmt.Sprintf("should not assign to %s", report.Render(pass, sel)))
52 | }
53 | code.Preorder(pass, fn, (*ast.AssignStmt)(nil))
54 | return nil, nil
55 | }
56 |
--------------------------------------------------------------------------------
/vendor/honnef.co/go/tools/staticcheck/sa4001/sa4001.go:
--------------------------------------------------------------------------------
1 | package sa4001
2 |
3 | import (
4 | "go/ast"
5 | "regexp"
6 |
7 | "honnef.co/go/tools/analysis/code"
8 | "honnef.co/go/tools/analysis/lint"
9 | "honnef.co/go/tools/analysis/report"
10 | "honnef.co/go/tools/pattern"
11 |
12 | "golang.org/x/tools/go/analysis"
13 | "golang.org/x/tools/go/analysis/passes/inspect"
14 | )
15 |
16 | var SCAnalyzer = lint.InitializeAnalyzer(&lint.Analyzer{
17 | Analyzer: &analysis.Analyzer{
18 | Name: "SA4001",
19 | Run: run,
20 | Requires: []*analysis.Analyzer{inspect.Analyzer},
21 | },
22 | Doc: &lint.RawDocumentation{
23 | Title: `\'&*x\' gets simplified to \'x\', it does not copy \'x\'`,
24 | Since: "2017.1",
25 | Severity: lint.SeverityWarning,
26 | MergeIf: lint.MergeIfAny,
27 | },
28 | })
29 |
30 | var Analyzer = SCAnalyzer.Analyzer
31 |
32 | var (
33 | // cgo produces code like fn(&*_Cvar_kSomeCallbacks) which we don't
34 | // want to flag.
35 | cgoIdent = regexp.MustCompile(`^_C(func|var)_.+$`)
36 | checkIneffectiveCopyQ1 = pattern.MustParse(`(UnaryExpr "&" (StarExpr obj))`)
37 | checkIneffectiveCopyQ2 = pattern.MustParse(`(StarExpr (UnaryExpr "&" _))`)
38 | )
39 |
40 | func run(pass *analysis.Pass) (interface{}, error) {
41 | fn := func(node ast.Node) {
42 | if m, ok := code.Match(pass, checkIneffectiveCopyQ1, node); ok {
43 | if ident, ok := m.State["obj"].(*ast.Ident); !ok || !cgoIdent.MatchString(ident.Name) {
44 | report.Report(pass, node, "&*x will be simplified to x. It will not copy x.")
45 | }
46 | } else if _, ok := code.Match(pass, checkIneffectiveCopyQ2, node); ok {
47 | report.Report(pass, node, "*&x will be simplified to x. It will not copy x.")
48 | }
49 | }
50 | code.Preorder(pass, fn, (*ast.UnaryExpr)(nil), (*ast.StarExpr)(nil))
51 | return nil, nil
52 | }
53 |
--------------------------------------------------------------------------------
/vendor/honnef.co/go/tools/staticcheck/sa4012/sa4012.go:
--------------------------------------------------------------------------------
1 | package sa4012
2 |
3 | import (
4 | "honnef.co/go/tools/analysis/lint"
5 | "honnef.co/go/tools/analysis/report"
6 | "honnef.co/go/tools/go/ir"
7 | "honnef.co/go/tools/go/ir/irutil"
8 | "honnef.co/go/tools/internal/passes/buildir"
9 |
10 | "golang.org/x/tools/go/analysis"
11 | )
12 |
13 | var SCAnalyzer = lint.InitializeAnalyzer(&lint.Analyzer{
14 | Analyzer: &analysis.Analyzer{
15 | Name: "SA4012",
16 | Run: run,
17 | Requires: []*analysis.Analyzer{buildir.Analyzer},
18 | },
19 | Doc: &lint.RawDocumentation{
20 | Title: `Comparing a value against NaN even though no value is equal to NaN`,
21 | Since: "2017.1",
22 | Severity: lint.SeverityWarning,
23 | MergeIf: lint.MergeIfAny,
24 | },
25 | })
26 |
27 | var Analyzer = SCAnalyzer.Analyzer
28 |
29 | func run(pass *analysis.Pass) (interface{}, error) {
30 | isNaN := func(v ir.Value) bool {
31 | call, ok := v.(*ir.Call)
32 | if !ok {
33 | return false
34 | }
35 | return irutil.IsCallTo(call.Common(), "math.NaN")
36 | }
37 | for _, fn := range pass.ResultOf[buildir.Analyzer].(*buildir.IR).SrcFuncs {
38 | for _, block := range fn.Blocks {
39 | for _, ins := range block.Instrs {
40 | ins, ok := ins.(*ir.BinOp)
41 | if !ok {
42 | continue
43 | }
44 | if isNaN(irutil.Flatten(ins.X)) || isNaN(irutil.Flatten(ins.Y)) {
45 | report.Report(pass, ins, "no value is equal to NaN, not even NaN itself")
46 | }
47 | }
48 | }
49 | }
50 | return nil, nil
51 | }
52 |
--------------------------------------------------------------------------------
/vendor/honnef.co/go/tools/staticcheck/sa4013/sa4013.go:
--------------------------------------------------------------------------------
1 | package sa4013
2 |
3 | import (
4 | "go/ast"
5 |
6 | "honnef.co/go/tools/analysis/code"
7 | "honnef.co/go/tools/analysis/edit"
8 | "honnef.co/go/tools/analysis/lint"
9 | "honnef.co/go/tools/analysis/report"
10 | "honnef.co/go/tools/pattern"
11 |
12 | "golang.org/x/tools/go/analysis"
13 | "golang.org/x/tools/go/analysis/passes/inspect"
14 | )
15 |
16 | var SCAnalyzer = lint.InitializeAnalyzer(&lint.Analyzer{
17 | Analyzer: &analysis.Analyzer{
18 | Name: "SA4013",
19 | Run: run,
20 | Requires: []*analysis.Analyzer{inspect.Analyzer},
21 | },
22 | Doc: &lint.RawDocumentation{
23 | Title: `Negating a boolean twice (\'!!b\') is the same as writing \'b\'. This is either redundant, or a typo.`,
24 | Since: "2017.1",
25 | Severity: lint.SeverityWarning,
26 | MergeIf: lint.MergeIfAny,
27 | },
28 | })
29 |
30 | var Analyzer = SCAnalyzer.Analyzer
31 |
32 | var checkDoubleNegationQ = pattern.MustParse(`(UnaryExpr "!" single@(UnaryExpr "!" x))`)
33 |
34 | func run(pass *analysis.Pass) (interface{}, error) {
35 | fn := func(node ast.Node) {
36 | if m, ok := code.Match(pass, checkDoubleNegationQ, node); ok {
37 | report.Report(pass, node, "negating a boolean twice has no effect; is this a typo?", report.Fixes(
38 | edit.Fix("turn into single negation", edit.ReplaceWithNode(pass.Fset, node, m.State["single"].(ast.Node))),
39 | edit.Fix("remove double negation", edit.ReplaceWithNode(pass.Fset, node, m.State["x"].(ast.Node)))))
40 | }
41 | }
42 | code.Preorder(pass, fn, (*ast.UnaryExpr)(nil))
43 | return nil, nil
44 | }
45 |
--------------------------------------------------------------------------------
/vendor/honnef.co/go/tools/staticcheck/sa4015/sa4015.go:
--------------------------------------------------------------------------------
1 | package sa4015
2 |
3 | import (
4 | "fmt"
5 | "go/types"
6 |
7 | "honnef.co/go/tools/analysis/callcheck"
8 | "honnef.co/go/tools/analysis/lint"
9 | "honnef.co/go/tools/go/ir"
10 | "honnef.co/go/tools/go/ir/irutil"
11 | "honnef.co/go/tools/go/types/typeutil"
12 | "honnef.co/go/tools/internal/passes/buildir"
13 |
14 | "golang.org/x/tools/go/analysis"
15 | )
16 |
17 | var SCAnalyzer = lint.InitializeAnalyzer(&lint.Analyzer{
18 | Analyzer: &analysis.Analyzer{
19 | Name: "SA4015",
20 | Requires: []*analysis.Analyzer{buildir.Analyzer},
21 | Run: callcheck.Analyzer(checkMathIntRules),
22 | },
23 | Doc: &lint.RawDocumentation{
24 | Title: `Calling functions like \'math.Ceil\' on floats converted from integers doesn't do anything useful`,
25 | Since: "2017.1",
26 | Severity: lint.SeverityWarning,
27 | MergeIf: lint.MergeIfAll,
28 | },
29 | })
30 |
31 | var Analyzer = SCAnalyzer.Analyzer
32 |
33 | var checkMathIntRules = map[string]callcheck.Check{
34 | "math.Ceil": pointlessIntMath,
35 | "math.Floor": pointlessIntMath,
36 | "math.IsNaN": pointlessIntMath,
37 | "math.Trunc": pointlessIntMath,
38 | "math.IsInf": pointlessIntMath,
39 | }
40 |
41 | func pointlessIntMath(call *callcheck.Call) {
42 | if ConvertedFromInt(call.Args[0].Value) {
43 | call.Invalid(fmt.Sprintf("calling %s on a converted integer is pointless", irutil.CallName(call.Instr.Common())))
44 | }
45 | }
46 |
47 | func ConvertedFromInt(v callcheck.Value) bool {
48 | conv, ok := v.Value.(*ir.Convert)
49 | if !ok {
50 | return false
51 | }
52 | return typeutil.NewTypeSet(conv.X.Type()).All(func(t *types.Term) bool {
53 | b, ok := t.Type().Underlying().(*types.Basic)
54 | return ok && b.Info()&types.IsInteger != 0
55 | })
56 | }
57 |
--------------------------------------------------------------------------------
/vendor/honnef.co/go/tools/staticcheck/sa4018/sa4018.go:
--------------------------------------------------------------------------------
1 | package sa4018
2 |
3 | import (
4 | "fmt"
5 | "go/ast"
6 | "go/token"
7 | "reflect"
8 |
9 | "honnef.co/go/tools/analysis/code"
10 | "honnef.co/go/tools/analysis/facts/generated"
11 | "honnef.co/go/tools/analysis/facts/purity"
12 | "honnef.co/go/tools/analysis/lint"
13 | "honnef.co/go/tools/analysis/report"
14 |
15 | "golang.org/x/tools/go/analysis"
16 | "golang.org/x/tools/go/analysis/passes/inspect"
17 | )
18 |
19 | var SCAnalyzer = lint.InitializeAnalyzer(&lint.Analyzer{
20 | Analyzer: &analysis.Analyzer{
21 | Name: "SA4018",
22 | Run: run,
23 | Requires: []*analysis.Analyzer{inspect.Analyzer, generated.Analyzer, purity.Analyzer},
24 | },
25 | Doc: &lint.RawDocumentation{
26 | Title: `Self-assignment of variables`,
27 | Since: "2017.1",
28 | Severity: lint.SeverityWarning,
29 | MergeIf: lint.MergeIfAny,
30 | },
31 | })
32 |
33 | var Analyzer = SCAnalyzer.Analyzer
34 |
35 | func run(pass *analysis.Pass) (interface{}, error) {
36 | pure := pass.ResultOf[purity.Analyzer].(purity.Result)
37 |
38 | fn := func(node ast.Node) {
39 | assign := node.(*ast.AssignStmt)
40 | if assign.Tok != token.ASSIGN || len(assign.Lhs) != len(assign.Rhs) {
41 | return
42 | }
43 | for i, lhs := range assign.Lhs {
44 | rhs := assign.Rhs[i]
45 | if reflect.TypeOf(lhs) != reflect.TypeOf(rhs) {
46 | continue
47 | }
48 | if code.MayHaveSideEffects(pass, lhs, pure) || code.MayHaveSideEffects(pass, rhs, pure) {
49 | continue
50 | }
51 |
52 | rlh := report.Render(pass, lhs)
53 | rrh := report.Render(pass, rhs)
54 | if rlh == rrh {
55 | report.Report(pass, assign, fmt.Sprintf("self-assignment of %s to %s", rrh, rlh), report.FilterGenerated())
56 | }
57 | }
58 | }
59 | code.Preorder(pass, fn, (*ast.AssignStmt)(nil))
60 | return nil, nil
61 | }
62 |
--------------------------------------------------------------------------------
/vendor/honnef.co/go/tools/staticcheck/sa4021/sa4021.go:
--------------------------------------------------------------------------------
1 | package sa4021
2 |
3 | import (
4 | "go/ast"
5 |
6 | "honnef.co/go/tools/analysis/code"
7 | "honnef.co/go/tools/analysis/facts/generated"
8 | "honnef.co/go/tools/analysis/lint"
9 | "honnef.co/go/tools/analysis/report"
10 | "honnef.co/go/tools/pattern"
11 |
12 | "golang.org/x/tools/go/analysis"
13 | "golang.org/x/tools/go/analysis/passes/inspect"
14 | )
15 |
16 | var SCAnalyzer = lint.InitializeAnalyzer(&lint.Analyzer{
17 | Analyzer: &analysis.Analyzer{
18 | Name: "SA4021",
19 | Run: run,
20 | Requires: []*analysis.Analyzer{inspect.Analyzer, generated.Analyzer},
21 | },
22 | Doc: &lint.RawDocumentation{
23 | Title: `\"x = append(y)\" is equivalent to \"x = y\"`,
24 | Since: "2019.2",
25 | Severity: lint.SeverityWarning,
26 | MergeIf: lint.MergeIfAny,
27 | },
28 | })
29 |
30 | var Analyzer = SCAnalyzer.Analyzer
31 |
32 | var checkSingleArgAppendQ = pattern.MustParse(`(CallExpr (Builtin "append") [_])`)
33 |
34 | func run(pass *analysis.Pass) (interface{}, error) {
35 | fn := func(node ast.Node) {
36 | _, ok := code.Match(pass, checkSingleArgAppendQ, node)
37 | if !ok {
38 | return
39 | }
40 | report.Report(pass, node, "x = append(y) is equivalent to x = y", report.FilterGenerated())
41 | }
42 | code.Preorder(pass, fn, (*ast.CallExpr)(nil))
43 | return nil, nil
44 | }
45 |
--------------------------------------------------------------------------------
/vendor/honnef.co/go/tools/staticcheck/sa4022/sa4022.go:
--------------------------------------------------------------------------------
1 | package sa4022
2 |
3 | import (
4 | "go/ast"
5 |
6 | "honnef.co/go/tools/analysis/code"
7 | "honnef.co/go/tools/analysis/lint"
8 | "honnef.co/go/tools/analysis/report"
9 | "honnef.co/go/tools/pattern"
10 |
11 | "golang.org/x/tools/go/analysis"
12 | "golang.org/x/tools/go/analysis/passes/inspect"
13 | )
14 |
15 | var SCAnalyzer = lint.InitializeAnalyzer(&lint.Analyzer{
16 | Analyzer: &analysis.Analyzer{
17 | Name: "SA4022",
18 | Run: run,
19 | Requires: []*analysis.Analyzer{inspect.Analyzer},
20 | },
21 | Doc: &lint.RawDocumentation{
22 | Title: `Comparing the address of a variable against nil`,
23 | Text: `Code such as \"if &x == nil\" is meaningless, because taking the address of a variable always yields a non-nil pointer.`,
24 | Since: "2020.1",
25 | Severity: lint.SeverityWarning,
26 | MergeIf: lint.MergeIfAny,
27 | },
28 | })
29 |
30 | var Analyzer = SCAnalyzer.Analyzer
31 |
32 | var CheckAddressIsNilQ = pattern.MustParse(
33 | `(BinaryExpr
34 | (UnaryExpr "&" _)
35 | (Or "==" "!=")
36 | (Builtin "nil"))`)
37 |
38 | func run(pass *analysis.Pass) (interface{}, error) {
39 | fn := func(node ast.Node) {
40 | _, ok := code.Match(pass, CheckAddressIsNilQ, node)
41 | if !ok {
42 | return
43 | }
44 | report.Report(pass, node, "the address of a variable cannot be nil")
45 | }
46 | code.Preorder(pass, fn, (*ast.BinaryExpr)(nil))
47 | return nil, nil
48 | }
49 |
--------------------------------------------------------------------------------
/vendor/honnef.co/go/tools/staticcheck/sa4024/sa4024.go:
--------------------------------------------------------------------------------
1 | package sa4024
2 |
3 | import (
4 | "fmt"
5 | "go/ast"
6 |
7 | "honnef.co/go/tools/analysis/code"
8 | "honnef.co/go/tools/analysis/lint"
9 | "honnef.co/go/tools/analysis/report"
10 | "honnef.co/go/tools/pattern"
11 |
12 | "golang.org/x/tools/go/analysis"
13 | "golang.org/x/tools/go/analysis/passes/inspect"
14 | )
15 |
16 | var SCAnalyzer = lint.InitializeAnalyzer(&lint.Analyzer{
17 | Analyzer: &analysis.Analyzer{
18 | Name: "SA4024",
19 | Run: run,
20 | Requires: []*analysis.Analyzer{inspect.Analyzer},
21 | },
22 | Doc: &lint.RawDocumentation{
23 | Title: `Checking for impossible return value from a builtin function`,
24 | Text: `Return values of the \'len\' and \'cap\' builtins cannot be negative.
25 |
26 | See https://golang.org/pkg/builtin/#len and https://golang.org/pkg/builtin/#cap.
27 |
28 | Example:
29 |
30 | if len(slice) < 0 {
31 | fmt.Println("unreachable code")
32 | }`,
33 | Since: "2021.1",
34 | Severity: lint.SeverityWarning,
35 | MergeIf: lint.MergeIfAny,
36 | },
37 | })
38 |
39 | var Analyzer = SCAnalyzer.Analyzer
40 |
41 | var builtinLessThanZeroQ = pattern.MustParse(`
42 | (Or
43 | (BinaryExpr
44 | (IntegerLiteral "0")
45 | ">"
46 | (CallExpr builtin@(Builtin (Or "len" "cap")) _))
47 | (BinaryExpr
48 | (CallExpr builtin@(Builtin (Or "len" "cap")) _)
49 | "<"
50 | (IntegerLiteral "0")))
51 | `)
52 |
53 | func run(pass *analysis.Pass) (interface{}, error) {
54 | fn := func(node ast.Node) {
55 | matcher, ok := code.Match(pass, builtinLessThanZeroQ, node)
56 | if !ok {
57 | return
58 | }
59 |
60 | builtin := matcher.State["builtin"].(*ast.Ident)
61 | report.Report(pass, node, fmt.Sprintf("builtin function %s does not return negative values", builtin.Name))
62 | }
63 | code.Preorder(pass, fn, (*ast.BinaryExpr)(nil))
64 |
65 | return nil, nil
66 | }
67 |
--------------------------------------------------------------------------------
/vendor/honnef.co/go/tools/staticcheck/sa4028/sa4028.go:
--------------------------------------------------------------------------------
1 | package sa4028
2 |
3 | import (
4 | "go/ast"
5 |
6 | "honnef.co/go/tools/analysis/code"
7 | "honnef.co/go/tools/analysis/lint"
8 | "honnef.co/go/tools/analysis/report"
9 | "honnef.co/go/tools/pattern"
10 |
11 | "golang.org/x/tools/go/analysis"
12 | "golang.org/x/tools/go/analysis/passes/inspect"
13 | )
14 |
15 | var SCAnalyzer = lint.InitializeAnalyzer(&lint.Analyzer{
16 | Analyzer: &analysis.Analyzer{
17 | Name: "SA4028",
18 | Run: run,
19 | Requires: []*analysis.Analyzer{inspect.Analyzer},
20 | },
21 | Doc: &lint.RawDocumentation{
22 | Title: `\'x % 1\' is always zero`,
23 | Since: "2022.1",
24 | Severity: lint.SeverityWarning,
25 | MergeIf: lint.MergeIfAny, // MergeIfAny if we only flag literals, not named constants
26 | },
27 | })
28 |
29 | var Analyzer = SCAnalyzer.Analyzer
30 |
31 | var moduloOneQ = pattern.MustParse(`(BinaryExpr _ "%" (IntegerLiteral "1"))`)
32 |
33 | func run(pass *analysis.Pass) (interface{}, error) {
34 | fn := func(node ast.Node) {
35 | _, ok := code.Match(pass, moduloOneQ, node)
36 | if !ok {
37 | return
38 | }
39 | report.Report(pass, node, "x % 1 is always zero")
40 | }
41 | code.Preorder(pass, fn, (*ast.BinaryExpr)(nil))
42 | return nil, nil
43 | }
44 |
--------------------------------------------------------------------------------
/vendor/honnef.co/go/tools/staticcheck/sa4030/sa4030.go:
--------------------------------------------------------------------------------
1 | package sa4030
2 |
3 | import (
4 | "fmt"
5 | "go/ast"
6 |
7 | "honnef.co/go/tools/analysis/code"
8 | "honnef.co/go/tools/analysis/lint"
9 | "honnef.co/go/tools/analysis/report"
10 | "honnef.co/go/tools/pattern"
11 |
12 | "golang.org/x/tools/go/analysis"
13 | "golang.org/x/tools/go/analysis/passes/inspect"
14 | )
15 |
16 | var SCAnalyzer = lint.InitializeAnalyzer(&lint.Analyzer{
17 | Analyzer: &analysis.Analyzer{
18 | Name: "SA4030",
19 | Run: run,
20 | Requires: []*analysis.Analyzer{inspect.Analyzer},
21 | },
22 | Doc: &lint.RawDocumentation{
23 | Title: "Ineffective attempt at generating random number",
24 | Text: `
25 | Functions in the \'math/rand\' package that accept upper limits, such
26 | as \'Intn\', generate random numbers in the half-open interval [0,n). In
27 | other words, the generated numbers will be \'>= 0\' and \'< n\' – they
28 | don't include \'n\'. \'rand.Intn(1)\' therefore doesn't generate \'0\'
29 | or \'1\', it always generates \'0\'.`,
30 | Since: "2022.1",
31 | Severity: lint.SeverityWarning,
32 | MergeIf: lint.MergeIfAny,
33 | },
34 | })
35 |
36 | var Analyzer = SCAnalyzer.Analyzer
37 |
38 | var ineffectiveRandIntQ = pattern.MustParse(`
39 | (CallExpr
40 | (Symbol
41 | name@(Or
42 | "math/rand.Int31n"
43 | "math/rand.Int63n"
44 | "math/rand.Intn"
45 | "(*math/rand.Rand).Int31n"
46 | "(*math/rand.Rand).Int63n"
47 | "(*math/rand.Rand).Intn"))
48 | [(IntegerLiteral "1")])`)
49 |
50 | func run(pass *analysis.Pass) (interface{}, error) {
51 | fn := func(node ast.Node) {
52 | m, ok := code.Match(pass, ineffectiveRandIntQ, node)
53 | if !ok {
54 | return
55 | }
56 |
57 | report.Report(pass, node,
58 | fmt.Sprintf("%s(n) generates a random value 0 <= x < n; that is, the generated values don't include n; %s therefore always returns 0",
59 | m.State["name"], report.Render(pass, node)))
60 | }
61 |
62 | code.Preorder(pass, fn, (*ast.CallExpr)(nil))
63 | return nil, nil
64 | }
65 |
--------------------------------------------------------------------------------
/vendor/honnef.co/go/tools/staticcheck/sa5000/sa5000.go:
--------------------------------------------------------------------------------
1 | package sa5000
2 |
3 | import (
4 | "honnef.co/go/tools/analysis/lint"
5 | "honnef.co/go/tools/analysis/report"
6 | "honnef.co/go/tools/go/ir"
7 | "honnef.co/go/tools/go/ir/irutil"
8 | "honnef.co/go/tools/internal/passes/buildir"
9 |
10 | "golang.org/x/tools/go/analysis"
11 | )
12 |
13 | var SCAnalyzer = lint.InitializeAnalyzer(&lint.Analyzer{
14 | Analyzer: &analysis.Analyzer{
15 | Name: "SA5000",
16 | Run: run,
17 | Requires: []*analysis.Analyzer{buildir.Analyzer},
18 | },
19 | Doc: &lint.RawDocumentation{
20 | Title: `Assignment to nil map`,
21 | Since: "2017.1",
22 | Severity: lint.SeverityError,
23 | MergeIf: lint.MergeIfAny,
24 | },
25 | })
26 |
27 | var Analyzer = SCAnalyzer.Analyzer
28 |
29 | func run(pass *analysis.Pass) (interface{}, error) {
30 | for _, fn := range pass.ResultOf[buildir.Analyzer].(*buildir.IR).SrcFuncs {
31 | for _, block := range fn.Blocks {
32 | for _, ins := range block.Instrs {
33 | mu, ok := ins.(*ir.MapUpdate)
34 | if !ok {
35 | continue
36 | }
37 | c, ok := irutil.Flatten(mu.Map).(*ir.Const)
38 | if !ok {
39 | continue
40 | }
41 | if c.Value != nil {
42 | continue
43 | }
44 | report.Report(pass, mu, "assignment to nil map")
45 | }
46 | }
47 | }
48 | return nil, nil
49 | }
50 |
--------------------------------------------------------------------------------
/vendor/honnef.co/go/tools/staticcheck/sa5004/sa5004.go:
--------------------------------------------------------------------------------
1 | package sa5004
2 |
3 | import (
4 | "go/ast"
5 |
6 | "honnef.co/go/tools/analysis/code"
7 | "honnef.co/go/tools/analysis/edit"
8 | "honnef.co/go/tools/analysis/lint"
9 | "honnef.co/go/tools/analysis/report"
10 |
11 | "golang.org/x/tools/go/analysis"
12 | "golang.org/x/tools/go/analysis/passes/inspect"
13 | )
14 |
15 | var SCAnalyzer = lint.InitializeAnalyzer(&lint.Analyzer{
16 | Analyzer: &analysis.Analyzer{
17 | Name: "SA5004",
18 | Run: run,
19 | Requires: []*analysis.Analyzer{inspect.Analyzer},
20 | },
21 | Doc: &lint.RawDocumentation{
22 | Title: `\"for { select { ...\" with an empty default branch spins`,
23 | Since: "2017.1",
24 | Severity: lint.SeverityWarning,
25 | MergeIf: lint.MergeIfAny,
26 | },
27 | })
28 |
29 | var Analyzer = SCAnalyzer.Analyzer
30 |
31 | func run(pass *analysis.Pass) (interface{}, error) {
32 | fn := func(node ast.Node) {
33 | loop := node.(*ast.ForStmt)
34 | if len(loop.Body.List) != 1 || loop.Cond != nil || loop.Init != nil {
35 | return
36 | }
37 | sel, ok := loop.Body.List[0].(*ast.SelectStmt)
38 | if !ok {
39 | return
40 | }
41 | for _, c := range sel.Body.List {
42 | // FIXME this leaves behind an empty line, and possibly
43 | // comments in the default branch. We can't easily fix
44 | // either.
45 | if comm, ok := c.(*ast.CommClause); ok && comm.Comm == nil && len(comm.Body) == 0 {
46 | report.Report(pass, comm, "should not have an empty default case in a for+select loop; the loop will spin",
47 | report.Fixes(edit.Fix("remove empty default branch", edit.Delete(comm))))
48 | // there can only be one default case
49 | break
50 | }
51 | }
52 | }
53 | code.Preorder(pass, fn, (*ast.ForStmt)(nil))
54 | return nil, nil
55 | }
56 |
--------------------------------------------------------------------------------
/vendor/honnef.co/go/tools/staticcheck/sa5008/structtag.go:
--------------------------------------------------------------------------------
1 | // Copyright 2009 The Go Authors. All rights reserved.
2 | // Copyright 2019 Dominik Honnef. All rights reserved.
3 |
4 | package sa5008
5 |
6 | import "strconv"
7 |
8 | func parseStructTag(tag string) (map[string][]string, error) {
9 | // FIXME(dh): detect missing closing quote
10 | out := map[string][]string{}
11 |
12 | for tag != "" {
13 | // Skip leading space.
14 | i := 0
15 | for i < len(tag) && tag[i] == ' ' {
16 | i++
17 | }
18 | tag = tag[i:]
19 | if tag == "" {
20 | break
21 | }
22 |
23 | // Scan to colon. A space, a quote or a control character is a syntax error.
24 | // Strictly speaking, control chars include the range [0x7f, 0x9f], not just
25 | // [0x00, 0x1f], but in practice, we ignore the multi-byte control characters
26 | // as it is simpler to inspect the tag's bytes than the tag's runes.
27 | i = 0
28 | for i < len(tag) && tag[i] > ' ' && tag[i] != ':' && tag[i] != '"' && tag[i] != 0x7f {
29 | i++
30 | }
31 | if i == 0 || i+1 >= len(tag) || tag[i] != ':' || tag[i+1] != '"' {
32 | break
33 | }
34 | name := string(tag[:i])
35 | tag = tag[i+1:]
36 |
37 | // Scan quoted string to find value.
38 | i = 1
39 | for i < len(tag) && tag[i] != '"' {
40 | if tag[i] == '\\' {
41 | i++
42 | }
43 | i++
44 | }
45 | if i >= len(tag) {
46 | break
47 | }
48 | qvalue := string(tag[:i+1])
49 | tag = tag[i+1:]
50 |
51 | value, err := strconv.Unquote(qvalue)
52 | if err != nil {
53 | return nil, err
54 | }
55 | out[name] = append(out[name], value)
56 | }
57 | return out, nil
58 | }
59 |
--------------------------------------------------------------------------------
/vendor/honnef.co/go/tools/staticcheck/sa6000/sa6000.go:
--------------------------------------------------------------------------------
1 | package sa6000
2 |
3 | import (
4 | "fmt"
5 |
6 | "honnef.co/go/tools/analysis/callcheck"
7 | "honnef.co/go/tools/analysis/lint"
8 | "honnef.co/go/tools/go/ir"
9 | "honnef.co/go/tools/go/ir/irutil"
10 | "honnef.co/go/tools/internal/passes/buildir"
11 |
12 | "golang.org/x/tools/go/analysis"
13 | )
14 |
15 | var SCAnalyzer = lint.InitializeAnalyzer(&lint.Analyzer{
16 | Analyzer: &analysis.Analyzer{
17 | Name: "SA6000",
18 | Requires: []*analysis.Analyzer{buildir.Analyzer},
19 | Run: callcheck.Analyzer(rules),
20 | },
21 | Doc: &lint.RawDocumentation{
22 | Title: `Using \'regexp.Match\' or related in a loop, should use \'regexp.Compile\'`,
23 | Since: "2017.1",
24 | Severity: lint.SeverityWarning,
25 | MergeIf: lint.MergeIfAny,
26 | },
27 | })
28 |
29 | var Analyzer = SCAnalyzer.Analyzer
30 |
31 | var rules = map[string]callcheck.Check{
32 | "regexp.Match": check("regexp.Match"),
33 | "regexp.MatchReader": check("regexp.MatchReader"),
34 | "regexp.MatchString": check("regexp.MatchString"),
35 | }
36 |
37 | func check(name string) callcheck.Check {
38 | return func(call *callcheck.Call) {
39 | if callcheck.ExtractConst(call.Args[0].Value) == nil {
40 | return
41 | }
42 | if !isInLoop(call.Instr.Block()) {
43 | return
44 | }
45 | call.Invalid(fmt.Sprintf("calling %s in a loop has poor performance, consider using regexp.Compile", name))
46 | }
47 | }
48 |
49 | func isInLoop(b *ir.BasicBlock) bool {
50 | sets := irutil.FindLoops(b.Parent())
51 | for _, set := range sets {
52 | if set.Has(b) {
53 | return true
54 | }
55 | }
56 | return false
57 | }
58 |
--------------------------------------------------------------------------------
/vendor/honnef.co/go/tools/staticcheck/sa6002/sa6002.go:
--------------------------------------------------------------------------------
1 | package sa6002
2 |
3 | import (
4 | "go/types"
5 |
6 | "honnef.co/go/tools/analysis/callcheck"
7 | "honnef.co/go/tools/analysis/lint"
8 | "honnef.co/go/tools/go/types/typeutil"
9 | "honnef.co/go/tools/internal/passes/buildir"
10 | "honnef.co/go/tools/knowledge"
11 |
12 | "golang.org/x/tools/go/analysis"
13 | )
14 |
15 | var SCAnalyzer = lint.InitializeAnalyzer(&lint.Analyzer{
16 | Analyzer: &analysis.Analyzer{
17 | Name: "SA6002",
18 | Requires: []*analysis.Analyzer{buildir.Analyzer},
19 | Run: callcheck.Analyzer(rules),
20 | },
21 | Doc: &lint.RawDocumentation{
22 | Title: `Storing non-pointer values in \'sync.Pool\' allocates memory`,
23 | Text: `A \'sync.Pool\' is used to avoid unnecessary allocations and reduce the
24 | amount of work the garbage collector has to do.
25 |
26 | When passing a value that is not a pointer to a function that accepts
27 | an interface, the value needs to be placed on the heap, which means an
28 | additional allocation. Slices are a common thing to put in sync.Pools,
29 | and they're structs with 3 fields (length, capacity, and a pointer to
30 | an array). In order to avoid the extra allocation, one should store a
31 | pointer to the slice instead.
32 |
33 | See the comments on https://go-review.googlesource.com/c/go/+/24371
34 | that discuss this problem.`,
35 | Since: "2017.1",
36 | Severity: lint.SeverityWarning,
37 | MergeIf: lint.MergeIfAny,
38 | },
39 | })
40 |
41 | var Analyzer = SCAnalyzer.Analyzer
42 |
43 | var rules = map[string]callcheck.Check{
44 | "(*sync.Pool).Put": func(call *callcheck.Call) {
45 | arg := call.Args[knowledge.Arg("(*sync.Pool).Put.x")]
46 | typ := arg.Value.Value.Type()
47 | _, isSlice := typ.Underlying().(*types.Slice)
48 | if !typeutil.IsPointerLike(typ) || isSlice {
49 | arg.Invalid("argument should be pointer-like to avoid allocations")
50 | }
51 | },
52 | }
53 |
--------------------------------------------------------------------------------
/vendor/honnef.co/go/tools/staticcheck/sa6003/sa6003.go:
--------------------------------------------------------------------------------
1 | package sa6003
2 |
3 | import (
4 | "honnef.co/go/tools/analysis/lint"
5 | "honnef.co/go/tools/internal/passes/buildir"
6 | "honnef.co/go/tools/internal/sharedcheck"
7 |
8 | "golang.org/x/tools/go/analysis"
9 | )
10 |
11 | var SCAnalyzer = lint.InitializeAnalyzer(&lint.Analyzer{
12 | Analyzer: &analysis.Analyzer{
13 | Name: "SA6003",
14 | Run: sharedcheck.CheckRangeStringRunes,
15 | Requires: []*analysis.Analyzer{buildir.Analyzer},
16 | },
17 | Doc: &lint.RawDocumentation{
18 | Title: `Converting a string to a slice of runes before ranging over it`,
19 | Text: `You may want to loop over the runes in a string. Instead of converting
20 | the string to a slice of runes and looping over that, you can loop
21 | over the string itself. That is,
22 |
23 | for _, r := range s {}
24 |
25 | and
26 |
27 | for _, r := range []rune(s) {}
28 |
29 | will yield the same values. The first version, however, will be faster
30 | and avoid unnecessary memory allocations.
31 |
32 | Do note that if you are interested in the indices, ranging over a
33 | string and over a slice of runes will yield different indices. The
34 | first one yields byte offsets, while the second one yields indices in
35 | the slice of runes.`,
36 | Since: "2017.1",
37 | Severity: lint.SeverityWarning,
38 | MergeIf: lint.MergeIfAny,
39 | },
40 | })
41 |
42 | var Analyzer = SCAnalyzer.Analyzer
43 |
--------------------------------------------------------------------------------
/vendor/honnef.co/go/tools/staticcheck/sa6006/sa6006.go:
--------------------------------------------------------------------------------
1 | package sa6006
2 |
3 | import (
4 | "go/ast"
5 |
6 | "honnef.co/go/tools/analysis/code"
7 | "honnef.co/go/tools/analysis/lint"
8 | "honnef.co/go/tools/analysis/report"
9 | "honnef.co/go/tools/pattern"
10 |
11 | "golang.org/x/tools/go/analysis"
12 | "golang.org/x/tools/go/analysis/passes/inspect"
13 | )
14 |
15 | var SCAnalyzer = lint.InitializeAnalyzer(&lint.Analyzer{
16 | Analyzer: &analysis.Analyzer{
17 | Name: "SA6006",
18 | Run: run,
19 | Requires: []*analysis.Analyzer{inspect.Analyzer},
20 | },
21 | Doc: &lint.RawDocumentation{
22 | Title: `Using io.WriteString to write \'[]byte\'`,
23 | Text: `Using io.WriteString to write a slice of bytes, as in
24 |
25 | io.WriteString(w, string(b))
26 |
27 | is both unnecessary and inefficient. Converting from \'[]byte\' to \'string\'
28 | has to allocate and copy the data, and we could simply use \'w.Write(b)\'
29 | instead.`,
30 |
31 | Since: "2024.1",
32 | },
33 | })
34 |
35 | var Analyzer = SCAnalyzer.Analyzer
36 |
37 | var ioWriteStringConversion = pattern.MustParse(`(CallExpr (Symbol "io.WriteString") [_ (CallExpr (Builtin "string") [arg])])`)
38 |
39 | func run(pass *analysis.Pass) (interface{}, error) {
40 | fn := func(node ast.Node) {
41 | m, ok := code.Match(pass, ioWriteStringConversion, node)
42 | if !ok {
43 | return
44 | }
45 | if !code.IsOfStringConvertibleByteSlice(pass, m.State["arg"].(ast.Expr)) {
46 | return
47 | }
48 | report.Report(pass, node, "use io.Writer.Write instead of converting from []byte to string to use io.WriteString")
49 | }
50 | code.Preorder(pass, fn, (*ast.CallExpr)(nil))
51 |
52 | return nil, nil
53 | }
54 |
--------------------------------------------------------------------------------
/vendor/honnef.co/go/tools/staticcheck/sa9001/sa9001.go:
--------------------------------------------------------------------------------
1 | package sa9001
2 |
3 | import (
4 | "go/ast"
5 | "go/token"
6 | "go/types"
7 |
8 | "honnef.co/go/tools/analysis/code"
9 | "honnef.co/go/tools/analysis/lint"
10 | "honnef.co/go/tools/analysis/report"
11 | "honnef.co/go/tools/go/types/typeutil"
12 |
13 | "golang.org/x/tools/go/analysis"
14 | "golang.org/x/tools/go/analysis/passes/inspect"
15 | )
16 |
17 | var SCAnalyzer = lint.InitializeAnalyzer(&lint.Analyzer{
18 | Analyzer: &analysis.Analyzer{
19 | Name: "SA9001",
20 | Run: run,
21 | Requires: []*analysis.Analyzer{inspect.Analyzer},
22 | },
23 | Doc: &lint.RawDocumentation{
24 | Title: `Defers in range loops may not run when you expect them to`,
25 | Since: "2017.1",
26 | Severity: lint.SeverityWarning,
27 | MergeIf: lint.MergeIfAny,
28 | },
29 | })
30 |
31 | var Analyzer = SCAnalyzer.Analyzer
32 |
33 | func run(pass *analysis.Pass) (interface{}, error) {
34 | fn := func(node ast.Node) {
35 | loop := node.(*ast.RangeStmt)
36 | typ := pass.TypesInfo.TypeOf(loop.X)
37 | _, ok := typeutil.CoreType(typ).(*types.Chan)
38 | if !ok {
39 | return
40 | }
41 |
42 | stmts := []*ast.DeferStmt{}
43 | exits := false
44 | fn2 := func(node ast.Node) bool {
45 | switch stmt := node.(type) {
46 | case *ast.DeferStmt:
47 | stmts = append(stmts, stmt)
48 | case *ast.FuncLit:
49 | // Don't look into function bodies
50 | return false
51 | case *ast.ReturnStmt:
52 | exits = true
53 | case *ast.BranchStmt:
54 | exits = node.(*ast.BranchStmt).Tok == token.BREAK
55 | }
56 | return true
57 | }
58 | ast.Inspect(loop.Body, fn2)
59 |
60 | if exits {
61 | return
62 | }
63 | for _, stmt := range stmts {
64 | report.Report(pass, stmt, "defers in this range loop won't run unless the channel gets closed")
65 | }
66 | }
67 | code.Preorder(pass, fn, (*ast.RangeStmt)(nil))
68 | return nil, nil
69 | }
70 |
--------------------------------------------------------------------------------
/vendor/honnef.co/go/tools/staticcheck/sa9002/sa9002.go:
--------------------------------------------------------------------------------
1 | package sa9002
2 |
3 | import (
4 | "fmt"
5 | "go/ast"
6 | "strconv"
7 |
8 | "honnef.co/go/tools/analysis/code"
9 | "honnef.co/go/tools/analysis/edit"
10 | "honnef.co/go/tools/analysis/lint"
11 | "honnef.co/go/tools/analysis/report"
12 | "honnef.co/go/tools/go/types/typeutil"
13 |
14 | "golang.org/x/tools/go/analysis"
15 | "golang.org/x/tools/go/analysis/passes/inspect"
16 | )
17 |
18 | var SCAnalyzer = lint.InitializeAnalyzer(&lint.Analyzer{
19 | Analyzer: &analysis.Analyzer{
20 | Name: "SA9002",
21 | Run: run,
22 | Requires: []*analysis.Analyzer{inspect.Analyzer},
23 | },
24 | Doc: &lint.RawDocumentation{
25 | Title: `Using a non-octal \'os.FileMode\' that looks like it was meant to be in octal.`,
26 | Since: "2017.1",
27 | Severity: lint.SeverityWarning,
28 | MergeIf: lint.MergeIfAny,
29 | },
30 | })
31 |
32 | var Analyzer = SCAnalyzer.Analyzer
33 |
34 | func run(pass *analysis.Pass) (interface{}, error) {
35 | fn := func(node ast.Node) {
36 | call := node.(*ast.CallExpr)
37 | for _, arg := range call.Args {
38 | lit, ok := arg.(*ast.BasicLit)
39 | if !ok {
40 | continue
41 | }
42 | if !typeutil.IsTypeWithName(pass.TypesInfo.TypeOf(lit), "os.FileMode") &&
43 | !typeutil.IsTypeWithName(pass.TypesInfo.TypeOf(lit), "io/fs.FileMode") {
44 | continue
45 | }
46 | if len(lit.Value) == 3 &&
47 | lit.Value[0] != '0' &&
48 | lit.Value[0] >= '0' && lit.Value[0] <= '7' &&
49 | lit.Value[1] >= '0' && lit.Value[1] <= '7' &&
50 | lit.Value[2] >= '0' && lit.Value[2] <= '7' {
51 |
52 | v, err := strconv.ParseInt(lit.Value, 10, 64)
53 | if err != nil {
54 | continue
55 | }
56 | report.Report(pass, arg, fmt.Sprintf("file mode '%s' evaluates to %#o; did you mean '0%s'?", lit.Value, v, lit.Value),
57 | report.Fixes(edit.Fix("fix octal literal", edit.ReplaceWithString(arg, "0"+lit.Value))))
58 | }
59 | }
60 | }
61 | code.Preorder(pass, fn, (*ast.CallExpr)(nil))
62 | return nil, nil
63 | }
64 |
--------------------------------------------------------------------------------
/vendor/honnef.co/go/tools/staticcheck/sa9003/sa9003.go:
--------------------------------------------------------------------------------
1 | package sa9003
2 |
3 | import (
4 | "go/ast"
5 |
6 | "golang.org/x/tools/go/analysis"
7 | "honnef.co/go/tools/analysis/facts/generated"
8 | "honnef.co/go/tools/analysis/lint"
9 | "honnef.co/go/tools/analysis/report"
10 | "honnef.co/go/tools/go/ir/irutil"
11 | "honnef.co/go/tools/internal/passes/buildir"
12 | )
13 |
14 | var SCAnalyzer = lint.InitializeAnalyzer(&lint.Analyzer{
15 | Analyzer: &analysis.Analyzer{
16 | Name: "SA9003",
17 | Run: run,
18 | Requires: []*analysis.Analyzer{buildir.Analyzer, generated.Analyzer},
19 | },
20 | Doc: &lint.RawDocumentation{
21 | Title: `Empty body in an if or else branch`,
22 | Since: "2017.1",
23 | NonDefault: true,
24 | Severity: lint.SeverityWarning,
25 | MergeIf: lint.MergeIfAny,
26 | },
27 | })
28 |
29 | var Analyzer = SCAnalyzer.Analyzer
30 |
31 | func run(pass *analysis.Pass) (interface{}, error) {
32 | for _, fn := range pass.ResultOf[buildir.Analyzer].(*buildir.IR).SrcFuncs {
33 | if fn.Source() == nil {
34 | continue
35 | }
36 | if irutil.IsExample(fn) {
37 | continue
38 | }
39 | cb := func(node ast.Node) bool {
40 | ifstmt, ok := node.(*ast.IfStmt)
41 | if !ok {
42 | return true
43 | }
44 | if ifstmt.Else != nil {
45 | b, ok := ifstmt.Else.(*ast.BlockStmt)
46 | if !ok || len(b.List) != 0 {
47 | return true
48 | }
49 | report.Report(pass, ifstmt.Else, "empty branch", report.FilterGenerated(), report.ShortRange())
50 | }
51 | if len(ifstmt.Body.List) != 0 {
52 | return true
53 | }
54 | report.Report(pass, ifstmt, "empty branch", report.FilterGenerated(), report.ShortRange())
55 | return true
56 | }
57 | if source := fn.Source(); source != nil {
58 | ast.Inspect(source, cb)
59 | }
60 | }
61 | return nil, nil
62 | }
63 |
--------------------------------------------------------------------------------
/vendor/honnef.co/go/tools/staticcheck/sa9009/sa9009.go:
--------------------------------------------------------------------------------
1 | package sa9009
2 |
3 | import (
4 | "fmt"
5 | "strings"
6 |
7 | "golang.org/x/tools/go/analysis"
8 |
9 | "honnef.co/go/tools/analysis/lint"
10 | "honnef.co/go/tools/analysis/report"
11 | )
12 |
13 | var SCAnalyzer = lint.InitializeAnalyzer(&lint.Analyzer{
14 | Analyzer: &analysis.Analyzer{
15 | Name: "SA9009",
16 | Run: run,
17 | Requires: []*analysis.Analyzer{},
18 | },
19 | Doc: &lint.RawDocumentation{
20 | Title: "Ineffectual Go compiler directive",
21 | Text: `
22 | A potential Go compiler directive was found, but is ineffectual as it begins
23 | with whitespace.`,
24 | Since: "2024.1",
25 | Severity: lint.SeverityWarning,
26 | },
27 | })
28 |
29 | var Analyzer = SCAnalyzer.Analyzer
30 |
31 | func run(pass *analysis.Pass) (any, error) {
32 | for _, f := range pass.Files {
33 | for _, cg := range f.Comments {
34 | for _, c := range cg.List {
35 | // Compiler directives have to be // comments
36 | if !strings.HasPrefix(c.Text, "//") {
37 | continue
38 | }
39 | if pass.Fset.PositionFor(c.Pos(), false).Column != 1 {
40 | // Compiler directives have to be top-level. This also
41 | // avoids a false positive for
42 | // 'import _ "unsafe" // go:linkname'
43 | continue
44 | }
45 | text := strings.TrimLeft(c.Text[2:], " \t")
46 | if len(text) == len(c.Text[2:]) {
47 | // There was no leading whitespace
48 | continue
49 | }
50 | if !strings.HasPrefix(text, "go:") {
51 | // Not an attempted compiler directive
52 | continue
53 | }
54 | text = text[3:]
55 | if len(text) == 0 || text[0] < 'a' || text[0] > 'z' {
56 | // A letter other than a-z after "go:", so unlikely to be an
57 | // attempted compiler directive
58 | continue
59 | }
60 | report.Report(pass, c,
61 | fmt.Sprintf(
62 | "ineffectual compiler directive due to extraneous space: %q",
63 | c.Text))
64 | }
65 | }
66 | }
67 | return nil, nil
68 | }
69 |
--------------------------------------------------------------------------------
/vendor/honnef.co/go/tools/stylecheck/analysis.go:
--------------------------------------------------------------------------------
1 | // Code generated by generate.go. DO NOT EDIT.
2 |
3 | package stylecheck
4 |
5 | import (
6 | "honnef.co/go/tools/analysis/lint"
7 | "honnef.co/go/tools/stylecheck/st1000"
8 | "honnef.co/go/tools/stylecheck/st1001"
9 | "honnef.co/go/tools/stylecheck/st1003"
10 | "honnef.co/go/tools/stylecheck/st1005"
11 | "honnef.co/go/tools/stylecheck/st1006"
12 | "honnef.co/go/tools/stylecheck/st1008"
13 | "honnef.co/go/tools/stylecheck/st1011"
14 | "honnef.co/go/tools/stylecheck/st1012"
15 | "honnef.co/go/tools/stylecheck/st1013"
16 | "honnef.co/go/tools/stylecheck/st1015"
17 | "honnef.co/go/tools/stylecheck/st1016"
18 | "honnef.co/go/tools/stylecheck/st1017"
19 | "honnef.co/go/tools/stylecheck/st1018"
20 | "honnef.co/go/tools/stylecheck/st1019"
21 | "honnef.co/go/tools/stylecheck/st1020"
22 | "honnef.co/go/tools/stylecheck/st1021"
23 | "honnef.co/go/tools/stylecheck/st1022"
24 | "honnef.co/go/tools/stylecheck/st1023"
25 | )
26 |
27 | var Analyzers = []*lint.Analyzer{
28 | st1000.SCAnalyzer,
29 | st1001.SCAnalyzer,
30 | st1003.SCAnalyzer,
31 | st1005.SCAnalyzer,
32 | st1006.SCAnalyzer,
33 | st1008.SCAnalyzer,
34 | st1011.SCAnalyzer,
35 | st1012.SCAnalyzer,
36 | st1013.SCAnalyzer,
37 | st1015.SCAnalyzer,
38 | st1016.SCAnalyzer,
39 | st1017.SCAnalyzer,
40 | st1018.SCAnalyzer,
41 | st1019.SCAnalyzer,
42 | st1020.SCAnalyzer,
43 | st1021.SCAnalyzer,
44 | st1022.SCAnalyzer,
45 | st1023.SCAnalyzer,
46 | }
47 |
--------------------------------------------------------------------------------
/vendor/honnef.co/go/tools/stylecheck/doc.go:
--------------------------------------------------------------------------------
1 | //go:generate go run ../generate.go
2 |
3 | // Package stylecheck contains analyzes that enforce style rules.
4 | // Most of the recommendations made are universally agreed upon by the wider Go community.
5 | // Some analyzes, however, implement stricter rules that not everyone will agree with.
6 | // In the context of Staticcheck, these analyzes are not enabled by default.
7 | //
8 | // For the most part it is recommended to follow the advice given by the analyzers that are enabled by default,
9 | // but you may want to disable additional analyzes on a case by case basis.
10 | package stylecheck
11 |
--------------------------------------------------------------------------------
/vendor/honnef.co/go/tools/stylecheck/st1008/st1008.go:
--------------------------------------------------------------------------------
1 | package st1008
2 |
3 | import (
4 | "go/types"
5 |
6 | "honnef.co/go/tools/analysis/lint"
7 | "honnef.co/go/tools/analysis/report"
8 | "honnef.co/go/tools/internal/passes/buildir"
9 |
10 | "golang.org/x/tools/go/analysis"
11 | )
12 |
13 | var SCAnalyzer = lint.InitializeAnalyzer(&lint.Analyzer{
14 | Analyzer: &analysis.Analyzer{
15 | Name: "ST1008",
16 | Run: run,
17 | Requires: []*analysis.Analyzer{buildir.Analyzer},
18 | },
19 | Doc: &lint.RawDocumentation{
20 | Title: `A function's error value should be its last return value`,
21 | Text: `A function's error value should be its last return value.`,
22 | Since: `2019.1`,
23 | MergeIf: lint.MergeIfAny,
24 | },
25 | })
26 |
27 | var Analyzer = SCAnalyzer.Analyzer
28 |
29 | func run(pass *analysis.Pass) (interface{}, error) {
30 | fnLoop:
31 | for _, fn := range pass.ResultOf[buildir.Analyzer].(*buildir.IR).SrcFuncs {
32 | sig := fn.Type().(*types.Signature)
33 | rets := sig.Results()
34 | if rets == nil || rets.Len() < 2 {
35 | continue
36 | }
37 |
38 | if types.Unalias(rets.At(rets.Len()-1).Type()) == types.Universe.Lookup("error").Type() {
39 | // Last return type is error. If the function also returns
40 | // errors in other positions, that's fine.
41 | continue
42 | }
43 |
44 | if rets.Len() >= 2 &&
45 | types.Unalias(rets.At(rets.Len()-1).Type()) == types.Universe.Lookup("bool").Type() &&
46 | types.Unalias(rets.At(rets.Len()-2).Type()) == types.Universe.Lookup("error").Type() {
47 | // Accept (..., error, bool) and assume it's a comma-ok function. It's not clear whether the bool should come last or not for these kinds of functions.
48 | continue
49 | }
50 | for i := rets.Len() - 2; i >= 0; i-- {
51 | if types.Unalias(rets.At(i).Type()) == types.Universe.Lookup("error").Type() {
52 | report.Report(pass, rets.At(i), "error should be returned as the last argument", report.ShortRange())
53 | continue fnLoop
54 | }
55 | }
56 | }
57 | return nil, nil
58 | }
59 |
--------------------------------------------------------------------------------
/vendor/honnef.co/go/tools/stylecheck/st1012/st1012.go:
--------------------------------------------------------------------------------
1 | package st1012
2 |
3 | import (
4 | "fmt"
5 | "go/ast"
6 | "go/token"
7 | "strings"
8 |
9 | "honnef.co/go/tools/analysis/code"
10 | "honnef.co/go/tools/analysis/lint"
11 | "honnef.co/go/tools/analysis/report"
12 |
13 | "golang.org/x/tools/go/analysis"
14 | )
15 |
16 | var SCAnalyzer = lint.InitializeAnalyzer(&lint.Analyzer{
17 | Analyzer: &analysis.Analyzer{
18 | Name: "ST1012",
19 | Run: run,
20 | },
21 | Doc: &lint.RawDocumentation{
22 | Title: `Poorly chosen name for error variable`,
23 | Text: `Error variables that are part of an API should be called \'errFoo\' or
24 | \'ErrFoo\'.`,
25 | Since: "2019.1",
26 | MergeIf: lint.MergeIfAny,
27 | },
28 | })
29 |
30 | var Analyzer = SCAnalyzer.Analyzer
31 |
32 | func run(pass *analysis.Pass) (interface{}, error) {
33 | for _, f := range pass.Files {
34 | for _, decl := range f.Decls {
35 | gen, ok := decl.(*ast.GenDecl)
36 | if !ok || gen.Tok != token.VAR {
37 | continue
38 | }
39 | for _, spec := range gen.Specs {
40 | spec := spec.(*ast.ValueSpec)
41 | if len(spec.Names) != len(spec.Values) {
42 | continue
43 | }
44 |
45 | for i, name := range spec.Names {
46 | val := spec.Values[i]
47 | if !code.IsCallToAny(pass, val, "errors.New", "fmt.Errorf") {
48 | continue
49 | }
50 |
51 | if pass.Pkg.Path() == "net/http" && strings.HasPrefix(name.Name, "http2err") {
52 | // special case for internal variable names of
53 | // bundled HTTP 2 code in net/http
54 | continue
55 | }
56 | prefix := "err"
57 | if name.IsExported() {
58 | prefix = "Err"
59 | }
60 | if !strings.HasPrefix(name.Name, prefix) {
61 | report.Report(pass, name, fmt.Sprintf("error var %s should have name of the form %sFoo", name.Name, prefix))
62 | }
63 | }
64 | }
65 | }
66 | }
67 | return nil, nil
68 | }
69 |
--------------------------------------------------------------------------------
/vendor/honnef.co/go/tools/stylecheck/st1017/st1017.go:
--------------------------------------------------------------------------------
1 | package st1017
2 |
3 | import (
4 | "go/ast"
5 |
6 | "honnef.co/go/tools/analysis/code"
7 | "honnef.co/go/tools/analysis/edit"
8 | "honnef.co/go/tools/analysis/facts/generated"
9 | "honnef.co/go/tools/analysis/lint"
10 | "honnef.co/go/tools/analysis/report"
11 | "honnef.co/go/tools/pattern"
12 |
13 | "golang.org/x/tools/go/analysis"
14 | "golang.org/x/tools/go/analysis/passes/inspect"
15 | )
16 |
17 | var SCAnalyzer = lint.InitializeAnalyzer(&lint.Analyzer{
18 | Analyzer: &analysis.Analyzer{
19 | Name: "ST1017",
20 | Run: run,
21 | Requires: []*analysis.Analyzer{inspect.Analyzer, generated.Analyzer},
22 | },
23 | Doc: &lint.RawDocumentation{
24 | Title: `Don't use Yoda conditions`,
25 | Text: `Yoda conditions are conditions of the kind \"if 42 == x\", where the
26 | literal is on the left side of the comparison. These are a common
27 | idiom in languages in which assignment is an expression, to avoid bugs
28 | of the kind \"if (x = 42)\". In Go, which doesn't allow for this kind of
29 | bug, we prefer the more idiomatic \"if x == 42\".`,
30 | Since: "2019.2",
31 | MergeIf: lint.MergeIfAny,
32 | },
33 | })
34 |
35 | var Analyzer = SCAnalyzer.Analyzer
36 |
37 | var (
38 | checkYodaConditionsQ = pattern.MustParse(`(BinaryExpr left@(TrulyConstantExpression _) tok@(Or "==" "!=") right@(Not (TrulyConstantExpression _)))`)
39 | checkYodaConditionsR = pattern.MustParse(`(BinaryExpr right tok left)`)
40 | )
41 |
42 | func run(pass *analysis.Pass) (interface{}, error) {
43 | fn := func(node ast.Node) {
44 | if _, edits, ok := code.MatchAndEdit(pass, checkYodaConditionsQ, checkYodaConditionsR, node); ok {
45 | report.Report(pass, node, "don't use Yoda conditions",
46 | report.FilterGenerated(),
47 | report.Fixes(edit.Fix("un-Yoda-fy", edits...)))
48 | }
49 | }
50 | code.Preorder(pass, fn, (*ast.BinaryExpr)(nil))
51 | return nil, nil
52 | }
53 |
--------------------------------------------------------------------------------
/vendor/honnef.co/go/tools/stylecheck/st1023/st1023.go:
--------------------------------------------------------------------------------
1 | package st1023
2 |
3 | import (
4 | "honnef.co/go/tools/analysis/lint"
5 | "honnef.co/go/tools/internal/sharedcheck"
6 | )
7 |
8 | func init() {
9 | SCAnalyzer.Analyzer.Name = "ST1023"
10 | }
11 |
12 | var SCAnalyzer = lint.InitializeAnalyzer(&lint.Analyzer{
13 | Analyzer: sharedcheck.RedundantTypeInDeclarationChecker("should", false),
14 | Doc: &lint.RawDocumentation{
15 | Title: "Redundant type in variable declaration",
16 | Since: "2021.1",
17 | NonDefault: true,
18 | MergeIf: lint.MergeIfAll,
19 | },
20 | })
21 |
22 | var Analyzer = SCAnalyzer.Analyzer
23 |
--------------------------------------------------------------------------------