├── .gitattributes ├── .github ├── FUNDING.yml ├── ISSUE_TEMPLATE │ ├── 1_false_positive.md │ ├── 2_false_negative.md │ ├── 3_bug.md │ ├── 4_other.md │ └── config.yml └── workflows │ └── ci.yml ├── .gitignore ├── .gitmodules ├── LICENSE ├── LICENSE-THIRD-PARTY ├── README.md ├── _benchmarks ├── bench.sh └── silent-staticcheck.sh ├── add-check.go ├── analysis ├── callcheck │ └── callcheck.go ├── code │ ├── code.go │ ├── code_test.go │ └── visit.go ├── dfa │ ├── dfa.el │ └── dfa.go ├── edit │ └── edit.go ├── facts │ ├── deprecated │ │ ├── deprecated.go │ │ ├── deprecated_test.go │ │ └── testdata │ │ │ └── src │ │ │ └── example.com │ │ │ └── Deprecated │ │ │ └── Deprecated.go │ ├── directives │ │ └── directives.go │ ├── generated │ │ └── generated.go │ ├── nilness │ │ ├── nilness.go │ │ ├── nilness_test.go │ │ └── testdata │ │ │ └── src │ │ │ └── example.com │ │ │ └── Nilness │ │ │ ├── Nilness.go │ │ │ ├── Nilness_go118.go │ │ │ └── Nilness_go17.go │ ├── purity │ │ ├── purity.go │ │ ├── purity_test.go │ │ └── testdata │ │ │ └── src │ │ │ └── example.com │ │ │ └── Purity │ │ │ └── CheckPureFunctions.go │ ├── tokenfile │ │ └── token.go │ └── typedness │ │ ├── testdata │ │ └── src │ │ │ └── example.com │ │ │ └── Typedness │ │ │ └── Typedness.go │ │ ├── typedness.go │ │ └── typedness_test.go ├── lint │ ├── lint.go │ └── testutil │ │ ├── check.go │ │ └── util.go └── report │ ├── report.go │ └── report_test.go ├── cmd ├── staticcheck │ ├── README.md │ └── staticcheck.go ├── structlayout-optimize │ └── main.go ├── structlayout-pretty │ └── main.go └── structlayout │ ├── README.md │ └── main.go ├── config ├── config.go └── example.conf ├── debug └── debug.go ├── dist └── build.sh ├── doc ├── articles │ └── customizing_staticcheck.html └── run.html ├── generate.go ├── go.mod ├── go.sum ├── go ├── ast │ └── astutil │ │ ├── upstream.go │ │ └── util.go ├── buildid │ ├── UPSTREAM │ ├── buildid.go │ └── note.go ├── gcsizes │ ├── LICENSE │ └── sizes.go ├── ir │ ├── LICENSE │ ├── UPSTREAM │ ├── bench_test.go │ ├── blockopt.go │ ├── builder.go │ ├── builder_test.go │ ├── const.go │ ├── create.go │ ├── doc.go │ ├── dom.go │ ├── emit.go │ ├── example_test.go │ ├── exits.go │ ├── func.go │ ├── html.go │ ├── irutil │ │ ├── load.go │ │ ├── load_test.go │ │ ├── loops.go │ │ ├── stub.go │ │ ├── switch.go │ │ ├── switch_test.go │ │ ├── terminates.go │ │ ├── testdata │ │ │ └── switches.go │ │ ├── util.go │ │ └── visit.go │ ├── lift.go │ ├── lvalue.go │ ├── methods.go │ ├── mode.go │ ├── print.go │ ├── sanity.go │ ├── source.go │ ├── source_test.go │ ├── ssa.go │ ├── stdlib_test.go │ ├── testdata │ │ ├── objlookup.go │ │ └── valueforexpr.go │ ├── util.go │ ├── wrappers.go │ └── write.go ├── loader │ ├── hash.go │ └── loader.go └── types │ └── typeutil │ ├── ext.go │ ├── typeparams.go │ ├── typeparams_test.go │ ├── upstream.go │ └── util.go ├── images ├── logo.svg └── screenshots │ └── struct.png ├── internal ├── analysisinternal │ └── typeindex │ │ └── typeindex.go ├── cmd │ ├── ast-to-pattern │ │ ├── main.go │ │ └── parse.go │ ├── gogrep │ │ └── gogrep.go │ ├── irdump │ │ └── main.go │ └── unused │ │ └── unused.go ├── diff │ └── myers │ │ └── diff.go ├── passes │ └── buildir │ │ ├── buildir.go │ │ ├── buildir_test.go │ │ └── testdata │ │ └── src │ │ └── a │ │ └── a.go ├── renameio │ ├── UPSTREAM │ ├── renameio.go │ ├── renameio_test.go │ └── umask_test.go ├── robustio │ ├── UPSTREAM │ ├── robustio.go │ ├── robustio_darwin.go │ ├── robustio_flaky.go │ ├── robustio_other.go │ └── robustio_windows.go ├── sharedcheck │ └── lint.go ├── sync │ └── sync.go ├── testenv │ ├── UPSTREAM │ ├── testenv.go │ └── testenv_112.go └── typesinternal │ └── typeindex │ └── typeindex.go ├── knowledge ├── arg.go ├── deprecated.go ├── doc.go ├── signatures.go └── targets.go ├── lintcmd ├── cache │ ├── UPSTREAM │ ├── cache.go │ ├── cache_test.go │ ├── default.go │ ├── hash.go │ └── hash_test.go ├── cmd.go ├── cmd_test.go ├── config.go ├── config_test.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 ├── parser_test.go ├── pattern.go └── testdata │ └── fuzz │ └── FuzzParse │ ├── 0001cdcefc5f03f99c21d4ef8232d8f0d8510d9c48e8105c927bc70ac02034a9 │ ├── 00ec3673b415e2f6fc4a3f0d31413096921fbd1faa1cbabdd3637480af027a72 │ ├── 02f183192c9bcfbb22db5afa08e5a9a84babfca022726d0121f42c68d3feecee │ ├── 04fca5bfcc4a67c0d97de75fd6dc13a4a3e5c2dc68e5061f7bcb7e19852efe56 │ ├── 05eea82b6791ec62e197e6128c608c67f5393ff98e94a9c1ba1311e763778749 │ ├── 06b3cbf8b7806ca08ce1ca466e83488ca32abb5db6b0ca4b07c54aa7be47adf3 │ ├── 09c3a6a518c0e44fe60591523655ba4d7dcf62cb477f7e316a51e089adea74c2 │ ├── 0a21c29e926184ebb3c293c9cea3465ef5e1fc5c1b81be7d0770d5d69ee838a3 │ ├── 0ce7ffb3713ec9373531b2903b8f8751e280cdae2b625dcf35dc1fcd88c592bf │ ├── 170704499ec0c05bf39fb37f6c5604e13624c4fb531e41305b2439308e370f35 │ ├── 1a3c741fba42577fac3c5035a3d44e5a78bcefa11f9ccc3bb2919376d984e4a2 │ ├── 1eb6c2e8b8e0be47a019f0345b68ebfdba5f05804204e810166d1fe7c12e8556 │ ├── 27e5f99d63fed488c4e9c3ac4a1e364f809ad894cb109aacc9bd6a85c015fdb7 │ ├── 2bac99d4a450641e3ae239588965c64323b1ee9eb2351cc53019d430d3a59efa │ ├── 2c72a4a6b571446d5374dc5174fa44767bdcc8197e38c54738e50f8b58903230 │ ├── 2f1cdb43e9c62bdb5f8777bc2cb4eee3e8fe173c4361f54833c48d06833ec8fe │ ├── 312c49b9d41ad52e7beaa65ab01f5416e4f4d1db78b4e0001260ac888256b609 │ ├── 3148b044a5e00e508bfd9ac4d139e032503a590c36bd458a8291b77502d13561 │ ├── 31ac2ece486bde345a4ac42fb989efa8835e72e82e357d5d82a313d6ba03eca2 │ ├── 359bf5d248c22a3fc8d67de10279802663a767d4bf2d11dad3209bee13953ee0 │ ├── 3895395d667f576d7f3891a63e4cc0157b2ec73dbe55745c1cba65f31e8cc5db │ ├── 3a3ef35129ccc131fc582363751397ad5723fb8ae891c31eaa5ad86ba402a27e │ ├── 3d78313ab191ebe8647428cd6d896208cb6dcfdd19eb87ae388315548176445a │ ├── 3e0e018aca3103af7824d729c88c028b8e0d60d3de223c786f46acac3e910cdb │ ├── 3f66b015db9a62175f277eab5f76a62397c681b7e4ed6564f452e6159d4cb454 │ ├── 4115b01752356dd12fd6499da369daec6031f62d315aecc4afad56c97f61b904 │ ├── 465963a68302ca54f21c75fc3f680d6a5e1065682fb05a1350ed105883436a82 │ ├── 47857edd56b46ac9c16e788e9295d1dafb910c345899aafd618ddaa12793f4f9 │ ├── 4dec90e6083b5e195501df63d8e1ed6813b623bef60ad8d9e0a1df1f251a58f3 │ ├── 51390f40de42348adb99c613cd8367db404851ce3ea1a4e02ea316b5b7e915b7 │ ├── 53da8fdd88cd66de33bbdbbf564e2b14b69d02f32102d8a96171ed4b05dbc92e │ ├── 56a234ae7b32577f770d5b997f037de709344d7be6fd9ca6e1f44fc8c4367f5b │ ├── 5baab7b6c2c18988c27aefc55f5d48c6ac583f790fb6763cda34375f9b07da40 │ ├── 5cc91809f9225a218b9cfb3a31d5baed3c5a44b5da3a74184fa97abe3bbf178f │ ├── 5d9a745f26174c61e5ab0966e4821f75b71de80345be52d4b81aa1515158b735 │ ├── 5e8383a425cf9bc34f43d60f7586184ae7a544e3ad10405ef7aca57246c2ab66 │ ├── 60c36a14214281c0c2c31599563afec69016f469a0f25222a9500e307b159d11 │ ├── 614ea1474d223cb45716d531aa8afac2dfd52938aeb38c64b70a351f0cf509b2 │ ├── 6490b1471fef1f39 │ ├── 6a4d6ea339df8f59816483834329cc4310816de0223bd3607b2af6c91367a59b │ ├── 6aa9975401e9a24c46284ea6ea1740740fc58950a021c56e1376c2e108ee3b90 │ ├── 6ac1f5e27fbe6d979efae1abf9b2439a824b83f4b2a27508dbeb5dc95b4f9960 │ ├── 6fa1e1e283fd220866a9e5878510db574b761fbd5a0e863e66f40fd4acbbaf07 │ ├── 71e2fa0db72c309e630267beac45c90d37e4b8f9d2d2ed52100d1abca7b72965 │ ├── 76d91998f39bf2e25bd361453a73968274ffe16677cf02d872222d4c799552f8 │ ├── 78eaf491672242d08770ab22b67853f639c767f65346de39c6f3e677b1cd879d │ ├── 7ba6359207886a1c2c7bbe254835555e87a037ecd3af0301a11a43ec2287c487 │ ├── 7ec87621ab148929b69125a04edd13ff104007ca0d8dff12f281753ea93ffb80 │ ├── 8203d4ee0690ca0d0c4b907e1f1c8d6c1724c4771ec3a685b56b440f52b4282a │ ├── 8324b925e52410ab88b6265538881346436b67d95ad808b8f9220a84b0772ab7 │ ├── 84e67732ffe4ba2d8fdb8cfc8690804579623dbc9c56a378ca483f088348296a │ ├── 87839b3497143dd5ea14963b78c011edceb40d13fe1d8cd9b894a81b5dae2200 │ ├── 87f42498d6f57dc40c9972487f0e35d9820acbbce6cf61f3b90dabaa9cb8a8fc │ ├── 90a846c5b88ccf4fe765113a3580ecc90a5cf083a97f0bc4b3bb53a1f00e3fd8 │ ├── 9437b751fb0f1f07f5dcb8c8a10d0f3d4470a77b7ec77df6be872a109184bd1b │ ├── 94b7dc35d595dd794b4f65cd35f94ae8fe7c7214e6da8caa69f0b841e9a099af │ ├── 9d603847ed1c030c81f2289ee576971cd63564cc811afb5c18d5a51db7aefa76 │ ├── a3b8af4d027db37d44e58995ed2ab3cd9f2cb415669287e9e7ce7186534b4b1f │ ├── aa520290f4868dc3c01f15d2769941654a404b87327f5dde790c99fc2c63d875 │ ├── ac1b69c690b399207dd7fe32f03a12d2731fa2d1704f6b15cfdc7f772b0f3187 │ ├── ad86b3632aca0a27fef3d6d79de5c2bcf1c21f7a6caa1260aab964edc21f3f65 │ ├── af10598249def731ec19ebffa3cbc464892d0e445dbefab9ccf578eae136236a │ ├── afe5949d38d9171e39ad413d31abfab6bf45d066b700b4e84a232a6b3aa53085 │ ├── b44bceab2d84f09950aa80d8541c18e31a3d5dde6e874fd0bfe2e4ce54606db0 │ ├── b553c9e015253a9e3d4e202fdb2d90764151e24219f26f7510a433d30323666e │ ├── b6a22c4a4f5e0cf4a291f2d6f03860631075934e4069959665d1f8097c69d0d0 │ ├── b95053e6ea7644faad4e0f2e5f308ca66d6a05c47bf36d0fde268fc12e09ca63 │ ├── ba95d1477ea1b35a949c6b469077d908b1cbcaf7fbf3ce9ef544bfeb24f877fb │ ├── bb62ca358e19867f7d31400cb2a65aac1e918308212c43d10cca21feeb9c99d2 │ ├── c1a2c8141751527604100e865db8d0e711ce25fc5c291b7702752496ac4b2546 │ ├── c30ca6d4801d71144c641960df6919115149d2b6fae5f7d9b2bac2b8cd6b8d25 │ ├── c5f48734d853b82016955671d916daaf72da20a5f8335dddf7640fab1f5a3acb │ ├── c6d06d254dee12276b9b46ef9be863a1eefc4d0673946a706ec7a164625595f0 │ ├── c7abb7fc60634bb8d57b5b7c225a6accf0d2eb56c88bfe5e44cdd3e0c3e29666 │ ├── ca92b01f6dbdcb91e335219081aa48c16893c217bf6edc020fcb78b3ebabcd1f │ ├── e027a03ee012e289def51d770ead1e8a136b60989d3d1fb9388a394da2f595da │ ├── e1e59b9e6718f5089e98c955c391d38c7e243495ece9598826492ab734e5171f │ ├── e43aa6da655e6c326cfb1f8c9970b603411caf262af4a50980c5a5987ee696f3 │ ├── e48990bfca21324ab7a29098b9a4b40fbd22bd5adcfa316b4b8af460a232b638 │ ├── eb0ecf0066fdafbe218a736d3fc071a52408311637cc527db239f110418e8616 │ ├── ed6769b59df864327fba2b109f0cb965e5b8a6e5f1085e36f5635f1d65003a00 │ ├── f640eee2b04d1b52793ba88998a86702893e23d2563d017be9be90efc04a43c6 │ ├── f855d335a52bd8b6ed4472abb33c0eb8f67a63d84f1c27398c23689fb2720645 │ ├── fac160433f2d82b3c15a8c6ad3938fd85825a4f248108538938a57914e80f114 │ ├── fb2c5ef5801f44e5bee94b82dbb1bc787cc4b7fbdb17e5cfcc4283f2c726a99f │ ├── fe6c6578776a5ce92474e943ac14979a308d4151d779fd4cfd782f7fb970165e │ └── ff2017b5c630d7225812cfa8b29b6ebad665505492db847722ba79da5d2c89eb ├── printf ├── fuzz.go ├── printf.go └── printf_test.go ├── quickfix ├── analysis.go ├── doc.go ├── qf1001 │ ├── qf1001.go │ ├── qf1001_test.go │ └── testdata │ │ └── go1.0 │ │ └── CheckDeMorgan │ │ ├── CheckDeMorgan.go │ │ ├── CheckDeMorgan.go.golden │ │ ├── kvexpr.go │ │ └── kvexpr.go.golden ├── qf1002 │ ├── qf1002.go │ ├── qf1002_test.go │ └── testdata │ │ └── go1.0 │ │ └── CheckTaglessSwitch │ │ ├── CheckTaglessSwitch.go │ │ └── CheckTaglessSwitch.go.golden ├── qf1003 │ ├── qf1003.go │ ├── qf1003_test.go │ └── testdata │ │ └── go1.0 │ │ └── CheckIfElseToSwitch │ │ ├── CheckIfElseToSwitch.go │ │ └── CheckIfElseToSwitch.go.golden ├── qf1004 │ ├── qf1004.go │ ├── qf1004_test.go │ └── testdata │ │ └── go1.0 │ │ └── CheckStringsReplaceAll │ │ ├── CheckStringsReplaceAll.go │ │ └── CheckStringsReplaceAll.go.golden ├── qf1005 │ ├── qf1005.go │ ├── qf1005_test.go │ └── testdata │ │ └── go1.0 │ │ └── CheckMathPow │ │ ├── CheckMathPow.go │ │ └── CheckMathPow.go.golden ├── qf1006 │ ├── qf1006.go │ ├── qf1006_test.go │ └── testdata │ │ └── go1.0 │ │ └── CheckForLoopIfBreak │ │ ├── CheckForLoopIfBreak.go │ │ └── CheckForLoopIfBreak.go.golden ├── qf1007 │ ├── qf1007.go │ ├── qf1007_test.go │ └── testdata │ │ └── go1.0 │ │ └── CheckConditionalAssignment │ │ ├── CheckConditionalAssignment.go │ │ └── CheckConditionalAssignment.go.golden ├── qf1008 │ ├── qf1008.go │ ├── qf1008_test.go │ └── testdata │ │ └── go1.0 │ │ ├── CheckExplicitEmbeddedSelector │ │ ├── CheckExplicitEmbeddedSelector-anon.go │ │ ├── CheckExplicitEmbeddedSelector-anon.go.golden │ │ ├── CheckExplicitEmbeddedSelector-basic.go │ │ ├── CheckExplicitEmbeddedSelector-basic.go.golden │ │ ├── CheckExplicitEmbeddedSelector-call.go │ │ ├── CheckExplicitEmbeddedSelector-call.go.golden │ │ ├── CheckExplicitEmbeddedSelector-depth.go │ │ ├── CheckExplicitEmbeddedSelector-depth.go.golden │ │ ├── CheckExplicitEmbeddedSelector-multi.go │ │ ├── CheckExplicitEmbeddedSelector-multi.go.golden │ │ ├── CheckExplicitEmbeddedSelector-partial-multi.go │ │ ├── CheckExplicitEmbeddedSelector-partial-multi.go.golden │ │ ├── CheckExplicitEmbeddedSelector-qualified.go │ │ ├── CheckExplicitEmbeddedSelector-qualified.go.golden │ │ ├── CheckExplicitEmbeddedSelector-recursive.go │ │ ├── CheckExplicitEmbeddedSelector-recursive.go.golden │ │ ├── CheckExplicitEmbeddedSelector-shadowing.go │ │ ├── CheckExplicitEmbeddedSelector-unexported.go │ │ └── CheckExplicitEmbeddedSelector-unexported.go.golden │ │ └── CheckExplicitEmbeddedSelectorassist │ │ └── assist.go ├── qf1009 │ ├── qf1009.go │ ├── qf1009_test.go │ └── testdata │ │ └── go1.0 │ │ └── CheckTimeEquality │ │ ├── CheckTimeEquality.go │ │ └── CheckTimeEquality.go.golden ├── qf1010 │ ├── qf1010.go │ ├── qf1010_test.go │ └── testdata │ │ ├── go1.0 │ │ └── CheckByteSlicePrinting │ │ │ ├── CheckByteSlicePrinting.go │ │ │ └── CheckByteSlicePrinting.go.golden │ │ └── go1.9 │ │ └── CheckByteSlicePrinting │ │ ├── CheckByteSlicePrinting.go │ │ └── CheckByteSlicePrinting.go.golden ├── qf1011 │ ├── qf1011.go │ ├── qf1011_test.go │ └── testdata │ │ ├── go1.0 │ │ └── CheckRedundantTypeInDeclaration │ │ │ ├── CheckRedundantTypeInDeclaration.go │ │ │ └── CheckRedundantTypeInDeclaration.go.golden │ │ └── go1.9 │ │ └── CheckRedundantTypeInDeclaration │ │ ├── README │ │ ├── cgo.go │ │ └── cgo.golden └── qf1012 │ ├── qf1012.go │ ├── qf1012_test.go │ └── testdata │ └── go1.0 │ └── CheckWriteBytesSprintf │ ├── CheckWriteBytesSprintf.go │ └── CheckWriteBytesSprintf.go.golden ├── sarif └── sarif.go ├── simple ├── analysis.go ├── doc.go ├── s1000 │ ├── s1000.go │ ├── s1000_test.go │ └── testdata │ │ └── go1.0 │ │ └── CheckSingleCaseSelect │ │ └── single-case-select.go ├── s1001 │ ├── s1001.go │ ├── s1001_test.go │ └── testdata │ │ ├── go1.0 │ │ └── CheckLoopCopy │ │ │ ├── copy.go │ │ │ └── copy.go.golden │ │ └── go1.18 │ │ └── CheckLoopCopy │ │ ├── copy_generics.go │ │ └── copy_generics.go.golden ├── s1002 │ ├── s1002.go │ ├── s1002_test.go │ └── testdata │ │ ├── go1.0 │ │ └── CheckIfBoolCmp │ │ │ ├── bool-cmp.go │ │ │ ├── bool-cmp.go.golden │ │ │ └── bool-cmp_test.go │ │ └── go1.18 │ │ └── CheckIfBoolCmp │ │ ├── bool-cmp_generics.go │ │ └── bool-cmp_generics.go.golden ├── s1003 │ ├── s1003.go │ ├── s1003_test.go │ └── testdata │ │ └── go1.0 │ │ └── CheckStringsContains │ │ ├── contains.go │ │ └── contains.go.golden ├── s1004 │ ├── s1004.go │ ├── s1004_test.go │ └── testdata │ │ └── go1.0 │ │ └── CheckBytesCompare │ │ ├── compare.go │ │ └── compare.go.golden ├── s1005 │ ├── s1005.go │ ├── s1005_test.go │ └── testdata │ │ ├── go1.0 │ │ └── CheckUnnecessaryBlank │ │ │ ├── LintBlankOK.go │ │ │ ├── LintBlankOK.go.golden │ │ │ ├── receive-blank.go │ │ │ └── receive-blank.go.golden │ │ ├── go1.3 │ │ └── CheckUnnecessaryBlank │ │ │ └── range.go │ │ └── go1.4 │ │ └── CheckUnnecessaryBlank │ │ ├── range.go │ │ └── range.go.golden ├── s1006 │ ├── s1006.go │ ├── s1006_test.go │ └── testdata │ │ └── go1.0 │ │ └── CheckForTrue │ │ ├── for-true.go │ │ ├── generated.go │ │ └── input.go ├── s1007 │ ├── s1007.go │ ├── s1007_test.go │ └── testdata │ │ └── go1.0 │ │ └── CheckRegexpRaw │ │ └── regexp-raw.go ├── s1008 │ ├── s1008.go │ ├── s1008_test.go │ └── testdata │ │ └── go1.0 │ │ └── CheckIfReturn │ │ ├── comment.go │ │ └── if-return.go ├── s1009 │ ├── s1009.go │ ├── s1009_test.go │ └── testdata │ │ ├── go1.0 │ │ └── CheckRedundantNilCheckWithLen │ │ │ └── nil-len.go │ │ └── go1.18 │ │ └── CheckRedundantNilCheckWithLen │ │ └── nil-len_generics.go ├── s1010 │ ├── s1010.go │ ├── s1010_test.go │ └── testdata │ │ └── go1.0 │ │ └── CheckSlicing │ │ ├── slicing.go │ │ └── slicing.go.golden ├── s1011 │ ├── s1011.go │ ├── s1011_test.go │ └── testdata │ │ └── go1.0 │ │ └── CheckLoopAppend │ │ ├── loop-append.go │ │ └── loop-append.go.golden ├── s1012 │ ├── s1012.go │ ├── s1012_test.go │ └── testdata │ │ └── go1.0 │ │ └── CheckTimeSince │ │ ├── time-since.go │ │ └── time-since.go.golden ├── s1016 │ ├── s1016.go │ ├── s1016_test.go │ └── testdata │ │ ├── go1.0 │ │ └── CheckSimplerStructConversion │ │ │ ├── convert.go │ │ │ └── convert.go.golden │ │ ├── go1.18 │ │ └── CheckSimplerStructConversion │ │ │ ├── convert_generics.go │ │ │ └── convert_generics.go.golden │ │ ├── go1.7 │ │ └── CheckSimplerStructConversion │ │ │ ├── convert.go │ │ │ └── convert.go.golden │ │ ├── go1.8 │ │ └── CheckSimplerStructConversion │ │ │ ├── convert.go │ │ │ └── convert.go.golden │ │ └── go1.9 │ │ └── CheckSimplerStructConversion │ │ ├── convert_alias.go │ │ └── convert_alias.go.golden ├── s1017 │ ├── s1017.go │ ├── s1017_test.go │ └── testdata │ │ └── go1.0 │ │ └── CheckTrim │ │ └── trim.go ├── s1018 │ ├── s1018.go │ ├── s1018_test.go │ └── testdata │ │ ├── go1.0 │ │ └── CheckLoopSlide │ │ │ ├── LintLoopSlide.go │ │ │ └── LintLoopSlide.go.golden │ │ └── go1.18 │ │ └── CheckLoopSlide │ │ ├── generics.go │ │ └── generics.go.golden ├── s1019 │ ├── s1019.go │ ├── s1019_test.go │ └── testdata │ │ ├── go1.0 │ │ └── CheckMakeLenCap │ │ │ └── LintMakeLenCap.go │ │ └── go1.18 │ │ └── CheckMakeLenCap │ │ └── CheckMakeLenCap.go ├── s1020 │ ├── s1020.go │ ├── s1020_test.go │ └── testdata │ │ └── go1.0 │ │ └── CheckAssertNotNil │ │ └── LintAssertNotNil.go ├── s1021 │ ├── s1021.go │ ├── s1021_test.go │ └── testdata │ │ └── go1.0 │ │ └── CheckDeclareAssign │ │ ├── LintDeclareAssign.go │ │ └── LintDeclareAssign.go.golden ├── s1023 │ ├── s1023.go │ ├── s1023_test.go │ └── testdata │ │ └── go1.0 │ │ ├── CheckRedundantBreak │ │ └── LintRedundantBreak.go │ │ └── CheckRedundantReturn │ │ └── LintRedundantReturn.go ├── s1024 │ ├── s1024.go │ ├── s1024_test.go │ └── testdata │ │ ├── go1.7 │ │ └── CheckTimeUntil │ │ │ └── LimeTimeUntil.go │ │ └── go1.8 │ │ └── CheckTimeUntil │ │ ├── LimeTimeUntil.go │ │ └── LimeTimeUntil.go.golden ├── s1025 │ ├── s1025.go │ ├── s1025_test.go │ └── testdata │ │ ├── go1.0 │ │ └── CheckRedundantSprintf │ │ │ ├── LintRedundantSprintf.go │ │ │ └── LintRedundantSprintf.go.golden │ │ ├── go1.17 │ │ └── CheckRedundantSprintf │ │ │ ├── LintRedundantSprintf.go │ │ │ └── LintRedundantSprintf.go.golden │ │ ├── go1.18 │ │ └── CheckRedundantSprintf │ │ │ ├── LintRedundantSprintf.go │ │ │ └── LintRedundantSprintf.go.golden │ │ └── go1.9 │ │ └── CheckRedundantSprintf │ │ ├── LintRedundantSprintf.go │ │ └── LintRedundantSprintf.go.golden ├── s1028 │ ├── s1028.go │ ├── s1028_test.go │ └── testdata │ │ └── go1.0 │ │ └── CheckErrorsNewSprintf │ │ ├── LintErrorsNewSprintf.go │ │ └── LintErrorsNewSprintf.go.golden ├── s1029 │ ├── s1029.go │ ├── s1029_test.go │ └── testdata │ │ ├── go1.0 │ │ └── CheckRangeStringRunes │ │ │ └── LintRangeStringRunes.go │ │ └── go1.18 │ │ └── CheckRangeStringRunes │ │ └── generics.go ├── s1030 │ ├── s1030.go │ ├── s1030_test.go │ └── testdata │ │ ├── go1.0 │ │ └── CheckBytesBufferConversions │ │ │ ├── LintBytesBufferConversions.go │ │ │ └── LintBytesBufferConversions.go.golden │ │ └── go1.9 │ │ └── CheckBytesBufferConversions │ │ ├── LintBytesBufferConversions.go │ │ └── LintBytesBufferConversions.go.golden ├── s1031 │ ├── s1031.go │ ├── s1031_test.go │ └── testdata │ │ ├── go1.0 │ │ └── CheckNilCheckAroundRange │ │ │ └── LintNilCheckAroundRange.go │ │ └── go1.18 │ │ └── CheckNilCheckAroundRange │ │ └── CheckNilCheckAroundRange.go ├── s1032 │ ├── s1032.go │ ├── s1032_test.go │ └── testdata │ │ └── go1.0 │ │ └── CheckSortHelpers │ │ └── LintSortHelpers.go ├── s1033 │ ├── s1033.go │ ├── s1033_test.go │ └── testdata │ │ └── go1.0 │ │ └── CheckGuardedDelete │ │ ├── LintGuardedDelete.go │ │ └── LintGuardedDelete.go.golden ├── s1034 │ ├── s1034.go │ ├── s1034_test.go │ └── testdata │ │ └── go1.0 │ │ └── CheckSimplifyTypeSwitch │ │ ├── LintSimplifyTypeSwitch.go │ │ └── LintSimplifyTypeSwitch.go.golden ├── s1035 │ ├── s1035.go │ ├── s1035_test.go │ └── testdata │ │ └── go1.0 │ │ └── CheckRedundantCanonicalHeaderKey │ │ ├── LintRedundantCanonicalHeaderKey.go │ │ └── LintRedundantCanonicalHeaderKey.go.golden ├── s1036 │ ├── s1036.go │ ├── s1036_test.go │ └── testdata │ │ └── go1.0 │ │ └── CheckUnnecessaryGuard │ │ ├── LintUnnecessaryGuard.go │ │ └── LintUnnecessaryGuard.go.golden ├── s1037 │ ├── s1037.go │ ├── s1037_test.go │ └── testdata │ │ └── go1.0 │ │ └── CheckElaborateSleep │ │ ├── LintElaborateSleep.go │ │ └── LintElaborateSleep.go.golden ├── s1038 │ ├── s1038.go │ ├── s1038_test.go │ └── testdata │ │ └── go1.0 │ │ └── CheckPrintSprintf │ │ └── CheckPrintSprintf.go ├── s1039 │ ├── s1039.go │ ├── s1039_test.go │ └── testdata │ │ └── go1.0 │ │ └── CheckSprintLiteral │ │ ├── CheckSprintLiteral.go │ │ └── CheckSprintLiteral.go.golden └── s1040 │ ├── s1040.go │ ├── s1040_test.go │ └── testdata │ └── go1.0 │ └── CheckSameTypeTypeAssertion │ └── CheckSameTypeTypeAssertion.go ├── staticcheck.conf ├── staticcheck ├── analysis.go ├── doc.go ├── fakejson │ └── encode.go ├── fakereflect │ └── fakereflect.go ├── fakexml │ ├── marshal.go │ ├── typeinfo.go │ └── xml.go ├── sa1000 │ ├── sa1000.go │ ├── sa1000_test.go │ └── testdata │ │ └── go1.0 │ │ └── CheckRegexps │ │ └── CheckRegexps.go ├── sa1001 │ ├── sa1001.go │ ├── sa1001_test.go │ └── testdata │ │ └── go1.0 │ │ └── CheckTemplate │ │ └── CheckTemplate.go ├── sa1002 │ ├── sa1002.go │ ├── sa1002_test.go │ └── testdata │ │ └── go1.0 │ │ └── CheckTimeParse │ │ └── CheckTimeParse.go ├── sa1003 │ ├── sa1003.go │ ├── sa1003_test.go │ └── testdata │ │ ├── go1.0 │ │ └── CheckEncodingBinary │ │ │ └── CheckEncodingBinary.go │ │ ├── go1.7 │ │ └── CheckEncodingBinary │ │ │ └── CheckEncodingBinary.go │ │ └── go1.8 │ │ └── CheckEncodingBinary │ │ └── CheckEncodingBinary.go ├── sa1004 │ ├── sa1004.go │ ├── sa1004_test.go │ └── testdata │ │ └── go1.0 │ │ └── CheckTimeSleepConstant │ │ ├── CheckTimeSleepConstant.go │ │ └── CheckTimeSleepConstant.go.golden ├── sa1005 │ ├── sa1005.go │ ├── sa1005_test.go │ └── testdata │ │ └── go1.0 │ │ └── CheckExec │ │ └── CheckExec.go ├── sa1006 │ ├── sa1006.go │ ├── sa1006_test.go │ └── testdata │ │ └── go1.0 │ │ └── CheckUnsafePrintf │ │ ├── CheckUnsafePrintf.go │ │ └── CheckUnsafePrintf.go.golden ├── sa1007 │ ├── sa1007.go │ ├── sa1007_test.go │ └── testdata │ │ └── go1.0 │ │ └── CheckURLs │ │ └── CheckURLs.go ├── sa1008 │ ├── sa1008.go │ ├── sa1008_test.go │ └── testdata │ │ └── go1.0 │ │ └── CheckCanonicalHeaderKey │ │ ├── CheckCanonicalHeaderKey.go │ │ └── CheckCanonicalHeaderKey.go.golden ├── sa1010 │ ├── sa1010.go │ ├── sa1010_test.go │ └── testdata │ │ └── go1.0 │ │ └── checkStdlibUsageRegexpFindAll │ │ └── checkStdlibUsageRegexpFindAll.go ├── sa1011 │ ├── sa1011.go │ ├── sa1011_test.go │ └── testdata │ │ └── go1.0 │ │ └── checkStdlibUsageUTF8Cutset │ │ └── checkStdlibUsageUTF8Cutset.go ├── sa1012 │ ├── sa1012.go │ ├── sa1012_test.go │ └── testdata │ │ ├── go1.0 │ │ └── checkStdlibUsageNilContext │ │ │ ├── checkStdlibUsageNilContext.go │ │ │ └── checkStdlibUsageNilContext.go.golden │ │ └── go1.18 │ │ └── checkStdlibUsageNilContext │ │ ├── checkStdlibUsageNilContext_generics.go │ │ └── checkStdlibUsageNilContext_generics.go.golden ├── sa1013 │ ├── sa1013.go │ ├── sa1013_test.go │ └── testdata │ │ └── go1.0 │ │ └── checkStdlibUsageSeeker │ │ ├── checkStdlibUsageSeeker.go │ │ └── checkStdlibUsageSeeker.go.golden ├── sa1014 │ ├── sa1014.go │ ├── sa1014_test.go │ └── testdata │ │ └── go1.0 │ │ └── CheckUnmarshalPointer │ │ └── CheckUnmarshalPointer.go ├── sa1015 │ ├── sa1015.go │ ├── sa1015_test.go │ └── testdata │ │ ├── go1.0 │ │ ├── CheckLeakyTimeTick-main │ │ │ └── CheckLeakyTimeTick-main.go │ │ └── CheckLeakyTimeTick │ │ │ └── CheckLeakyTimeTick.go │ │ └── go1.23 │ │ └── CheckLeakyTimeTick │ │ └── CheckLeakyTimeTick.go ├── sa1016 │ ├── sa1016.go │ ├── sa1016_test.go │ └── testdata │ │ └── go1.0 │ │ └── CheckUntrappableSignal │ │ ├── CheckUntrappableSignal.go │ │ ├── CheckUntrappableSignal.go.golden │ │ ├── CheckUntrappableSignal_unix.go │ │ └── CheckUntrappableSignal_unix.go.golden ├── sa1017 │ ├── sa1017.go │ ├── sa1017_test.go │ └── testdata │ │ └── go1.0 │ │ └── CheckUnbufferedSignalChan │ │ └── CheckUnbufferedSignalChan.go ├── sa1018 │ ├── sa1018.go │ ├── sa1018_test.go │ └── testdata │ │ └── go1.0 │ │ └── CheckStringsReplaceZero │ │ └── CheckStringsReplaceZero.go ├── sa1019 │ ├── sa1019.go │ ├── sa1019_test.go │ └── testdata │ │ ├── go1.0 │ │ ├── AnotherCheckDeprecated.assist │ │ │ └── CheckDeprecatedassist.go │ │ ├── CheckDeprecated.assist │ │ │ └── CheckDeprecatedassist.go │ │ ├── CheckDeprecated │ │ │ ├── CheckDeprecated.go │ │ │ ├── CheckDeprecated_test.go │ │ │ ├── external_test.go │ │ │ ├── not-protobuf.go │ │ │ └── protobuf.go │ │ └── vendor │ │ │ └── github.com │ │ │ └── golang │ │ │ └── protobuf │ │ │ └── proto │ │ │ └── pkg.go │ │ ├── go1.18 │ │ ├── CheckDeprecated.assist │ │ │ └── CheckDeprecatedassist_generics.go │ │ └── CheckDeprecated │ │ │ └── CheckDeprecated_generics.go │ │ ├── go1.19 │ │ └── CheckDeprecated │ │ │ ├── CheckDeprecated.go │ │ │ └── stub.go │ │ ├── go1.3 │ │ └── CheckDeprecated │ │ │ └── CheckDeprecated.go │ │ ├── go1.4 │ │ └── CheckDeprecated │ │ │ └── CheckDeprecated.go │ │ └── go1.8 │ │ └── CheckDeprecated │ │ └── CheckDeprecated.go ├── sa1020 │ ├── sa1020.go │ ├── sa1020_test.go │ └── testdata │ │ └── go1.0 │ │ └── CheckListenAddress │ │ └── CheckListenAddress.go ├── sa1021 │ ├── sa1021.go │ ├── sa1021_test.go │ └── testdata │ │ └── go1.0 │ │ └── CheckBytesEqualIP │ │ └── CheckBytesEqualIP.go ├── sa1023 │ ├── sa1023.go │ ├── sa1023_test.go │ └── testdata │ │ ├── go1.0 │ │ └── CheckWriterBufferModified │ │ │ └── CheckWriterBufferModified.go │ │ └── go1.9 │ │ └── CheckWriterBufferModified │ │ └── CheckWriterBufferModified.go ├── sa1024 │ ├── sa1024.go │ ├── sa1024_test.go │ └── testdata │ │ └── go1.0 │ │ └── CheckNonUniqueCutset │ │ └── CheckNonUniqueCutset.go ├── sa1025 │ ├── sa1025.go │ ├── sa1025_test.go │ └── testdata │ │ └── go1.0 │ │ └── CheckTimerResetReturnValue │ │ └── CheckTimerResetReturnValue.go ├── sa1026 │ ├── sa1026.go │ ├── sa1026_test.go │ └── testdata │ │ ├── go1.0 │ │ └── CheckUnsupportedMarshal │ │ │ └── CheckUnsupportedMarshal.go │ │ └── go1.18 │ │ └── CheckUnsupportedMarshal │ │ └── generics.go ├── sa1027 │ ├── sa1027.go │ ├── sa1027_test.go │ └── testdata │ │ └── go1.0 │ │ └── CheckAtomicAlignment │ │ ├── atomic32.go │ │ └── atomic64.go ├── sa1028 │ ├── sa1028.go │ ├── sa1028_test.go │ └── testdata │ │ └── go1.0 │ │ └── CheckSortSlice │ │ └── slice.go ├── sa1029 │ ├── sa1029.go │ ├── sa1029_test.go │ └── testdata │ │ └── go1.0 │ │ └── CheckWithValueKey │ │ └── CheckWithValueKey.go ├── sa1030 │ ├── sa1030.go │ ├── sa1030_test.go │ └── testdata │ │ ├── go1.0 │ │ └── CheckStrconv │ │ │ └── CheckStrconv.go │ │ └── go1.15 │ │ └── CheckStrconv │ │ ├── CheckStrconv.go │ │ └── stub.go ├── sa1031 │ ├── sa1031.go │ ├── sa1031_test.go │ └── testdata │ │ └── go1.0 │ │ ├── CheckEncodingAscii85 │ │ └── CheckEncodingAscii85.go │ │ ├── CheckEncodingBase32 │ │ └── CheckEncodingBase32.go │ │ ├── CheckEncodingBase64 │ │ └── CheckEncodingBase64.go │ │ └── CheckEncodingHex │ │ └── CheckEncodingHex.go ├── sa1032 │ ├── sa1032.go │ ├── sa1032_test.go │ └── testdata │ │ └── go1.0 │ │ └── example.com │ │ └── ErrorsOrder │ │ └── ErrorsOrder.go ├── sa2000 │ ├── sa2000.go │ ├── sa2000_test.go │ └── testdata │ │ └── go1.0 │ │ └── CheckWaitgroupAdd │ │ └── CheckWaitgroupAdd.go ├── sa2001 │ ├── sa2001.go │ ├── sa2001_test.go │ └── testdata │ │ └── go1.0 │ │ └── CheckEmptyCriticalSection │ │ └── CheckEmptyCriticalSection.go ├── sa2002 │ ├── sa2002.go │ ├── sa2002_test.go │ └── testdata │ │ └── go1.0 │ │ └── CheckConcurrentTesting │ │ └── CheckConcurrentTesting.go ├── sa2003 │ ├── sa2003.go │ ├── sa2003_test.go │ └── testdata │ │ └── go1.0 │ │ └── CheckDeferLock │ │ └── CheckDeferLock.go ├── sa3000 │ ├── sa3000.go │ ├── sa3000_test.go │ └── testdata │ │ ├── go1.15 │ │ └── CheckTestMainExit-1 │ │ │ └── CheckTestMainExit-1.go │ │ └── go1.4 │ │ ├── CheckTestMainExit-1 │ │ └── CheckTestMainExit-1.go │ │ ├── CheckTestMainExit-2 │ │ └── CheckTestMainExit-2.go │ │ ├── CheckTestMainExit-3 │ │ └── CheckTestMainExit-3.go │ │ ├── CheckTestMainExit-4 │ │ └── CheckTestMainExit-4.go │ │ └── CheckTestMainExit-5 │ │ └── CheckTestMainExit-5.go ├── sa3001 │ ├── sa3001.go │ ├── sa3001_test.go │ └── testdata │ │ └── go1.0 │ │ └── CheckBenchmarkN │ │ └── CheckBenchmarkN.go ├── sa4000 │ ├── sa4000.go │ ├── sa4000_test.go │ └── testdata │ │ ├── go1.0 │ │ └── CheckLhsRhsIdentical │ │ │ ├── CheckLhsRhsIdentical.go │ │ │ └── cgo.go │ │ └── go1.18 │ │ └── CheckLhsRhsIdentical │ │ └── generics.go ├── sa4001 │ ├── sa4001.go │ ├── sa4001_test.go │ └── testdata │ │ └── go1.0 │ │ └── CheckIneffectiveCopy │ │ └── CheckIneffectiveCopy.go ├── sa4003 │ ├── sa4003.go │ ├── sa4003_test.go │ └── testdata │ │ └── go1.0 │ │ └── CheckExtremeComparison │ │ ├── CheckExtremeComparison.go │ │ └── CheckExtremeComparison64.go ├── sa4004 │ ├── sa4004.go │ ├── sa4004_test.go │ └── testdata │ │ ├── go1.0 │ │ └── CheckIneffectiveLoop │ │ │ └── CheckIneffectiveLoop.go │ │ └── go1.18 │ │ └── CheckIneffectiveLoop │ │ └── CheckIneffectiveLoop_generics.go ├── sa4005 │ ├── sa4005.go │ ├── sa4005_test.go │ └── testdata │ │ └── go1.0 │ │ └── CheckIneffectiveFieldAssignments │ │ ├── CheckIneffectiveFieldAssignments.go │ │ └── issue141.go ├── sa4006 │ ├── sa4006.go │ ├── sa4006_test.go │ └── testdata │ │ └── go1.0 │ │ └── CheckUnreadVariableValues │ │ ├── CheckUnreadVariableValues.go │ │ └── CheckUnreadVariableValues_test.go ├── sa4008 │ ├── sa4008.go │ ├── sa4008_test.go │ └── testdata │ │ └── go1.0 │ │ └── CheckLoopCondition │ │ └── CheckLoopCondition.go ├── sa4009 │ ├── sa4009.go │ ├── sa4009_test.go │ └── testdata │ │ └── go1.0 │ │ └── CheckArgOverwritten │ │ └── CheckArgOverwritten.go ├── sa4010 │ ├── sa4010.go │ ├── sa4010_test.go │ └── testdata │ │ └── go1.0 │ │ └── CheckIneffectiveAppend │ │ └── CheckIneffectiveAppend.go ├── sa4011 │ ├── sa4011.go │ ├── sa4011_test.go │ └── testdata │ │ └── go1.0 │ │ └── CheckScopedBreak │ │ └── CheckScopedBreak.go ├── sa4012 │ ├── sa4012.go │ ├── sa4012_test.go │ └── testdata │ │ └── go1.0 │ │ └── CheckNaNComparison │ │ └── CheckNaNComparison.go ├── sa4013 │ ├── sa4013.go │ ├── sa4013_test.go │ └── testdata │ │ └── go1.0 │ │ └── CheckDoubleNegation │ │ ├── CheckDoubleNegation.go │ │ └── CheckDoubleNegation.go.golden ├── sa4014 │ ├── sa4014.go │ ├── sa4014_test.go │ └── testdata │ │ └── go1.0 │ │ └── CheckRepeatedIfElse │ │ └── CheckRepeatedIfElse.go ├── sa4015 │ ├── sa4015.go │ ├── sa4015_test.go │ └── testdata │ │ ├── go1.0 │ │ └── CheckMathInt │ │ │ └── CheckMathInt.go │ │ └── go1.18 │ │ └── CheckMathInt │ │ └── CheckMathInt.go ├── sa4016 │ ├── sa4016.go │ ├── sa4016_test.go │ └── testdata │ │ ├── go1.0 │ │ ├── CheckSillyBitwiseOps │ │ │ └── CheckSillyBitwiseOps.go │ │ ├── CheckSillyBitwiseOps_dotImport │ │ │ ├── foo.go │ │ │ └── foo_test.go │ │ └── CheckSillyBitwiseOps_shadowedIota │ │ │ └── shadowed.go │ │ └── go1.18 │ │ └── CheckSillyBitwiseOps │ │ └── generics.go ├── sa4017 │ ├── sa4017.go │ ├── sa4017_test.go │ └── testdata │ │ └── go1.0 │ │ └── CheckSideEffectFreeCalls │ │ ├── CheckSideEffectFreeCalls.go │ │ └── CheckSideEffectFreeCalls_test.go ├── sa4018 │ ├── sa4018.go │ ├── sa4018_test.go │ └── testdata │ │ └── go1.0 │ │ └── CheckSelfAssignment │ │ └── CheckSelfAssignment.go ├── sa4019 │ ├── sa4019.go │ ├── sa4019_test.go │ └── testdata │ │ └── go1.1 │ │ └── CheckDuplicateBuildConstraints │ │ └── CheckDuplicateBuildConstraints.go ├── sa4020 │ ├── sa4020.go │ ├── sa4020_test.go │ └── testdata │ │ ├── go1.0 │ │ └── CheckUnreachableTypeCases │ │ │ └── CheckUnreachableTypeCases.go │ │ └── go1.18 │ │ └── CheckUnreachableTypeCases │ │ └── typeparams.go ├── sa4021 │ ├── sa4021.go │ ├── sa4021_test.go │ └── testdata │ │ └── go1.0 │ │ └── CheckSingleArgAppend │ │ └── CheckSingleArgAppend.go ├── sa4022 │ ├── sa4022.go │ ├── sa4022_test.go │ └── testdata │ │ └── go1.0 │ │ └── CheckAddressIsNil │ │ └── CheckAddressIsNil.go ├── sa4023 │ ├── sa4023.go │ ├── sa4023_test.go │ └── testdata │ │ ├── go1.0 │ │ ├── CheckTypedNilInterface │ │ │ ├── CheckTypedNilInterface.go │ │ │ └── real.go │ │ ├── i26000 │ │ │ └── 26000.go │ │ ├── i27815 │ │ │ └── 27815.go │ │ ├── i28241 │ │ │ └── 28241.go │ │ ├── i31873 │ │ │ └── 31873.go │ │ ├── i33965 │ │ │ └── 33965.go │ │ ├── i33994 │ │ │ └── 33994.go │ │ └── i35217 │ │ │ └── 35217.go │ │ ├── go1.18 │ │ └── CheckTypedNilInterface │ │ │ └── generics.go │ │ └── go1.9 │ │ └── CheckTypedNilInterface │ │ └── CheckTypedNilInterface.go ├── sa4024 │ ├── sa4024.go │ ├── sa4024_test.go │ └── testdata │ │ └── go1.0 │ │ └── CheckBuiltinZeroComparison │ │ └── CheckBuiltinZeroComparison.go ├── sa4025 │ ├── sa4025.go │ ├── sa4025_test.go │ └── testdata │ │ └── go1.0 │ │ └── CheckIntegerDivisionEqualsZero │ │ └── CheckIntegerDivisionEqualsZero.go ├── sa4026 │ ├── sa4026.go │ ├── sa4026_test.go │ └── testdata │ │ └── go1.0 │ │ └── CheckNegativeZeroFloat │ │ ├── CheckNegativeZeroFloat.go │ │ └── CheckNegativeZeroFloat.go.golden ├── sa4027 │ ├── sa4027.go │ ├── sa4027_test.go │ └── testdata │ │ └── go1.0 │ │ └── CheckIneffectiveURLQueryModification │ │ └── CheckIneffectiveURLQueryModification.go ├── sa4028 │ ├── sa4028.go │ ├── sa4028_test.go │ └── testdata │ │ └── go1.0 │ │ └── CheckModuloOne │ │ └── CheckModuloOne.go ├── sa4029 │ ├── sa4029.go │ ├── sa4029_test.go │ └── testdata │ │ ├── go1.0 │ │ └── CheckIneffectiveSort │ │ │ ├── CheckIneffectiveSort.go │ │ │ └── CheckIneffectiveSort.go.golden │ │ └── go1.9 │ │ └── CheckIneffectiveSort │ │ ├── CheckIneffectiveSort.go │ │ └── CheckIneffectiveSort.go.golden ├── sa4030 │ ├── sa4030.go │ ├── sa4030_test.go │ └── testdata │ │ ├── go1.0 │ │ └── CheckIneffectiveRandInt │ │ │ └── CheckIneffectiveRandInt.go │ │ └── go1.22 │ │ └── CheckIneffectiveRandInt │ │ └── CheckIneffectiveRandInt.go ├── sa4031 │ ├── sa4031.go │ ├── sa4031_test.go │ └── testdata │ │ └── go1.0 │ │ └── CheckAllocationNilCheck │ │ └── CheckAllocationNilCheck.go ├── sa4032 │ ├── sa4032.go │ ├── sa4032_test.go │ └── testdata │ │ └── go1.0 │ │ └── CheckGOOSComparison │ │ ├── complex.go │ │ ├── f_linux.go │ │ ├── f_unix.go │ │ ├── f_windows.go │ │ ├── other.go │ │ ├── tlinux.go │ │ ├── tunix.go │ │ ├── twindows.go │ │ └── unknown.go ├── sa5000 │ ├── sa5000.go │ ├── sa5000_test.go │ └── testdata │ │ └── go1.0 │ │ └── CheckNilMaps │ │ └── CheckNilMaps.go ├── sa5001 │ ├── sa5001.go │ ├── sa5001_test.go │ └── testdata │ │ └── go1.0 │ │ └── CheckEarlyDefer │ │ └── CheckEarlyDefer.go ├── sa5002 │ ├── sa5002.go │ ├── sa5002_test.go │ └── testdata │ │ └── go1.0 │ │ └── CheckInfiniteEmptyLoop │ │ └── CheckInfiniteEmptyLoop.go ├── sa5003 │ ├── sa5003.go │ ├── sa5003_test.go │ └── testdata │ │ └── go1.0 │ │ └── CheckDeferInInfiniteLoop │ │ └── CheckDeferInInfiniteLoop.go ├── sa5004 │ ├── sa5004.go │ ├── sa5004_test.go │ └── testdata │ │ └── go1.0 │ │ └── CheckLoopEmptyDefault │ │ ├── CheckLoopEmptyDefault.go │ │ └── CheckLoopEmptyDefault.go.golden ├── sa5005 │ ├── sa5005.go │ ├── sa5005_test.go │ └── testdata │ │ └── go1.0 │ │ └── CheckCyclicFinalizer │ │ └── CheckCyclicFinalizer.go ├── sa5007 │ ├── sa5007.go │ ├── sa5007_test.go │ └── testdata │ │ └── go1.0 │ │ └── CheckInfiniteRecursion │ │ └── CheckInfiniteRecursion.go ├── sa5008 │ ├── sa5008.go │ ├── sa5008_test.go │ ├── structtag.go │ └── testdata │ │ ├── go1.0 │ │ ├── CheckStructTags │ │ │ └── CheckStructTags.go │ │ ├── CheckStructTags2 │ │ │ └── CheckStructTags2.go │ │ └── vendor │ │ │ └── github.com │ │ │ └── jessevdk │ │ │ └── go-flags │ │ │ └── pkg.go │ │ └── go1.18 │ │ └── CheckStructTags │ │ └── generics.go ├── sa5009 │ ├── sa5009.go │ ├── sa5009_test.go │ └── testdata │ │ └── go1.0 │ │ └── CheckPrintf │ │ └── CheckPrintf.go ├── sa5010 │ ├── sa5010.go │ ├── sa5010_test.go │ └── testdata │ │ ├── go1.0 │ │ └── CheckImpossibleTypeAssertion │ │ │ └── CheckImpossibleTypeAssertion.go │ │ └── go1.18 │ │ └── CheckImpossibleTypeAssertion │ │ └── CheckImpossibleTypeAssertion.go ├── sa5011 │ ├── sa5011.go │ ├── sa5011_test.go │ └── testdata │ │ ├── go1.0 │ │ └── CheckMaybeNil │ │ │ └── CheckMaybeNil.go │ │ └── go1.18 │ │ └── CheckMaybeNil │ │ └── generics.go ├── sa5012 │ ├── sa5012.go │ ├── sa5012_test.go │ └── testdata │ │ └── go1.0 │ │ └── CheckEvenSliceLength │ │ └── CheckEvenSliceLength.go ├── sa6000 │ ├── sa6000.go │ ├── sa6000_test.go │ └── testdata │ │ └── go1.0 │ │ └── CheckRegexpMatchLoop │ │ └── CheckRegexpMatchLoop.go ├── sa6001 │ ├── sa6001.go │ ├── sa6001_test.go │ └── testdata │ │ ├── go1.0 │ │ └── CheckMapBytesKey │ │ │ └── key.go │ │ └── go1.18 │ │ └── CheckMapBytesKey │ │ └── key_generics.go ├── sa6002 │ ├── sa6002.go │ ├── sa6002_test.go │ └── testdata │ │ └── go1.0 │ │ └── CheckSyncPoolValue │ │ └── CheckSyncPoolValue.go ├── sa6003 │ ├── sa6003.go │ ├── sa6003_test.go │ └── testdata │ │ ├── go1.0 │ │ └── CheckRangeStringRunes │ │ │ └── CheckRangeStringRunes.go │ │ └── go1.18 │ │ └── CheckRangeStringRunes │ │ └── generics.go ├── sa6005 │ ├── sa6005.go │ ├── sa6005_test.go │ └── testdata │ │ └── go1.0 │ │ └── CheckToLowerToUpperComparison │ │ ├── CheckToLowerToUpperComparison.go │ │ └── CheckToLowerToUpperComparison.go.golden ├── sa6006 │ ├── sa6006.go │ ├── sa6006_test.go │ └── testdata │ │ └── go1.0 │ │ └── CheckByteSliceInIOWriteString │ │ └── CheckByteSliceInIOWriteString.go ├── sa9001 │ ├── sa9001.go │ ├── sa9001_test.go │ └── testdata │ │ ├── go1.0 │ │ └── CheckDubiousDeferInChannelRangeLoop │ │ │ └── CheckDubiousDeferInChannelRangeLoop.go │ │ └── go1.18 │ │ └── CheckDubiousDeferInChannelRangeLoop │ │ └── generics.go ├── sa9002 │ ├── sa9002.go │ ├── sa9002_test.go │ └── testdata │ │ └── go1.0 │ │ └── CheckNonOctalFileMode │ │ ├── CheckNonOctalFileMode.go │ │ └── CheckNonOctalFileMode.go.golden ├── sa9003 │ ├── sa9003.go │ ├── sa9003_test.go │ └── testdata │ │ └── go1.0 │ │ └── CheckEmptyBranch │ │ ├── CheckEmptyBranch.go │ │ ├── CheckEmptyBranch_generated.go │ │ └── CheckEmptyBranch_test.go ├── sa9004 │ ├── sa9004.go │ ├── sa9004_test.go │ └── testdata │ │ └── go1.0 │ │ └── CheckMissingEnumTypesInDeclaration │ │ ├── CheckMissingEnumTypesInDeclaration.go │ │ └── CheckMissingEnumTypesInDeclaration.go.golden ├── sa9005 │ ├── sa9005.go │ ├── sa9005_test.go │ └── testdata │ │ └── go1.0 │ │ └── CheckNoopMarshal │ │ └── CheckNoopMarshal.go ├── sa9006 │ ├── sa9006.go │ ├── sa9006_test.go │ └── testdata │ │ └── go1.0 │ │ └── CheckStaticBitShift │ │ └── CheckStaticBitShift.go ├── sa9007 │ ├── sa9007.go │ ├── sa9007_test.go │ └── testdata │ │ └── go1.0 │ │ └── CheckBadRemoveAll │ │ └── CheckBadRemoveAll.go ├── sa9008 │ ├── sa9008.go │ ├── sa9008_test.go │ └── testdata │ │ └── go1.0 │ │ └── CheckTypeAssertionShadowingElse │ │ └── CheckTypeAssertionShadowingElse.go └── sa9009 │ ├── sa9009.go │ ├── sa9009_test.go │ └── testdata │ └── go1.0 │ └── Directives │ └── pkg.go ├── structlayout └── layout.go ├── stylecheck ├── analysis.go ├── doc.go ├── st1000 │ ├── st1000.go │ ├── st1000_test.go │ └── testdata │ │ └── go1.0 │ │ ├── CheckPackageComment-1 │ │ └── CheckPackageComment-1.go │ │ ├── CheckPackageComment-2 │ │ └── CheckPackageComment-2.go │ │ ├── CheckPackageComment-3 │ │ └── CheckPackageComment-3.go │ │ ├── CheckPackageComment-4 │ │ └── CheckPackageComment-4.go │ │ ├── CheckPackageComment-5 │ │ └── CheckPackageComment-5.go │ │ └── CheckPackageComment-6 │ │ └── CheckPackageComment-6.go ├── st1001 │ ├── st1001.go │ ├── st1001_test.go │ └── testdata │ │ └── go1.0 │ │ └── CheckDotImports │ │ ├── CheckDotImports.go │ │ └── CheckDotImports_test.go ├── st1003 │ ├── st1003.go │ ├── st1003_test.go │ └── testdata │ │ └── go1.0 │ │ ├── CheckNames │ │ └── CheckNames.go │ │ └── CheckNames_generated │ │ └── CheckNames_generated.go ├── st1005 │ ├── st1005.go │ ├── st1005_test.go │ └── testdata │ │ └── go1.0 │ │ └── CheckErrorStrings │ │ └── CheckErrorStrings.go ├── st1006 │ ├── st1006.go │ ├── st1006_test.go │ └── testdata │ │ └── go1.0 │ │ └── CheckReceiverNames │ │ └── CheckReceiverNames.go ├── st1008 │ ├── st1008.go │ ├── st1008_test.go │ └── testdata │ │ ├── go1.0 │ │ └── CheckErrorReturn │ │ │ └── CheckErrorReturn.go │ │ └── go1.9 │ │ └── CheckErrorReturn │ │ └── CheckErrorReturn.go ├── st1011 │ ├── st1011.go │ ├── st1011_test.go │ └── testdata │ │ └── go1.0 │ │ └── CheckTimeNames │ │ └── CheckTimeNames.go ├── st1012 │ ├── st1012.go │ ├── st1012_test.go │ └── testdata │ │ └── go1.0 │ │ └── CheckErrorVarNames │ │ └── CheckErrorVarNames.go ├── st1013 │ ├── st1013.go │ ├── st1013_test.go │ └── testdata │ │ └── go1.0 │ │ └── CheckHTTPStatusCodes │ │ ├── CheckHTTPStatusCodes.go │ │ └── CheckHTTPStatusCodes.go.golden ├── st1015 │ ├── st1015.go │ ├── st1015_test.go │ └── testdata │ │ └── go1.0 │ │ └── CheckDefaultCaseOrder │ │ └── CheckDefaultCaseOrder.go ├── st1016 │ ├── st1016.go │ ├── st1016_test.go │ └── testdata │ │ └── go1.0 │ │ └── CheckReceiverNamesIdentical │ │ ├── CheckReceiverNames.go │ │ └── generated.go ├── st1017 │ ├── st1017.go │ ├── st1017_test.go │ └── testdata │ │ └── go1.0 │ │ └── CheckYodaConditions │ │ ├── CheckYodaConditions.go │ │ └── CheckYodaConditions.go.golden ├── st1018 │ ├── st1018.go │ ├── st1018_test.go │ └── testdata │ │ └── go1.0 │ │ └── CheckInvisibleCharacters │ │ ├── CheckInvisibleCharacters.go │ │ └── CheckInvisibleCharacters.go.golden ├── st1019 │ ├── st1019.go │ ├── st1019_test.go │ └── testdata │ │ └── go1.0 │ │ └── CheckDuplicatedImports │ │ └── CheckDuplicatedImports.go ├── st1020 │ ├── st1020.go │ ├── st1020_test.go │ └── testdata │ │ ├── go1.0 │ │ └── CheckExportedFunctionDocs │ │ │ ├── CheckExportedFunctionDocs.go │ │ │ └── foo_test.go │ │ └── go1.18 │ │ └── CheckExportedFunctionDocs │ │ └── generics.go ├── st1021 │ ├── st1021.go │ ├── st1021_test.go │ └── testdata │ │ └── go1.0 │ │ └── CheckExportedTypeDocs │ │ └── CheckExportedTypeDocs.go ├── st1022 │ ├── st1022.go │ ├── st1022_test.go │ └── testdata │ │ └── go1.0 │ │ └── CheckExportedVarDocs │ │ └── CheckExportedVarDocs.go └── st1023 │ ├── st1023.go │ ├── st1023_test.go │ └── testdata │ └── go1.0 │ ├── CheckRedundantTypeInDeclaration │ ├── CheckRedundantTypeInDeclaration.go │ └── CheckRedundantTypeInDeclaration.go.golden │ └── CheckRedundantTypeInDeclaration_syscall │ └── CheckRedundantTypeInDeclaration_syscall.go ├── unused ├── implements.go ├── runtime.go ├── serialize.go ├── testdata │ └── src │ │ └── example.com │ │ ├── alias │ │ └── alias.go │ │ ├── anonymous │ │ └── anonymous.go │ │ ├── blank-function-parameter │ │ └── blank.go │ │ ├── blank │ │ └── blank.go │ │ ├── cgo │ │ └── cgo.go │ │ ├── constexpr │ │ └── constexpr.go │ │ ├── consts │ │ └── consts.go │ │ ├── conversion │ │ └── conversion.go │ │ ├── cyclic │ │ └── cyclic.go │ │ ├── defer │ │ └── defer.go │ │ ├── elem │ │ └── elem.go │ │ ├── embedded_call │ │ └── embedded_call.go │ │ ├── embedding-alias │ │ └── embedding-alias.go │ │ ├── embedding │ │ └── embedding.go │ │ ├── embedding2 │ │ └── embedding2.go │ │ ├── exported_fields │ │ └── exported_fields.go │ │ ├── exported_fields_main │ │ └── exported_fields_main.go │ │ ├── exported_method_test │ │ ├── exported_method.go │ │ └── exported_method_test.go │ │ ├── fields │ │ ├── fields.go │ │ └── fields_go123.go │ │ ├── functions │ │ └── functions.go │ │ ├── generated │ │ ├── generated.go │ │ └── normal.go │ │ ├── generic-interfaces │ │ └── generic-interfaces.go │ │ ├── ignored │ │ ├── ignored.go │ │ ├── ignored2.go │ │ ├── ignored3.go │ │ └── ignored4.go │ │ ├── implicit-conversion │ │ └── implicit-conversion.go │ │ ├── increment │ │ ├── increment.go │ │ └── increment_test.go │ │ ├── index-write │ │ └── write.go │ │ ├── initializers │ │ └── initializers.go │ │ ├── instantiated-functions │ │ └── instantiated-functions.go │ │ ├── interfaces │ │ └── interfaces.go │ │ ├── interfaces2 │ │ └── interfaces.go │ │ ├── issue1289 │ │ └── issue1289.go │ │ ├── linkname │ │ └── linkname.go │ │ ├── local-type-param-sink │ │ └── typeparam.go │ │ ├── local-type-param-source │ │ └── typeparam.go │ │ ├── main │ │ └── main.go │ │ ├── mapslice │ │ └── mapslice.go │ │ ├── methods │ │ └── methods.go │ │ ├── named │ │ └── named.go │ │ ├── nested │ │ └── nested.go │ │ ├── nocopy-main │ │ ├── nocopy-main.go │ │ └── stub.go │ │ ├── nocopy │ │ └── nocopy.go │ │ ├── parens │ │ └── parens.go │ │ ├── pointer-type-embedding │ │ └── pointer-type-embedding.go │ │ ├── pointers │ │ └── pointers.go │ │ ├── quiet │ │ └── quiet.go │ │ ├── selectors │ │ └── selectors.go │ │ ├── skipped-test │ │ └── skipped_test.go │ │ ├── switch_interface │ │ └── switch_interface.go │ │ ├── tests-main │ │ ├── main.go │ │ └── main_test.go │ │ ├── tests │ │ ├── tests.go │ │ └── tests_test.go │ │ ├── type-dedup │ │ └── dedup.go │ │ ├── type-dedup2 │ │ └── dedup.go │ │ ├── type-dedup3 │ │ └── dedup.go │ │ ├── typeparams │ │ ├── typeparams.go │ │ └── typeparams_17.go │ │ ├── types │ │ └── types.go │ │ ├── unsafe-recursive │ │ └── conversion.go │ │ ├── unused-argument │ │ └── unused-argument.go │ │ ├── unused_type │ │ └── unused_type.go │ │ └── variables │ │ ├── variables.go │ │ └── vartype.go ├── unused.go └── unused_test.go └── website ├── archetypes └── default.md ├── assets ├── js │ └── base.js └── scss │ ├── _styles_project.scss │ └── _variables_project.scss ├── build.sh ├── cmd ├── generate_checks │ └── generate_checks.go └── generate_config │ └── generate_config.go ├── config.toml ├── content ├── _index.md ├── changes │ ├── 2017.2.md │ ├── 2019.1.md │ ├── 2019.2.md │ ├── 2020.1.md │ ├── 2020.2.md │ ├── 2021.1.md │ ├── 2022.1.md │ ├── 2023.1.md │ ├── 2024.1.md │ ├── 2025.1.md │ └── _index.md ├── contact.md ├── docs │ ├── _index.md │ ├── changes.md │ ├── checks.html │ ├── configuration │ │ ├── _index.md │ │ └── options.md │ ├── faq.md │ ├── getting-started.md │ └── running-staticcheck │ │ ├── _index.md │ │ ├── ci │ │ ├── _index.md │ │ └── github-actions │ │ │ └── index.md │ │ ├── cli │ │ ├── _index.md │ │ ├── build-tags │ │ │ └── index.md │ │ └── formatters.md │ │ └── editors.md └── sponsors.md ├── go.mod ├── go.sum ├── layouts ├── _internal │ └── twitter_cards.html ├── changes │ └── list.rss.xml ├── index.redir ├── partials │ ├── breadcrumb.html │ ├── footer.html │ ├── hooks │ │ └── head-end.html │ └── navbar.html └── shortcodes │ ├── check.html │ ├── commit.html │ ├── content.html │ ├── details.html │ ├── faq │ ├── list.html │ └── question.md │ ├── issue.html │ ├── issueref.html │ └── option.html ├── package-lock.json ├── package.json ├── shell.nix ├── static ├── _headers └── img │ ├── logo.svg │ └── logo.webp └── website.go /.gitattributes: -------------------------------------------------------------------------------- 1 | *.golden -text 2 | *.svg binary 3 | **/testdata/** -text 4 | -------------------------------------------------------------------------------- /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | patreon: dominikh 2 | github: dominikh 3 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/4_other.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: 🛠 Other 3 | about: Ideas, feature requests, and all other issues not fitting into another category. 4 | labels: needs-triage 5 | title: "" 6 | --- 7 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/config.yml: -------------------------------------------------------------------------------- 1 | blank_issues_enabled: false 2 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /cmd/keyify/keyify 2 | /cmd/staticcheck/staticcheck 3 | /cmd/structlayout-optimize/structlayout-optimize 4 | /cmd/structlayout-pretty/structlayout-pretty 5 | /cmd/structlayout/structlayout 6 | /dist/20??.?.?/ 7 | /dist/20??.?/ 8 | /internal/cmd/irdump/irdump 9 | /website/.hugo_build.lock 10 | /website/public 11 | /website/resources 12 | /website/assets/img/sponsors 13 | /website/data/sponsors.toml 14 | /website/data/copyrights.toml 15 | /website/data/checks.json 16 | /website/content/docs/configuration/default_config/index.md 17 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "website/themes/docsy"] 2 | path = website/themes/docsy 3 | url = https://github.com/google/docsy 4 | -------------------------------------------------------------------------------- /_benchmarks/silent-staticcheck.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | /home/dominikh/prj/src/honnef.co/go/tools/cmd/staticcheck/staticcheck -checks "all" -fail "" $1 &>/dev/null 3 | exit 0 4 | -------------------------------------------------------------------------------- /analysis/facts/deprecated/deprecated_test.go: -------------------------------------------------------------------------------- 1 | package deprecated 2 | 3 | import ( 4 | "testing" 5 | 6 | "golang.org/x/tools/go/analysis/analysistest" 7 | ) 8 | 9 | func TestDeprecated(t *testing.T) { 10 | analysistest.Run(t, analysistest.TestData(), Analyzer, "example.com/Deprecated") 11 | } 12 | -------------------------------------------------------------------------------- /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) (any, 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 | -------------------------------------------------------------------------------- /analysis/facts/nilness/nilness_test.go: -------------------------------------------------------------------------------- 1 | package nilness 2 | 3 | import ( 4 | "testing" 5 | 6 | "golang.org/x/tools/go/analysis/analysistest" 7 | ) 8 | 9 | func TestNilness(t *testing.T) { 10 | analysistest.Run(t, analysistest.TestData(), Analysis, "example.com/Nilness") 11 | } 12 | -------------------------------------------------------------------------------- /analysis/facts/purity/purity_test.go: -------------------------------------------------------------------------------- 1 | package purity 2 | 3 | import ( 4 | "testing" 5 | 6 | "golang.org/x/tools/go/analysis/analysistest" 7 | ) 8 | 9 | func TestPurity(t *testing.T) { 10 | analysistest.Run(t, analysistest.TestData(), Analyzer, "example.com/Purity") 11 | } 12 | -------------------------------------------------------------------------------- /analysis/facts/typedness/typedness_test.go: -------------------------------------------------------------------------------- 1 | package typedness 2 | 3 | import ( 4 | "testing" 5 | 6 | "golang.org/x/tools/go/analysis/analysistest" 7 | ) 8 | 9 | func TestTypedness(t *testing.T) { 10 | analysistest.Run(t, analysistest.TestData(), Analysis, "example.com/Typedness") 11 | } 12 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /doc/articles/customizing_staticcheck.html: -------------------------------------------------------------------------------- 1 | - how to customize staticcheck 2 | - tools serve humans 3 | - tools should assist workflows 4 | - don't let tools bully you 5 | 6 | - exit status 7 | - which checks run 8 | - ignoring findings 9 | - output format 10 | - go version 11 | - tests 12 | -------------------------------------------------------------------------------- /go.mod: -------------------------------------------------------------------------------- 1 | module honnef.co/go/tools 2 | 3 | go 1.23.0 4 | 5 | require ( 6 | github.com/BurntSushi/toml v1.4.1-0.20240526193622-a339e1f7089c 7 | golang.org/x/exp v0.0.0-20231110203233-9a3e6036ecaa 8 | golang.org/x/exp/typeparams v0.0.0-20231108232855-2478ac86f678 9 | golang.org/x/sys v0.33.0 10 | golang.org/x/tools v0.33.1-0.20250521210010-423c5afcceff 11 | ) 12 | 13 | require ( 14 | golang.org/x/mod v0.24.0 // indirect 15 | golang.org/x/sync v0.14.0 // indirect 16 | ) 17 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /go/ir/write.go: -------------------------------------------------------------------------------- 1 | package ir 2 | 3 | func NewJump(parent *BasicBlock) *Jump { 4 | return &Jump{anInstruction{block: parent}} 5 | } 6 | -------------------------------------------------------------------------------- /images/screenshots/struct.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dominikh/go-tools/bbc2f4dd71ea1dd1f0801fd7b7c4b7a22b9a90ba/images/screenshots/struct.png -------------------------------------------------------------------------------- /internal/passes/buildir/testdata/src/a/a.go: -------------------------------------------------------------------------------- 1 | package a 2 | 3 | func Fib(x int) int { 4 | if x < 2 { 5 | return x 6 | } 7 | return Fib(x-1) + Fib(x-2) 8 | } 9 | 10 | type T int 11 | 12 | func (T) fib(x int) int { return Fib(x) } 13 | 14 | func _() { 15 | print("hi") 16 | } 17 | 18 | func _() { 19 | print("hi") 20 | } 21 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /internal/testenv/UPSTREAM: -------------------------------------------------------------------------------- 1 | This package is a copy of golang.org/x/tools/internal/testenv, 2 | imported from commit 33e937220d8f91f1d242ad15aebc3e245aca5515. 3 | 4 | The last upstream commit we've looked at was: 414ec9c3f0ea84250efb8f18f51c607184b7631e 5 | -------------------------------------------------------------------------------- /knowledge/doc.go: -------------------------------------------------------------------------------- 1 | // Package knowledge contains manually collected information about Go APIs. 2 | package knowledge 3 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /pattern/testdata/fuzz/FuzzParse/0001cdcefc5f03f99c21d4ef8232d8f0d8510d9c48e8105c927bc70ac02034a9: -------------------------------------------------------------------------------- 1 | go test fuzz v1 2 | []byte("(AssignStmt ident \":=\" expr)") -------------------------------------------------------------------------------- /pattern/testdata/fuzz/FuzzParse/00ec3673b415e2f6fc4a3f0d31413096921fbd1faa1cbabdd3637480af027a72: -------------------------------------------------------------------------------- 1 | go test fuzz v1 2 | []byte("(CallExpr (SelectorExpr recv (Ident \"String\")) [])") -------------------------------------------------------------------------------- /pattern/testdata/fuzz/FuzzParse/02f183192c9bcfbb22db5afa08e5a9a84babfca022726d0121f42c68d3feecee: -------------------------------------------------------------------------------- 1 | go test fuzz v1 2 | []byte("go test fuzz v1\n[]byte(\"(CallExpr (Symbol \\\"math.Pow\\\") [x (IntegerLiteral n)])\")") -------------------------------------------------------------------------------- /pattern/testdata/fuzz/FuzzParse/05eea82b6791ec62e197e6128c608c67f5393ff98e94a9c1ba1311e763778749: -------------------------------------------------------------------------------- 1 | go test fuzz v1 2 | []byte("(Or________________________________________________________________________________________________________________________________)") 3 | -------------------------------------------------------------------------------- /pattern/testdata/fuzz/FuzzParse/06b3cbf8b7806ca08ce1ca466e83488ca32abb5db6b0ca4b07c54aa7be47adf3: -------------------------------------------------------------------------------- 1 | go test fuzz v1 2 | []byte("(CallExpr (SelectorExpr lhs (Ident \"Equal\")) rhs)") -------------------------------------------------------------------------------- /pattern/testdata/fuzz/FuzzParse/09c3a6a518c0e44fe60591523655ba4d7dcf62cb477f7e316a51e089adea74c2: -------------------------------------------------------------------------------- 1 | go test fuzz v1 2 | []byte("(AssignStmt x tok@(Or \"+=\" \"-=\") (BasicLit \"INT\" \"1\"))") -------------------------------------------------------------------------------- /pattern/testdata/fuzz/FuzzParse/0a21c29e926184ebb3c293c9cea3465ef5e1fc5c1b81be7d0770d5d69ee838a3: -------------------------------------------------------------------------------- 1 | go test fuzz v1 2 | []byte("\n\t\t(ForStmt\n\t\t\tnil nil nil\n\t\t\tselect@(SelectStmt\n\t\t\t\t(CommClause\n\t\t\t\t\t(Or\n\t\t\t\t\t\t(UnaryExpr \"<-\" _)\n\t\t\t\t\t\t(AssignStmt _ _ (UnaryExpr \"<-\" _)))\n\t\t\t\t\t_)))") -------------------------------------------------------------------------------- /pattern/testdata/fuzz/FuzzParse/0ce7ffb3713ec9373531b2903b8f8751e280cdae2b625dcf35dc1fcd88c592bf: -------------------------------------------------------------------------------- 1 | go test fuzz v1 2 | []byte("go test fuzz v1\n[]byte(\"\\n\\t(CallExpr\\n\\t\\tfn@(Or\\n\\t\\t\\t(Symbol \\\"fmt.Sprint\\\")\\n\\t\\t\\t(Symbol \\\"fmt.Sprintf\\\"))\\n\\t\\t[lit@(BasicLit \\\"STRING\\\" _)])\")") -------------------------------------------------------------------------------- /pattern/testdata/fuzz/FuzzParse/170704499ec0c05bf39fb37f6c5604e13624c4fb531e41305b2439308e370f35: -------------------------------------------------------------------------------- 1 | go test fuzz v1 2 | []byte("(CallExpr fun@(SelectorExpr _ (Ident \"Seek\")) [arg1@(SelectorExpr (Ident \"io\") (Ident (Or \"SeekStart\" \"SeekCurrent\" \"SeekEnd\"))) arg2])") -------------------------------------------------------------------------------- /pattern/testdata/fuzz/FuzzParse/1a3c741fba42577fac3c5035a3d44e5a78bcefa11f9ccc3bb2919376d984e4a2: -------------------------------------------------------------------------------- 1 | go test fuzz v1 2 | []byte("(BinaryExpr left@(TrulyConstantExpression _) tok@(Or \"==\" \"!=\") right@(Not (TrulyConstantExpression _)))") -------------------------------------------------------------------------------- /pattern/testdata/fuzz/FuzzParse/1eb6c2e8b8e0be47a019f0345b68ebfdba5f05804204e810166d1fe7c12e8556: -------------------------------------------------------------------------------- 1 | go test fuzz v1 2 | []byte("\n\t(IfStmt\n\t\tnil\n\t\t(BinaryExpr x@(Object _) \"!=\" (Builtin \"nil\"))\n\t\t[(RangeStmt _ _ _ x _)]\n\t\tnil)") -------------------------------------------------------------------------------- /pattern/testdata/fuzz/FuzzParse/27e5f99d63fed488c4e9c3ac4a1e364f809ad894cb109aacc9bd6a85c015fdb7: -------------------------------------------------------------------------------- 1 | go test fuzz v1 2 | []byte("(IfStmt nil cond [(ReturnStmt [ret@(Builtin (Or \"true\" \"false\"))])] nil)") -------------------------------------------------------------------------------- /pattern/testdata/fuzz/FuzzParse/2bac99d4a450641e3ae239588965c64323b1ee9eb2351cc53019d430d3a59efa: -------------------------------------------------------------------------------- 1 | go test fuzz v1 2 | []byte("go test fuzz v1\n[]byte(\"\\n\\t(CallExpr\\n\\t\\t(SelectorExpr recv (Ident \\\"Write\\\"))\\n\\t\\t(CallExpr (ArrayType nil (Ident \\\"byte\\\"))\\n\\t\\t\\t(CallExpr\\n\\t\\t\\t\\tfn@(Or\\n\\t\\t\\t\\t\\t(Symbol \\\"fmt.Sprint\\\")\\n\\t\\t\\t\\t\\t(Symbol \\\"fmt.Sprintf\\\")\\n\\t\\t\\t\\t\\t(Symbol \\\"fmt.Sprintln\\\"))\\n\\t\\t\\t\\targs)\\n\\t))\")") -------------------------------------------------------------------------------- /pattern/testdata/fuzz/FuzzParse/2c72a4a6b571446d5374dc5174fa44767bdcc8197e38c54738e50f8b58903230: -------------------------------------------------------------------------------- 1 | go test fuzz v1 2 | []byte("(CallExpr(Ident(SelectorExpr(Ident\"\")(Ident\"\")))[])") 3 | -------------------------------------------------------------------------------- /pattern/testdata/fuzz/FuzzParse/2f1cdb43e9c62bdb5f8777bc2cb4eee3e8fe173c4361f54833c48d06833ec8fe: -------------------------------------------------------------------------------- 1 | go test fuzz v1 2 | []byte("\n\t\t(IfStmt\n\t\t\tnil\n\t\t\t(BinaryExpr lhs@(Object _) \"!=\" (Builtin \"nil\"))\n\t\t\t[\n\t\t\t\tifstmt@(IfStmt\n\t\t\t\t\t(AssignStmt [(Ident \"_\") ok@(Object _)] _ [(TypeAssertExpr lhs _)])\n\t\t\t\t\tok\n\t\t\t\t\t_\n\t\t\t\t\tnil)\n\t\t\t]\n\t\t\tnil)") -------------------------------------------------------------------------------- /pattern/testdata/fuzz/FuzzParse/312c49b9d41ad52e7beaa65ab01f5416e4f4d1db78b4e0001260ac888256b609: -------------------------------------------------------------------------------- 1 | go test fuzz v1 2 | []byte("(CallExpr (Ident \"string\") [arg])") -------------------------------------------------------------------------------- /pattern/testdata/fuzz/FuzzParse/3148b044a5e00e508bfd9ac4d139e032503a590c36bd458a8291b77502d13561: -------------------------------------------------------------------------------- 1 | go test fuzz v1 2 | []byte("(AssignStmt x@(Object _) \":=\" assign@(Builtin b@(Or \"true\" \"false\")))") -------------------------------------------------------------------------------- /pattern/testdata/fuzz/FuzzParse/31ac2ece486bde345a4ac42fb989efa8835e72e82e357d5d82a313d6ba03eca2: -------------------------------------------------------------------------------- 1 | go test fuzz v1 2 | []byte("(ForStmt nil nil nil if@(IfStmt nil cond (BranchStmt \"BREAK\" nil) nil):_)") -------------------------------------------------------------------------------- /pattern/testdata/fuzz/FuzzParse/359bf5d248c22a3fc8d67de10279802663a767d4bf2d11dad3209bee13953ee0: -------------------------------------------------------------------------------- 1 | go test fuzz v1 2 | []byte("(CallExpr (Builtin \"make\") [typ size size])") -------------------------------------------------------------------------------- /pattern/testdata/fuzz/FuzzParse/3895395d667f576d7f3891a63e4cc0157b2ec73dbe55745c1cba65f31e8cc5db: -------------------------------------------------------------------------------- 1 | go test fuzz v1 2 | []byte("(CallExpr (SelectorExpr (CallExpr (SelectorExpr recv (Ident \"Query\")) []) (Ident meth)) _)") -------------------------------------------------------------------------------- /pattern/testdata/fuzz/FuzzParse/3a3ef35129ccc131fc582363751397ad5723fb8ae891c31eaa5ad86ba402a27e: -------------------------------------------------------------------------------- 1 | go test fuzz v1 2 | []byte("go test fuzz v1\n[]byte(\"(CallExpr (Symbol \\\"fmt.Sprintf\\\") [format arg])\")") -------------------------------------------------------------------------------- /pattern/testdata/fuzz/FuzzParse/3d78313ab191ebe8647428cd6d896208cb6dcfdd19eb87ae388315548176445a: -------------------------------------------------------------------------------- 1 | go test fuzz v1 2 | []byte("(UnaryExpr \"!\" expr@(BinaryExpr _ _ _))") -------------------------------------------------------------------------------- /pattern/testdata/fuzz/FuzzParse/3e0e018aca3103af7824d729c88c028b8e0d60d3de223c786f46acac3e910cdb: -------------------------------------------------------------------------------- 1 | go test fuzz v1 2 | []byte("\n\t(IfStmt\n\t\t(AssignStmt\n\t\t\t[(Ident \"_\") ok@(Ident _)]\n\t\t\t\":=\"\n\t\t\t(IndexExpr m key))\n\t\tok\n\t\t[call@(CallExpr (Builtin \"delete\") [m key])]\n\t\tnil)") -------------------------------------------------------------------------------- /pattern/testdata/fuzz/FuzzParse/3f66b015db9a62175f277eab5f76a62397c681b7e4ed6564f452e6159d4cb454: -------------------------------------------------------------------------------- 1 | go test fuzz v1 2 | []byte("\n\t\t(AssignStmt\n\t\t\t(Ident \"_\") _ recv@(UnaryExpr \"<-\" _))") -------------------------------------------------------------------------------- /pattern/testdata/fuzz/FuzzParse/4115b01752356dd12fd6499da369daec6031f62d315aecc4afad56c97f61b904: -------------------------------------------------------------------------------- 1 | go test fuzz v1 2 | []byte("(BinaryExpr duration \"*\" (SelectorExpr (Ident \"time\") (Ident \"Second\")))") -------------------------------------------------------------------------------- /pattern/testdata/fuzz/FuzzParse/465963a68302ca54f21c75fc3f680d6a5e1065682fb05a1350ed105883436a82: -------------------------------------------------------------------------------- 1 | go test fuzz v1 2 | []byte("(CallExpr (SelectorExpr (Ident \"bytes\") (Ident \"Equal\")) args)") -------------------------------------------------------------------------------- /pattern/testdata/fuzz/FuzzParse/47857edd56b46ac9c16e788e9295d1dafb910c345899aafd618ddaa12793f4f9: -------------------------------------------------------------------------------- 1 | go test fuzz v1 2 | []byte("go test fuzz v1\n[]byte(\"(CallExpr (Symbol \\\"errors.New\\\") [(CallExpr (Symbol \\\"fmt.Sprintf\\\") args)])\")") -------------------------------------------------------------------------------- /pattern/testdata/fuzz/FuzzParse/4dec90e6083b5e195501df63d8e1ed6813b623bef60ad8d9e0a1df1f251a58f3: -------------------------------------------------------------------------------- 1 | go test fuzz v1 2 | []byte("go test fuzz v1\n[]byte(\"\\n\\t(CallExpr\\n\\t\\t(Symbol\\n\\t\\t\\tname@(Or\\n\\t\\t\\t\\t\\\"math/rand.Int31n\\\"\\n\\t\\t\\t\\t\\\"math/rand.Int63n\\\"\\n\\t\\t\\t\\t\\\"math/rand.Intn\\\"\\n\\t\\t\\t\\t\\\"(*math/rand.Rand).Int31n\\\"\\n\\t\\t\\t\\t\\\"(*math/rand.Rand).Int63n\\\"\\n\\t\\t\\t\\t\\\"(*math/rand.Rand).Intn\\\"))\\n\\t\\t[(IntegerLiteral \\\"1\\\")])\")") -------------------------------------------------------------------------------- /pattern/testdata/fuzz/FuzzParse/51390f40de42348adb99c613cd8367db404851ce3ea1a4e02ea316b5b7e915b7: -------------------------------------------------------------------------------- 1 | go test fuzz v1 2 | []byte("\n\t\t(ForStmt\n\t\t\t(AssignStmt initvar@(Ident _) _ (IntegerLiteral \"0\"))\n\t\t\t(BinaryExpr initvar \"<\" limit@(Ident _))\n\t\t\t(IncDecStmt initvar \"++\")\n\t\t\t[(AssignStmt\n\t\t\t\t(IndexExpr slice@(Ident _) initvar)\n\t\t\t\t\"=\"\n\t\t\t\t(IndexExpr slice (BinaryExpr offset@(Ident _) \"+\" initvar)))])") -------------------------------------------------------------------------------- /pattern/testdata/fuzz/FuzzParse/53da8fdd88cd66de33bbdbbf564e2b14b69d02f32102d8a96171ed4b05dbc92e: -------------------------------------------------------------------------------- 1 | go test fuzz v1 2 | []byte("go test fuzz v1\n[]byte(\"\\n\\t\\t(CallExpr\\n\\t\\t\\t(Symbol\\n\\t\\t\\t\\t(Or\\n\\t\\t\\t\\t\\t\\\"log.Fatal\\\"\\n\\t\\t\\t\\t\\t\\\"log.Fatalln\\\"\\n\\t\\t\\t\\t\\t\\\"log.Panic\\\"\\n\\t\\t\\t\\t\\t\\\"log.Panicln\\\"\\n\\t\\t\\t\\t\\t\\\"log.Print\\\"\\n\\t\\t\\t\\t\\t\\\"log.Println\\\"))\\n\\t\\t\\t[(CallExpr (Symbol \\\"fmt.Sprintf\\\") args)])\")") -------------------------------------------------------------------------------- /pattern/testdata/fuzz/FuzzParse/56a234ae7b32577f770d5b997f037de709344d7be6fd9ca6e1f44fc8c4367f5b: -------------------------------------------------------------------------------- 1 | go test fuzz v1 2 | []byte("(ForStmt a a a(IfStmt a b(BranchStmt nil a)a):a)") 3 | -------------------------------------------------------------------------------- /pattern/testdata/fuzz/FuzzParse/5cc91809f9225a218b9cfb3a31d5baed3c5a44b5da3a74184fa97abe3bbf178f: -------------------------------------------------------------------------------- 1 | go test fuzz v1 2 | []byte("(CallExpr (SelectorExpr (Ident \"time\") (Ident \"Since\")) [arg])") -------------------------------------------------------------------------------- /pattern/testdata/fuzz/FuzzParse/5d9a745f26174c61e5ab0966e4821f75b71de80345be52d4b81aa1515158b735: -------------------------------------------------------------------------------- 1 | go test fuzz v1 2 | []byte("(BinaryExpr\n\t\t(UnaryExpr \"&\" _)\n\t\t(Or \"==\" \"!=\")\n\t\t(Builtin \"nil\"))") -------------------------------------------------------------------------------- /pattern/testdata/fuzz/FuzzParse/5e8383a425cf9bc34f43d60f7586184ae7a544e3ad10405ef7aca57246c2ab66: -------------------------------------------------------------------------------- 1 | go test fuzz v1 2 | []byte("go test fuzz v1\n[]byte(\"\\n\\t(BinaryExpr\\n\\t\\t(CallExpr fun@(Symbol (Or \\\"strings.ToLower\\\" \\\"strings.ToUpper\\\")) [a])\\n \\t\\ttok@(Or \\\"==\\\" \\\"!=\\\")\\n \\t\\t(CallExpr fun [b]))\")") -------------------------------------------------------------------------------- /pattern/testdata/fuzz/FuzzParse/60c36a14214281c0c2c31599563afec69016f469a0f25222a9500e307b159d11: -------------------------------------------------------------------------------- 1 | go test fuzz v1 2 | []byte("(Or[a a])") 3 | -------------------------------------------------------------------------------- /pattern/testdata/fuzz/FuzzParse/614ea1474d223cb45716d531aa8afac2dfd52938aeb38c64b70a351f0cf509b2: -------------------------------------------------------------------------------- 1 | go test fuzz v1 2 | []byte("go test fuzz v1\n[]byte(\"(CallExpr (SelectorExpr (CallExpr (Symbol \\\"time.Now\\\") []) (Symbol \\\"(time.Time).Sub\\\")) [arg])\")") -------------------------------------------------------------------------------- /pattern/testdata/fuzz/FuzzParse/6490b1471fef1f39: -------------------------------------------------------------------------------- 1 | go test fuzz v1 2 | []byte("(Or_:)E)") 3 | -------------------------------------------------------------------------------- /pattern/testdata/fuzz/FuzzParse/6a4d6ea339df8f59816483834329cc4310816de0223bd3607b2af6c91367a59b: -------------------------------------------------------------------------------- 1 | go test fuzz v1 2 | []byte("\n\t\t(AssignStmt\n\t\t\t[_ (Ident \"_\")]\n\t\t\t_\n\t\t\t(Or\n\t\t\t\t(IndexExpr _ _)\n\t\t\t\t(UnaryExpr \"<-\" _))) ") -------------------------------------------------------------------------------- /pattern/testdata/fuzz/FuzzParse/6aa9975401e9a24c46284ea6ea1740740fc58950a021c56e1376c2e108ee3b90: -------------------------------------------------------------------------------- 1 | go test fuzz v1 2 | []byte("(CallExpr (SelectorExpr recv (Ident \"Bytes\")) [])") -------------------------------------------------------------------------------- /pattern/testdata/fuzz/FuzzParse/6fa1e1e283fd220866a9e5878510db574b761fbd5a0e863e66f40fd4acbbaf07: -------------------------------------------------------------------------------- 1 | go test fuzz v1 2 | []byte("go test fuzz v1\n[]byte(\"(SelectStmt (CommClause (UnaryExpr \\\"<-\\\" (CallExpr (Symbol \\\"time.After\\\") [arg])) body))\")") -------------------------------------------------------------------------------- /pattern/testdata/fuzz/FuzzParse/71e2fa0db72c309e630267beac45c90d37e4b8f9d2d2ed52100d1abca7b72965: -------------------------------------------------------------------------------- 1 | go test fuzz v1 2 | []byte("\n\t(Or\n\t\t(UnaryExpr\n\t\t\t\"-\"\n\t\t\t(BasicLit \"FLOAT\" \"0.0\"))\n\n\t\t(UnaryExpr\n\t\t\t\"-\"\n\t\t\t(CallExpr conv@(Object (Or \"float32\" \"float64\")) lit@(Or (BasicLit \"INT\" \"0\") (BasicLit \"FLOAT\" \"0.0\"))))\n\n\t\t(CallExpr\n\t\t\tconv@(Object (Or \"float32\" \"float64\"))\n\t\t\t(UnaryExpr \"-\" lit@(BasicLit \"INT\" \"0\"))))") -------------------------------------------------------------------------------- /pattern/testdata/fuzz/FuzzParse/78eaf491672242d08770ab22b67853f639c767f65346de39c6f3e677b1cd879d: -------------------------------------------------------------------------------- 1 | go test fuzz v1 2 | []byte("(UnaryExpr \"&\" (StarExpr obj))") -------------------------------------------------------------------------------- /pattern/testdata/fuzz/FuzzParse/7ba6359207886a1c2c7bbe254835555e87a037ecd3af0301a11a43ec2287c487: -------------------------------------------------------------------------------- 1 | go test fuzz v1 2 | []byte("go test fuzz v1\n[]byte(\"(CallExpr fun@(Symbol _) (Builtin \\\"nil\\\"):_)\")") -------------------------------------------------------------------------------- /pattern/testdata/fuzz/FuzzParse/7ec87621ab148929b69125a04edd13ff104007ca0d8dff12f281753ea93ffb80: -------------------------------------------------------------------------------- 1 | go test fuzz v1 2 | []byte("go test fuzz v1\n[]byte(\"(BinaryExpr (CallExpr (Symbol \\\"bytes.Compare\\\") args) op@(Or \\\"==\\\" \\\"!=\\\") (IntegerLiteral \\\"0\\\"))\")") -------------------------------------------------------------------------------- /pattern/testdata/fuzz/FuzzParse/8203d4ee0690ca0d0c4b907e1f1c8d6c1724c4771ec3a685b56b440f52b4282a: -------------------------------------------------------------------------------- 1 | go test fuzz v1 2 | []byte("(BinaryExpr _ \"%\" (IntegerLiteral \"1\"))") -------------------------------------------------------------------------------- /pattern/testdata/fuzz/FuzzParse/8324b925e52410ab88b6265538881346436b67d95ad808b8f9220a84b0772ab7: -------------------------------------------------------------------------------- 1 | go test fuzz v1 2 | []byte("\n\t\t(IfStmt\n\t\t\t(AssignStmt [(Ident \"_\") ok@(Object _)] _ [(TypeAssertExpr assert@(Object _) _)])\n\t\t\t(Or\n\t\t\t\t(BinaryExpr ok \"&&\" (BinaryExpr assert \"!=\" (Builtin \"nil\")))\n\t\t\t\t(BinaryExpr (BinaryExpr assert \"!=\" (Builtin \"nil\")) \"&&\" ok))\n\t\t\t_\n\t\t\t_)") -------------------------------------------------------------------------------- /pattern/testdata/fuzz/FuzzParse/84e67732ffe4ba2d8fdb8cfc8690804579623dbc9c56a378ca483f088348296a: -------------------------------------------------------------------------------- 1 | go test fuzz v1 2 | []byte("(ReturnStmt [ret@(Builtin (Or \"true\" \"false\"))])") -------------------------------------------------------------------------------- /pattern/testdata/fuzz/FuzzParse/87839b3497143dd5ea14963b78c011edceb40d13fe1d8cd9b894a81b5dae2200: -------------------------------------------------------------------------------- 1 | go test fuzz v1 2 | []byte("(CallExpr (Builtin \"make\") [typ size@(IntegerLiteral \"0\")])") -------------------------------------------------------------------------------- /pattern/testdata/fuzz/FuzzParse/87f42498d6f57dc40c9972487f0e35d9820acbbce6cf61f3b90dabaa9cb8a8fc: -------------------------------------------------------------------------------- 1 | go test fuzz v1 2 | []byte("(AssignStmt[a(Ident\"_\")]a(Or(IndexExpr_a)(UnaryExpr\"\"a)))") 3 | -------------------------------------------------------------------------------- /pattern/testdata/fuzz/FuzzParse/90a846c5b88ccf4fe765113a3580ecc90a5cf083a97f0bc4b3bb53a1f00e3fd8: -------------------------------------------------------------------------------- 1 | go test fuzz v1 2 | []byte("(SliceExpr x@(Object _) low (CallExpr (Builtin \"len\") [x]) nil)") -------------------------------------------------------------------------------- /pattern/testdata/fuzz/FuzzParse/9437b751fb0f1f07f5dcb8c8a10d0f3d4470a77b7ec77df6be872a109184bd1b: -------------------------------------------------------------------------------- 1 | go test fuzz v1 2 | []byte("go test fuzz v1\n[]byte(\"(CallExpr (Symbol \\\"time.Sleep\\\") lit@(IntegerLiteral value))\")") -------------------------------------------------------------------------------- /pattern/testdata/fuzz/FuzzParse/94b7dc35d595dd794b4f65cd35f94ae8fe7c7214e6da8caa69f0b841e9a099af: -------------------------------------------------------------------------------- 1 | go test fuzz v1 2 | []byte("(CallExpr _ [(CallExpr sel@(SelectorExpr recv _) [])])") -------------------------------------------------------------------------------- /pattern/testdata/fuzz/FuzzParse/a3b8af4d027db37d44e58995ed2ab3cd9f2cb415669287e9e7ce7186534b4b1f: -------------------------------------------------------------------------------- 1 | go test fuzz v1 2 | []byte("(CallExpr (SelectorExpr (Ident \"time\") (Ident \"Until\")) [arg])") -------------------------------------------------------------------------------- /pattern/testdata/fuzz/FuzzParse/aa520290f4868dc3c01f15d2769941654a404b87327f5dde790c99fc2c63d875: -------------------------------------------------------------------------------- 1 | go test fuzz v1 2 | []byte("(IfStmt (AssignStmt [obj@(Ident _) ok@(Ident _)] \":=\" assert@(TypeAssertExpr obj _)) ok _ elseBranch)") -------------------------------------------------------------------------------- /pattern/testdata/fuzz/FuzzParse/ac1b69c690b399207dd7fe32f03a12d2731fa2d1704f6b15cfdc7f772b0f3187: -------------------------------------------------------------------------------- 1 | go test fuzz v1 2 | []byte("go test fuzz v1\n[]byte(\"\\n\\t(CallExpr\\n\\t\\t(SelectorExpr recv (Ident \\\"WriteString\\\"))\\n\\t\\t(CallExpr\\n\\t\\t\\tfn@(Or\\n\\t\\t\\t\\t(Symbol \\\"fmt.Sprint\\\")\\n\\t\\t\\t\\t(Symbol \\\"fmt.Sprintf\\\")\\n\\t\\t\\t\\t(Symbol \\\"fmt.Sprintln\\\"))\\n\\t\\t\\targs))\")") -------------------------------------------------------------------------------- /pattern/testdata/fuzz/FuzzParse/ad86b3632aca0a27fef3d6d79de5c2bcf1c21f7a6caa1260aab964edc21f3f65: -------------------------------------------------------------------------------- 1 | go test fuzz v1 2 | []byte("go test fuzz v1\n[]byte(\"\\n\\t(GoStmt\\n\\t\\t(CallExpr\\n\\t\\t\\t(FuncLit\\n\\t\\t\\t\\t_\\n\\t\\t\\t\\tcall@(CallExpr (Symbol \\\"(*sync.WaitGroup).Add\\\") _):_) _))\")") -------------------------------------------------------------------------------- /pattern/testdata/fuzz/FuzzParse/af10598249def731ec19ebffa3cbc464892d0e445dbefab9ccf578eae136236a: -------------------------------------------------------------------------------- 1 | go test fuzz v1 2 | []byte("(IntegerLiteral tv)") -------------------------------------------------------------------------------- /pattern/testdata/fuzz/FuzzParse/b44bceab2d84f09950aa80d8541c18e31a3d5dde6e874fd0bfe2e4ce54606db0: -------------------------------------------------------------------------------- 1 | go test fuzz v1 2 | []byte("(AssignStmt a a@(Or\"0\"\"0\")(BasicLit\"000\"\"\"))") 3 | -------------------------------------------------------------------------------- /pattern/testdata/fuzz/FuzzParse/b553c9e015253a9e3d4e202fdb2d90764151e24219f26f7510a433d30323666e: -------------------------------------------------------------------------------- 1 | go test fuzz v1 2 | []byte("\n\t(Or\n\t\t(BinaryExpr\n\t\t\t(IntegerLiteral \"0\")\n\t\t\t\">\"\n\t\t\t(CallExpr builtin@(Builtin (Or \"len\" \"cap\")) _))\n\t\t(BinaryExpr\n\t\t\t(CallExpr builtin@(Builtin (Or \"len\" \"cap\")) _)\n\t\t\t\"<\"\n\t\t\t(IntegerLiteral \"0\")))\n") -------------------------------------------------------------------------------- /pattern/testdata/fuzz/FuzzParse/b6a22c4a4f5e0cf4a291f2d6f03860631075934e4069959665d1f8097c69d0d0: -------------------------------------------------------------------------------- 1 | go test fuzz v1 2 | []byte("(UnaryExpr \"!\" (CallExpr (SelectorExpr (Ident \"bytes\") (Ident \"Equal\")) args))") -------------------------------------------------------------------------------- /pattern/testdata/fuzz/FuzzParse/ba95d1477ea1b35a949c6b469077d908b1cbcaf7fbf3ce9ef544bfeb24f877fb: -------------------------------------------------------------------------------- 1 | go test fuzz v1 2 | []byte("(BinaryExpr duration \"*\" (SelectorExpr (Ident \"time\") (Ident \"Nanosecond\")))") -------------------------------------------------------------------------------- /pattern/testdata/fuzz/FuzzParse/bb62ca358e19867f7d31400cb2a65aac1e918308212c43d10cca21feeb9c99d2: -------------------------------------------------------------------------------- 1 | go test fuzz v1 2 | []byte("\n\t\t(TypeSwitchStmt\n\t\t\tnil\n\t\t\texpr@(TypeAssertExpr ident@(Ident _) _)\n\t\t\tbody)") -------------------------------------------------------------------------------- /pattern/testdata/fuzz/FuzzParse/c1a2c8141751527604100e865db8d0e711ce25fc5c291b7702752496ac4b2546: -------------------------------------------------------------------------------- 1 | go test fuzz v1 2 | []byte("(CallExpr fun [arg2 arg1])") -------------------------------------------------------------------------------- /pattern/testdata/fuzz/FuzzParse/c30ca6d4801d71144c641960df6919115149d2b6fae5f7d9b2bac2b8cd6b8d25: -------------------------------------------------------------------------------- 1 | go test fuzz v1 2 | []byte("go test fuzz v1\n[]byte(\"(AssignStmt target@(Ident _) \\\"=\\\" (CallExpr typ@(Symbol (Or \\\"sort.Float64Slice\\\" \\\"sort.IntSlice\\\" \\\"sort.StringSlice\\\")) [target]))\")") -------------------------------------------------------------------------------- /pattern/testdata/fuzz/FuzzParse/c5f48734d853b82016955671d916daaf72da20a5f8335dddf7640fab1f5a3acb: -------------------------------------------------------------------------------- 1 | go test fuzz v1 2 | []byte("(BinaryExpr right tok left)") -------------------------------------------------------------------------------- /pattern/testdata/fuzz/FuzzParse/c6d06d254dee12276b9b46ef9be863a1eefc4d0673946a706ec7a164625595f0: -------------------------------------------------------------------------------- 1 | go test fuzz v1 2 | []byte("(SelectStmt (CommClause _ _))") -------------------------------------------------------------------------------- /pattern/testdata/fuzz/FuzzParse/c7abb7fc60634bb8d57b5b7c225a6accf0d2eb56c88bfe5e44cdd3e0c3e29666: -------------------------------------------------------------------------------- 1 | go test fuzz v1 2 | []byte("(IfStmt _ cond@(BinaryExpr lhs op@(Or \"==\" \"!=\") (Builtin \"nil\")) _ _)") -------------------------------------------------------------------------------- /pattern/testdata/fuzz/FuzzParse/ca92b01f6dbdcb91e335219081aa48c16893c217bf6edc020fcb78b3ebabcd1f: -------------------------------------------------------------------------------- 1 | go test fuzz v1 2 | []byte("(BinaryExpr (IntegerLiteral _) \"/\" (IntegerLiteral _))") -------------------------------------------------------------------------------- /pattern/testdata/fuzz/FuzzParse/e027a03ee012e289def51d770ead1e8a136b60989d3d1fb9388a394da2f595da: -------------------------------------------------------------------------------- 1 | go test fuzz v1 2 | []byte("go test fuzz v1\n[]byte(\"(CallExpr (Symbol \\\"(time.Time).Sub\\\") [(CallExpr (Symbol \\\"time.Now\\\") [])])\")") -------------------------------------------------------------------------------- /pattern/testdata/fuzz/FuzzParse/e1e59b9e6718f5089e98c955c391d38c7e243495ece9598826492ab734e5171f: -------------------------------------------------------------------------------- 1 | go test fuzz v1 2 | []byte("(CallExpr (Builtin \"append\") [_])") -------------------------------------------------------------------------------- /pattern/testdata/fuzz/FuzzParse/e43aa6da655e6c326cfb1f8c9970b603411caf262af4a50980c5a5987ee696f3: -------------------------------------------------------------------------------- 1 | go test fuzz v1 2 | []byte("(IfStmt nil cond [(AssignStmt x@(Object _) \"=\" (Builtin b@(Or \"true\" \"false\")))] nil)") -------------------------------------------------------------------------------- /pattern/testdata/fuzz/FuzzParse/e48990bfca21324ab7a29098b9a4b40fbd22bd5adcfa316b4b8af460a232b638: -------------------------------------------------------------------------------- 1 | go test fuzz v1 2 | []byte("(CallExpr (SelectorExpr (Ident \"strings\") (Ident \"EqualFold\")) [a b])") -------------------------------------------------------------------------------- /pattern/testdata/fuzz/FuzzParse/eb0ecf0066fdafbe218a736d3fc071a52408311637cc527db239f110418e8616: -------------------------------------------------------------------------------- 1 | go test fuzz v1 2 | []byte("(StarExpr (UnaryExpr \"&\" _))") -------------------------------------------------------------------------------- /pattern/testdata/fuzz/FuzzParse/ed6769b59df864327fba2b109f0cb965e5b8a6e5f1085e36f5635f1d65003a00: -------------------------------------------------------------------------------- 1 | go test fuzz v1 2 | []byte("\n\t\t(CallExpr\n\t\t\t(Ident \"copy\")\n\t\t\t[(SliceExpr slice nil limit nil)\n\t\t\t\t(SliceExpr slice offset nil nil)])") -------------------------------------------------------------------------------- /pattern/testdata/fuzz/FuzzParse/f640eee2b04d1b52793ba88998a86702893e23d2563d017be9be90efc04a43c6: -------------------------------------------------------------------------------- 1 | go test fuzz v1 2 | []byte("(Or (BasicLit \"INT\" _) (UnaryExpr (Or \"+\" \"-\") (IntegerLiteral _)))") -------------------------------------------------------------------------------- /pattern/testdata/fuzz/FuzzParse/f855d335a52bd8b6ed4472abb33c0eb8f67a63d84f1c27398c23689fb2720645: -------------------------------------------------------------------------------- 1 | go test fuzz v1 2 | []byte("(CallExpr (SelectorExpr (Ident \"time\") (Ident \"Sleep\")) [arg])") -------------------------------------------------------------------------------- /pattern/testdata/fuzz/FuzzParse/fac160433f2d82b3c15a8c6ad3938fd85825a4f248108538938a57914e80f114: -------------------------------------------------------------------------------- 1 | go test fuzz v1 2 | []byte("(UnaryExpr \"!\" single@(UnaryExpr \"!\" x))") -------------------------------------------------------------------------------- /pattern/testdata/fuzz/FuzzParse/fb2c5ef5801f44e5bee94b82dbb1bc787cc4b7fbdb17e5cfcc4283f2c726a99f: -------------------------------------------------------------------------------- 1 | go test fuzz v1 2 | []byte("(CallExpr (SelectorExpr (Ident \"fmt\") (Ident \"Errorf\")) args)") -------------------------------------------------------------------------------- /pattern/testdata/fuzz/FuzzParse/fe6c6578776a5ce92474e943ac14979a308d4151d779fd4cfd782f7fb970165e: -------------------------------------------------------------------------------- 1 | go test fuzz v1 2 | []byte("(Or[a_a_a_a])") 3 | -------------------------------------------------------------------------------- /pattern/testdata/fuzz/FuzzParse/ff2017b5c630d7225812cfa8b29b6ebad665505492db847722ba79da5d2c89eb: -------------------------------------------------------------------------------- 1 | go test fuzz v1 2 | []byte("\n\t\t(Or\n\t\t\t(AssignStmt _ (Or \">>=\" \"<<=\") _)\n\t\t\t(BinaryExpr _ (Or \">>\" \"<<\") _))\n\t") -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /quickfix/qf1001/qf1001_test.go: -------------------------------------------------------------------------------- 1 | // Code generated by generate.go. DO NOT EDIT. 2 | 3 | package qf1001 4 | 5 | import ( 6 | "testing" 7 | 8 | "honnef.co/go/tools/analysis/lint/testutil" 9 | ) 10 | 11 | func TestTestdata(t *testing.T) { 12 | testutil.Run(t, SCAnalyzer) 13 | } 14 | -------------------------------------------------------------------------------- /quickfix/qf1001/testdata/go1.0/CheckDeMorgan/CheckDeMorgan.go: -------------------------------------------------------------------------------- 1 | package pkg 2 | 3 | func fn() { 4 | var a, b, c bool 5 | var e, f, g int 6 | var h, i float64 7 | 8 | _ = !(a && b && (!c || e > f) && g == f) //@ diag(`could apply De Morgan's law`) 9 | _ = !(a && h > i) 10 | } 11 | -------------------------------------------------------------------------------- /quickfix/qf1001/testdata/go1.0/CheckDeMorgan/kvexpr.go: -------------------------------------------------------------------------------- 1 | package pkg 2 | 3 | func do() bool { 4 | type Info struct { 5 | idx int 6 | } 7 | 8 | var state map[Info]int 9 | // Don't crash on KeyValueExpr 10 | return !(state[Info{idx: 6}] == 6 || false) //@ diag(`could apply De Morgan's law`) 11 | } 12 | -------------------------------------------------------------------------------- /quickfix/qf1001/testdata/go1.0/CheckDeMorgan/kvexpr.go.golden: -------------------------------------------------------------------------------- 1 | -- Apply De Morgan's law -- 2 | package pkg 3 | 4 | func do() bool { 5 | type Info struct { 6 | idx int 7 | } 8 | 9 | var state map[Info]int 10 | // Don't crash on KeyValueExpr 11 | return state[Info{idx: 6}] != 6 && !false //@ diag(`could apply De Morgan's law`) 12 | } 13 | -------------------------------------------------------------------------------- /quickfix/qf1002/qf1002_test.go: -------------------------------------------------------------------------------- 1 | // Code generated by generate.go. DO NOT EDIT. 2 | 3 | package qf1002 4 | 5 | import ( 6 | "testing" 7 | 8 | "honnef.co/go/tools/analysis/lint/testutil" 9 | ) 10 | 11 | func TestTestdata(t *testing.T) { 12 | testutil.Run(t, SCAnalyzer) 13 | } 14 | -------------------------------------------------------------------------------- /quickfix/qf1003/qf1003_test.go: -------------------------------------------------------------------------------- 1 | // Code generated by generate.go. DO NOT EDIT. 2 | 3 | package qf1003 4 | 5 | import ( 6 | "testing" 7 | 8 | "honnef.co/go/tools/analysis/lint/testutil" 9 | ) 10 | 11 | func TestTestdata(t *testing.T) { 12 | testutil.Run(t, SCAnalyzer) 13 | } 14 | -------------------------------------------------------------------------------- /quickfix/qf1004/qf1004_test.go: -------------------------------------------------------------------------------- 1 | // Code generated by generate.go. DO NOT EDIT. 2 | 3 | package qf1004 4 | 5 | import ( 6 | "testing" 7 | 8 | "honnef.co/go/tools/analysis/lint/testutil" 9 | ) 10 | 11 | func TestTestdata(t *testing.T) { 12 | testutil.Run(t, SCAnalyzer) 13 | } 14 | -------------------------------------------------------------------------------- /quickfix/qf1005/qf1005_test.go: -------------------------------------------------------------------------------- 1 | // Code generated by generate.go. DO NOT EDIT. 2 | 3 | package qf1005 4 | 5 | import ( 6 | "testing" 7 | 8 | "honnef.co/go/tools/analysis/lint/testutil" 9 | ) 10 | 11 | func TestTestdata(t *testing.T) { 12 | testutil.Run(t, SCAnalyzer) 13 | } 14 | -------------------------------------------------------------------------------- /quickfix/qf1006/qf1006_test.go: -------------------------------------------------------------------------------- 1 | // Code generated by generate.go. DO NOT EDIT. 2 | 3 | package qf1006 4 | 5 | import ( 6 | "testing" 7 | 8 | "honnef.co/go/tools/analysis/lint/testutil" 9 | ) 10 | 11 | func TestTestdata(t *testing.T) { 12 | testutil.Run(t, SCAnalyzer) 13 | } 14 | -------------------------------------------------------------------------------- /quickfix/qf1007/qf1007_test.go: -------------------------------------------------------------------------------- 1 | // Code generated by generate.go. DO NOT EDIT. 2 | 3 | package qf1007 4 | 5 | import ( 6 | "testing" 7 | 8 | "honnef.co/go/tools/analysis/lint/testutil" 9 | ) 10 | 11 | func TestTestdata(t *testing.T) { 12 | testutil.Run(t, SCAnalyzer) 13 | } 14 | -------------------------------------------------------------------------------- /quickfix/qf1008/qf1008_test.go: -------------------------------------------------------------------------------- 1 | // Code generated by generate.go. DO NOT EDIT. 2 | 3 | package qf1008 4 | 5 | import ( 6 | "testing" 7 | 8 | "honnef.co/go/tools/analysis/lint/testutil" 9 | ) 10 | 11 | func TestTestdata(t *testing.T) { 12 | testutil.Run(t, SCAnalyzer) 13 | } 14 | -------------------------------------------------------------------------------- /quickfix/qf1008/testdata/go1.0/CheckExplicitEmbeddedSelector/CheckExplicitEmbeddedSelector-anon.go: -------------------------------------------------------------------------------- 1 | package pkg 2 | 3 | type AnonOuter struct{ AnonInner } 4 | type AnonInner struct{ F4 struct{ F5 int } } 5 | 6 | func fnAnon() { 7 | var anon AnonOuter 8 | _ = anon.AnonInner.F4.F5 //@ diag(`could remove embedded field "AnonInner" from selector`) 9 | _ = anon.F4.F5 // minimal form 10 | } 11 | -------------------------------------------------------------------------------- /quickfix/qf1008/testdata/go1.0/CheckExplicitEmbeddedSelector/CheckExplicitEmbeddedSelector-anon.go.golden: -------------------------------------------------------------------------------- 1 | package pkg 2 | 3 | type AnonOuter struct{ AnonInner } 4 | type AnonInner struct{ F4 struct{ F5 int } } 5 | 6 | func fnAnon() { 7 | var anon AnonOuter 8 | _ = anon.F4.F5 //@ diag(`could remove embedded field "AnonInner" from selector`) 9 | _ = anon.F4.F5 // minimal form 10 | } 11 | -------------------------------------------------------------------------------- /quickfix/qf1008/testdata/go1.0/CheckExplicitEmbeddedSelector/CheckExplicitEmbeddedSelector-basic.go: -------------------------------------------------------------------------------- 1 | package pkg 2 | 3 | type BasicOuter struct{ BasicInner } 4 | type BasicInner struct{ F1 int } 5 | 6 | func fnBasic() { 7 | var basic BasicOuter 8 | _ = basic.BasicInner.F1 //@ diag(`could remove embedded field "BasicInner" from selector`) 9 | _ = basic.F1 // minimal form 10 | } 11 | -------------------------------------------------------------------------------- /quickfix/qf1008/testdata/go1.0/CheckExplicitEmbeddedSelector/CheckExplicitEmbeddedSelector-basic.go.golden: -------------------------------------------------------------------------------- 1 | package pkg 2 | 3 | type BasicOuter struct{ BasicInner } 4 | type BasicInner struct{ F1 int } 5 | 6 | func fnBasic() { 7 | var basic BasicOuter 8 | _ = basic.F1 //@ diag(`could remove embedded field "BasicInner" from selector`) 9 | _ = basic.F1 // minimal form 10 | } 11 | -------------------------------------------------------------------------------- /quickfix/qf1008/testdata/go1.0/CheckExplicitEmbeddedSelector/CheckExplicitEmbeddedSelector-depth.go: -------------------------------------------------------------------------------- 1 | package pkg 2 | 3 | func fnDepth() { 4 | type T4 struct{ F int } 5 | type T5 struct{ T4 } 6 | type T3 struct{ T5 } 7 | type T2 struct{ T4 } 8 | 9 | type T1 struct { 10 | T2 11 | T3 12 | } 13 | 14 | var v T1 15 | _ = v.F 16 | _ = v.T2.F //@ diag(`could remove embedded field "T2" from selector`) 17 | _ = v.T3.F 18 | } 19 | -------------------------------------------------------------------------------- /quickfix/qf1008/testdata/go1.0/CheckExplicitEmbeddedSelector/CheckExplicitEmbeddedSelector-depth.go.golden: -------------------------------------------------------------------------------- 1 | package pkg 2 | 3 | func fnDepth() { 4 | type T4 struct{ F int } 5 | type T5 struct{ T4 } 6 | type T3 struct{ T5 } 7 | type T2 struct{ T4 } 8 | 9 | type T1 struct { 10 | T2 11 | T3 12 | } 13 | 14 | var v T1 15 | _ = v.F 16 | _ = v.F //@ diag(`could remove embedded field "T2" from selector`) 17 | _ = v.T3.F 18 | } 19 | -------------------------------------------------------------------------------- /quickfix/qf1008/testdata/go1.0/CheckExplicitEmbeddedSelector/CheckExplicitEmbeddedSelector-qualified.go: -------------------------------------------------------------------------------- 1 | package pkg 2 | 3 | import ( 4 | "io" 5 | 6 | assist "example.com/CheckExplicitEmbeddedSelectorassist" 7 | ) 8 | 9 | func fnQualified() { 10 | _ = io.EOF.Error // minimal form 11 | _ = assist.V.T2.F //@ diag(`could remove embedded field "T2" from selector`) 12 | _ = assist.V.F // minimal form 13 | } 14 | -------------------------------------------------------------------------------- /quickfix/qf1008/testdata/go1.0/CheckExplicitEmbeddedSelector/CheckExplicitEmbeddedSelector-qualified.go.golden: -------------------------------------------------------------------------------- 1 | package pkg 2 | 3 | import ( 4 | "io" 5 | 6 | assist "example.com/CheckExplicitEmbeddedSelectorassist" 7 | ) 8 | 9 | func fnQualified() { 10 | _ = io.EOF.Error // minimal form 11 | _ = assist.V.F //@ diag(`could remove embedded field "T2" from selector`) 12 | _ = assist.V.F // minimal form 13 | } 14 | -------------------------------------------------------------------------------- /quickfix/qf1008/testdata/go1.0/CheckExplicitEmbeddedSelector/CheckExplicitEmbeddedSelector-recursive.go: -------------------------------------------------------------------------------- 1 | package pkg 2 | 3 | type T1 struct { 4 | Next *T1 5 | } 6 | 7 | type T2 struct { 8 | F int 9 | *T2 10 | T3 11 | } 12 | 13 | type T3 struct { 14 | F2 int 15 | } 16 | 17 | func (*T1) Foo() {} 18 | func (*T2) Foo() {} 19 | 20 | func fn() { 21 | var t1 T1 22 | var t2 T2 23 | _ = t1.Next.Foo 24 | _ = t2.T2.Foo 25 | _ = t2.T2.F 26 | _ = t2.T3.F2 //@ diag(`could remove embedded field "T3" from selector`) 27 | } 28 | -------------------------------------------------------------------------------- /quickfix/qf1008/testdata/go1.0/CheckExplicitEmbeddedSelector/CheckExplicitEmbeddedSelector-recursive.go.golden: -------------------------------------------------------------------------------- 1 | package pkg 2 | 3 | type T1 struct { 4 | Next *T1 5 | } 6 | 7 | type T2 struct { 8 | F int 9 | *T2 10 | T3 11 | } 12 | 13 | type T3 struct { 14 | F2 int 15 | } 16 | 17 | func (*T1) Foo() {} 18 | func (*T2) Foo() {} 19 | 20 | func fn() { 21 | var t1 T1 22 | var t2 T2 23 | _ = t1.Next.Foo 24 | _ = t2.T2.Foo 25 | _ = t2.T2.F 26 | _ = t2.F2 //@ diag(`could remove embedded field "T3" from selector`) 27 | } 28 | -------------------------------------------------------------------------------- /quickfix/qf1008/testdata/go1.0/CheckExplicitEmbeddedSelector/CheckExplicitEmbeddedSelector-shadowing.go: -------------------------------------------------------------------------------- 1 | package pkg 2 | 3 | type Shadowing struct { 4 | F1 int 5 | BasicInner 6 | } 7 | 8 | func fnShadowing() { 9 | var shadowing Shadowing 10 | _ = shadowing.BasicInner.F1 // can't be simplified due to shadowing 11 | } 12 | -------------------------------------------------------------------------------- /quickfix/qf1008/testdata/go1.0/CheckExplicitEmbeddedSelector/CheckExplicitEmbeddedSelector-unexported.go: -------------------------------------------------------------------------------- 1 | package pkg 2 | 3 | type UnexportedSamePackageOuter struct { 4 | unexportedSamePackageInner 5 | } 6 | 7 | type unexportedSamePackageInner struct { 8 | F10 int 9 | } 10 | 11 | func fnUnexported() { 12 | var unexportedSame UnexportedSamePackageOuter 13 | _ = unexportedSame.unexportedSamePackageInner.F10 //@ diag(`could remove embedded field "unexportedSamePackageInner" from selector`) 14 | _ = unexportedSame.F10 // minimal form 15 | } 16 | -------------------------------------------------------------------------------- /quickfix/qf1008/testdata/go1.0/CheckExplicitEmbeddedSelector/CheckExplicitEmbeddedSelector-unexported.go.golden: -------------------------------------------------------------------------------- 1 | package pkg 2 | 3 | type UnexportedSamePackageOuter struct { 4 | unexportedSamePackageInner 5 | } 6 | 7 | type unexportedSamePackageInner struct { 8 | F10 int 9 | } 10 | 11 | func fnUnexported() { 12 | var unexportedSame UnexportedSamePackageOuter 13 | _ = unexportedSame.F10 //@ diag(`could remove embedded field "unexportedSamePackageInner" from selector`) 14 | _ = unexportedSame.F10 // minimal form 15 | } 16 | -------------------------------------------------------------------------------- /quickfix/qf1008/testdata/go1.0/CheckExplicitEmbeddedSelectorassist/assist.go: -------------------------------------------------------------------------------- 1 | package assist 2 | 3 | type T1 struct { 4 | T2 5 | } 6 | 7 | type T2 struct { 8 | F int 9 | } 10 | 11 | var V T1 12 | -------------------------------------------------------------------------------- /quickfix/qf1009/qf1009_test.go: -------------------------------------------------------------------------------- 1 | // Code generated by generate.go. DO NOT EDIT. 2 | 3 | package qf1009 4 | 5 | import ( 6 | "testing" 7 | 8 | "honnef.co/go/tools/analysis/lint/testutil" 9 | ) 10 | 11 | func TestTestdata(t *testing.T) { 12 | testutil.Run(t, SCAnalyzer) 13 | } 14 | -------------------------------------------------------------------------------- /quickfix/qf1009/testdata/go1.0/CheckTimeEquality/CheckTimeEquality.go: -------------------------------------------------------------------------------- 1 | package pkg 2 | 3 | import "time" 4 | 5 | func foo() time.Time { return time.Time{} } 6 | func bar() time.Time { return time.Time{} } 7 | 8 | func fn() { 9 | var t1, t2 time.Time 10 | if t1 == t2 { //@ diag(`probably want to use time.Time.Equal instead`) 11 | } 12 | 13 | if foo() == bar() { //@ diag(`probably want to use time.Time.Equal instead`) 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /quickfix/qf1009/testdata/go1.0/CheckTimeEquality/CheckTimeEquality.go.golden: -------------------------------------------------------------------------------- 1 | package pkg 2 | 3 | import "time" 4 | 5 | func foo() time.Time { return time.Time{} } 6 | func bar() time.Time { return time.Time{} } 7 | 8 | func fn() { 9 | var t1, t2 time.Time 10 | if t1.Equal(t2) { //@ diag(`probably want to use time.Time.Equal instead`) 11 | } 12 | 13 | if foo().Equal(bar()) { //@ diag(`probably want to use time.Time.Equal instead`) 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /quickfix/qf1010/qf1010_test.go: -------------------------------------------------------------------------------- 1 | // Code generated by generate.go. DO NOT EDIT. 2 | 3 | package qf1010 4 | 5 | import ( 6 | "testing" 7 | 8 | "honnef.co/go/tools/analysis/lint/testutil" 9 | ) 10 | 11 | func TestTestdata(t *testing.T) { 12 | testutil.Run(t, SCAnalyzer) 13 | } 14 | -------------------------------------------------------------------------------- /quickfix/qf1010/testdata/go1.9/CheckByteSlicePrinting/CheckByteSlicePrinting.go: -------------------------------------------------------------------------------- 1 | package pkg 2 | 3 | import "fmt" 4 | 5 | func fn() { 6 | type ByteSlice []byte 7 | type Alias1 = []byte 8 | type Alias2 = ByteSlice 9 | type Alias3 = byte 10 | type Alias4 = []Alias3 11 | 12 | fmt.Print(Alias1{}) //@ diag(`could convert argument to string`) 13 | fmt.Print(Alias2{}) //@ diag(`could convert argument to string`) 14 | fmt.Print(Alias4{}) //@ diag(`could convert argument to string`) 15 | fmt.Print() 16 | fmt.Fprint(nil) 17 | } 18 | -------------------------------------------------------------------------------- /quickfix/qf1010/testdata/go1.9/CheckByteSlicePrinting/CheckByteSlicePrinting.go.golden: -------------------------------------------------------------------------------- 1 | package pkg 2 | 3 | import "fmt" 4 | 5 | func fn() { 6 | type ByteSlice []byte 7 | type Alias1 = []byte 8 | type Alias2 = ByteSlice 9 | type Alias3 = byte 10 | type Alias4 = []Alias3 11 | 12 | fmt.Print(string(Alias1{})) //@ diag(`could convert argument to string`) 13 | fmt.Print(string(Alias2{})) //@ diag(`could convert argument to string`) 14 | fmt.Print(string(Alias4{})) //@ diag(`could convert argument to string`) 15 | fmt.Print() 16 | fmt.Fprint(nil) 17 | } 18 | -------------------------------------------------------------------------------- /quickfix/qf1011/qf1011_test.go: -------------------------------------------------------------------------------- 1 | // Code generated by generate.go. DO NOT EDIT. 2 | 3 | package qf1011 4 | 5 | import ( 6 | "testing" 7 | 8 | "honnef.co/go/tools/analysis/lint/testutil" 9 | ) 10 | 11 | func TestTestdata(t *testing.T) { 12 | testutil.Run(t, SCAnalyzer) 13 | } 14 | -------------------------------------------------------------------------------- /quickfix/qf1011/testdata/go1.9/CheckRedundantTypeInDeclaration/README: -------------------------------------------------------------------------------- 1 | The cgo test case needs Go 1.9 because modern cgo generates code that 2 | uses aliases. -------------------------------------------------------------------------------- /quickfix/qf1011/testdata/go1.9/CheckRedundantTypeInDeclaration/cgo.go: -------------------------------------------------------------------------------- 1 | package pkg 2 | 3 | // #include 4 | import "C" 5 | import "unsafe" 6 | 7 | func fnCgo(arg C.size_t) { 8 | var ptr unsafe.Pointer 9 | C.realloc(ptr, arg) 10 | } 11 | -------------------------------------------------------------------------------- /quickfix/qf1011/testdata/go1.9/CheckRedundantTypeInDeclaration/cgo.golden: -------------------------------------------------------------------------------- 1 | package pkg 2 | 3 | // #include 4 | import "C" 5 | import "unsafe" 6 | 7 | func fnCgo(arg C.size_t) { 8 | var ptr unsafe.Pointer 9 | C.realloc(ptr, arg) 10 | } 11 | -------------------------------------------------------------------------------- /quickfix/qf1012/qf1012_test.go: -------------------------------------------------------------------------------- 1 | // Code generated by generate.go. DO NOT EDIT. 2 | 3 | package qf1012 4 | 5 | import ( 6 | "testing" 7 | 8 | "honnef.co/go/tools/analysis/lint/testutil" 9 | ) 10 | 11 | func TestTestdata(t *testing.T) { 12 | testutil.Run(t, SCAnalyzer) 13 | } 14 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /simple/s1000/s1000_test.go: -------------------------------------------------------------------------------- 1 | // Code generated by generate.go. DO NOT EDIT. 2 | 3 | package s1000 4 | 5 | import ( 6 | "testing" 7 | 8 | "honnef.co/go/tools/analysis/lint/testutil" 9 | ) 10 | 11 | func TestTestdata(t *testing.T) { 12 | testutil.Run(t, SCAnalyzer) 13 | } 14 | -------------------------------------------------------------------------------- /simple/s1000/testdata/go1.0/CheckSingleCaseSelect/single-case-select.go: -------------------------------------------------------------------------------- 1 | package pkg 2 | 3 | func fn() { 4 | var ch chan int 5 | select { //@ diag(`should use a simple channel send`) 6 | case <-ch: 7 | } 8 | outer: 9 | for { //@ diag(`should use for range`) 10 | select { 11 | case <-ch: 12 | break outer 13 | } 14 | } 15 | 16 | for { //@ diag(`should use for range`) 17 | select { 18 | case x := <-ch: 19 | _ = x 20 | } 21 | } 22 | 23 | for { 24 | select { //@ diag(`should use a simple channel send`) 25 | case ch <- 0: 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /simple/s1001/s1001_test.go: -------------------------------------------------------------------------------- 1 | // Code generated by generate.go. DO NOT EDIT. 2 | 3 | package s1001 4 | 5 | import ( 6 | "testing" 7 | 8 | "honnef.co/go/tools/analysis/lint/testutil" 9 | ) 10 | 11 | func TestTestdata(t *testing.T) { 12 | testutil.Run(t, SCAnalyzer) 13 | } 14 | -------------------------------------------------------------------------------- /simple/s1002/s1002_test.go: -------------------------------------------------------------------------------- 1 | // Code generated by generate.go. DO NOT EDIT. 2 | 3 | package s1002 4 | 5 | import ( 6 | "testing" 7 | 8 | "honnef.co/go/tools/analysis/lint/testutil" 9 | ) 10 | 11 | func TestTestdata(t *testing.T) { 12 | testutil.Run(t, SCAnalyzer) 13 | } 14 | -------------------------------------------------------------------------------- /simple/s1002/testdata/go1.0/CheckIfBoolCmp/bool-cmp_test.go: -------------------------------------------------------------------------------- 1 | package pkg 2 | 3 | import "testing" 4 | 5 | func TestFoo(t *testing.T) { 6 | if fn1() == true { 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /simple/s1003/s1003_test.go: -------------------------------------------------------------------------------- 1 | // Code generated by generate.go. DO NOT EDIT. 2 | 3 | package s1003 4 | 5 | import ( 6 | "testing" 7 | 8 | "honnef.co/go/tools/analysis/lint/testutil" 9 | ) 10 | 11 | func TestTestdata(t *testing.T) { 12 | testutil.Run(t, SCAnalyzer) 13 | } 14 | -------------------------------------------------------------------------------- /simple/s1004/s1004_test.go: -------------------------------------------------------------------------------- 1 | // Code generated by generate.go. DO NOT EDIT. 2 | 3 | package s1004 4 | 5 | import ( 6 | "testing" 7 | 8 | "honnef.co/go/tools/analysis/lint/testutil" 9 | ) 10 | 11 | func TestTestdata(t *testing.T) { 12 | testutil.Run(t, SCAnalyzer) 13 | } 14 | -------------------------------------------------------------------------------- /simple/s1004/testdata/go1.0/CheckBytesCompare/compare.go: -------------------------------------------------------------------------------- 1 | package pkg 2 | 3 | import "bytes" 4 | 5 | func fn() { 6 | _ = bytes.Compare(nil, nil) == 0 //@ diag(` bytes.Equal`) 7 | _ = bytes.Compare(nil, nil) != 0 //@ diag(`!bytes.Equal`) 8 | _ = bytes.Compare(nil, nil) > 0 9 | _ = bytes.Compare(nil, nil) < 0 10 | } 11 | -------------------------------------------------------------------------------- /simple/s1004/testdata/go1.0/CheckBytesCompare/compare.go.golden: -------------------------------------------------------------------------------- 1 | package pkg 2 | 3 | import "bytes" 4 | 5 | func fn() { 6 | _ = bytes.Equal(nil, nil) //@ diag(` bytes.Equal`) 7 | _ = !bytes.Equal(nil, nil) //@ diag(`!bytes.Equal`) 8 | _ = bytes.Compare(nil, nil) > 0 9 | _ = bytes.Compare(nil, nil) < 0 10 | } 11 | -------------------------------------------------------------------------------- /simple/s1005/s1005_test.go: -------------------------------------------------------------------------------- 1 | // Code generated by generate.go. DO NOT EDIT. 2 | 3 | package s1005 4 | 5 | import ( 6 | "testing" 7 | 8 | "honnef.co/go/tools/analysis/lint/testutil" 9 | ) 10 | 11 | func TestTestdata(t *testing.T) { 12 | testutil.Run(t, SCAnalyzer) 13 | } 14 | -------------------------------------------------------------------------------- /simple/s1005/testdata/go1.0/CheckUnnecessaryBlank/LintBlankOK.go: -------------------------------------------------------------------------------- 1 | package pkg 2 | 3 | func fn() { 4 | var m map[int]int 5 | var ch chan int 6 | var fn func() (int, bool) 7 | 8 | x, _ := m[0] //@ diag(`unnecessary assignment to the blank identifier`) 9 | x, _ = <-ch //@ diag(`unnecessary assignment to the blank identifier`) 10 | x, _ = fn() 11 | _ = x 12 | } 13 | -------------------------------------------------------------------------------- /simple/s1005/testdata/go1.0/CheckUnnecessaryBlank/LintBlankOK.go.golden: -------------------------------------------------------------------------------- 1 | package pkg 2 | 3 | func fn() { 4 | var m map[int]int 5 | var ch chan int 6 | var fn func() (int, bool) 7 | 8 | x := m[0] //@ diag(`unnecessary assignment to the blank identifier`) 9 | x = <-ch //@ diag(`unnecessary assignment to the blank identifier`) 10 | x, _ = fn() 11 | _ = x 12 | } 13 | -------------------------------------------------------------------------------- /simple/s1005/testdata/go1.0/CheckUnnecessaryBlank/receive-blank.go: -------------------------------------------------------------------------------- 1 | package pkg 2 | 3 | func fn2() { 4 | var ch chan int 5 | <-ch 6 | _ = <-ch //@ diag(`unnecessary assignment to the blank identifier`) 7 | select { 8 | case <-ch: 9 | case _ = <-ch: //@ diag(`unnecessary assignment to the blank identifier`) 10 | } 11 | x := <-ch 12 | y, _ := <-ch, <-ch 13 | _, z := <-ch, <-ch 14 | _, _, _ = x, y, z 15 | } 16 | -------------------------------------------------------------------------------- /simple/s1005/testdata/go1.0/CheckUnnecessaryBlank/receive-blank.go.golden: -------------------------------------------------------------------------------- 1 | package pkg 2 | 3 | func fn2() { 4 | var ch chan int 5 | <-ch 6 | <-ch //@ diag(`unnecessary assignment to the blank identifier`) 7 | select { 8 | case <-ch: 9 | case <-ch: //@ diag(`unnecessary assignment to the blank identifier`) 10 | } 11 | x := <-ch 12 | y, _ := <-ch, <-ch 13 | _, z := <-ch, <-ch 14 | _, _, _ = x, y, z 15 | } 16 | -------------------------------------------------------------------------------- /simple/s1005/testdata/go1.3/CheckUnnecessaryBlank/range.go: -------------------------------------------------------------------------------- 1 | package pkg 2 | 3 | func fn() { 4 | var m map[string]int 5 | 6 | // with := 7 | for x, _ := range m { 8 | _ = x 9 | } 10 | // with = 11 | var y string 12 | _ = y 13 | for y, _ = range m { 14 | } 15 | 16 | // all OK: 17 | for x := range m { 18 | _ = x 19 | } 20 | for x, y := range m { 21 | _, _ = x, y 22 | } 23 | for _, y := range m { 24 | _ = y 25 | } 26 | var x int 27 | _ = x 28 | for y = range m { 29 | } 30 | for y, x = range m { 31 | } 32 | for _, x = range m { 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /simple/s1006/s1006_test.go: -------------------------------------------------------------------------------- 1 | // Code generated by generate.go. DO NOT EDIT. 2 | 3 | package s1006 4 | 5 | import ( 6 | "testing" 7 | 8 | "honnef.co/go/tools/analysis/lint/testutil" 9 | ) 10 | 11 | func TestTestdata(t *testing.T) { 12 | testutil.Run(t, SCAnalyzer) 13 | } 14 | -------------------------------------------------------------------------------- /simple/s1006/testdata/go1.0/CheckForTrue/for-true.go: -------------------------------------------------------------------------------- 1 | package pkg 2 | 3 | func fn() { 4 | for false { 5 | } 6 | for true { //@ diag(`should use for`) 7 | } 8 | for { 9 | } 10 | for i := 0; true; i++ { 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /simple/s1006/testdata/go1.0/CheckForTrue/generated.go: -------------------------------------------------------------------------------- 1 | // Code generated by a clever monkey. DO NOT EDIT. 2 | 3 | package pkg 4 | 5 | func fn3() { 6 | for true { 7 | } 8 | } 9 | 10 | //line input.go:2 11 | func fn2() { 12 | for true { 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /simple/s1006/testdata/go1.0/CheckForTrue/input.go: -------------------------------------------------------------------------------- 1 | package pkg 2 | 3 | //@ diag(`should use for {}`) 4 | 5 | // the error is produced by generated.go, which pretends that its 6 | // broken code came from this file. 7 | -------------------------------------------------------------------------------- /simple/s1007/s1007_test.go: -------------------------------------------------------------------------------- 1 | // Code generated by generate.go. DO NOT EDIT. 2 | 3 | package s1007 4 | 5 | import ( 6 | "testing" 7 | 8 | "honnef.co/go/tools/analysis/lint/testutil" 9 | ) 10 | 11 | func TestTestdata(t *testing.T) { 12 | testutil.Run(t, SCAnalyzer) 13 | } 14 | -------------------------------------------------------------------------------- /simple/s1008/s1008_test.go: -------------------------------------------------------------------------------- 1 | // Code generated by generate.go. DO NOT EDIT. 2 | 3 | package s1008 4 | 5 | import ( 6 | "testing" 7 | 8 | "honnef.co/go/tools/analysis/lint/testutil" 9 | ) 10 | 11 | func TestTestdata(t *testing.T) { 12 | testutil.Run(t, SCAnalyzer) 13 | } 14 | -------------------------------------------------------------------------------- /simple/s1009/s1009_test.go: -------------------------------------------------------------------------------- 1 | // Code generated by generate.go. DO NOT EDIT. 2 | 3 | package s1009 4 | 5 | import ( 6 | "testing" 7 | 8 | "honnef.co/go/tools/analysis/lint/testutil" 9 | ) 10 | 11 | func TestTestdata(t *testing.T) { 12 | testutil.Run(t, SCAnalyzer) 13 | } 14 | -------------------------------------------------------------------------------- /simple/s1009/testdata/go1.18/CheckRedundantNilCheckWithLen/nil-len_generics.go: -------------------------------------------------------------------------------- 1 | package pkg 2 | 3 | func fn1[T []int | *[4]int](a T) { 4 | if a != nil && len(a) > 0 { // don't flag, because of the pointer 5 | } 6 | } 7 | 8 | func fn2[T []int | []string | map[string]int](a T) { 9 | if a != nil && len(a) > 0 { //@ diag(`should omit nil check`) 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /simple/s1010/s1010_test.go: -------------------------------------------------------------------------------- 1 | // Code generated by generate.go. DO NOT EDIT. 2 | 3 | package s1010 4 | 5 | import ( 6 | "testing" 7 | 8 | "honnef.co/go/tools/analysis/lint/testutil" 9 | ) 10 | 11 | func TestTestdata(t *testing.T) { 12 | testutil.Run(t, SCAnalyzer) 13 | } 14 | -------------------------------------------------------------------------------- /simple/s1010/testdata/go1.0/CheckSlicing/slicing.go: -------------------------------------------------------------------------------- 1 | package pkg 2 | 3 | func fn() { 4 | var s [5]int 5 | _ = s[:len(s)] //@ diag(`omit second index`) 6 | 7 | len := func(s [5]int) int { return -1 } 8 | _ = s[:len(s)] 9 | } 10 | -------------------------------------------------------------------------------- /simple/s1010/testdata/go1.0/CheckSlicing/slicing.go.golden: -------------------------------------------------------------------------------- 1 | package pkg 2 | 3 | func fn() { 4 | var s [5]int 5 | _ = s[:] //@ diag(`omit second index`) 6 | 7 | len := func(s [5]int) int { return -1 } 8 | _ = s[:len(s)] 9 | } 10 | -------------------------------------------------------------------------------- /simple/s1011/s1011_test.go: -------------------------------------------------------------------------------- 1 | // Code generated by generate.go. DO NOT EDIT. 2 | 3 | package s1011 4 | 5 | import ( 6 | "testing" 7 | 8 | "honnef.co/go/tools/analysis/lint/testutil" 9 | ) 10 | 11 | func TestTestdata(t *testing.T) { 12 | testutil.Run(t, SCAnalyzer) 13 | } 14 | -------------------------------------------------------------------------------- /simple/s1012/s1012_test.go: -------------------------------------------------------------------------------- 1 | // Code generated by generate.go. DO NOT EDIT. 2 | 3 | package s1012 4 | 5 | import ( 6 | "testing" 7 | 8 | "honnef.co/go/tools/analysis/lint/testutil" 9 | ) 10 | 11 | func TestTestdata(t *testing.T) { 12 | testutil.Run(t, SCAnalyzer) 13 | } 14 | -------------------------------------------------------------------------------- /simple/s1012/testdata/go1.0/CheckTimeSince/time-since.go: -------------------------------------------------------------------------------- 1 | package pkg 2 | 3 | import "time" 4 | 5 | func fn() { 6 | t1 := time.Now() 7 | _ = time.Now().Sub(t1) //@ diag(`time.Since`) 8 | _ = time.Date(0, 0, 0, 0, 0, 0, 0, nil).Sub(t1) 9 | } 10 | -------------------------------------------------------------------------------- /simple/s1012/testdata/go1.0/CheckTimeSince/time-since.go.golden: -------------------------------------------------------------------------------- 1 | package pkg 2 | 3 | import "time" 4 | 5 | func fn() { 6 | t1 := time.Now() 7 | _ = time.Since(t1) //@ diag(`time.Since`) 8 | _ = time.Date(0, 0, 0, 0, 0, 0, 0, nil).Sub(t1) 9 | } 10 | -------------------------------------------------------------------------------- /simple/s1016/s1016_test.go: -------------------------------------------------------------------------------- 1 | // Code generated by generate.go. DO NOT EDIT. 2 | 3 | package s1016 4 | 5 | import ( 6 | "testing" 7 | 8 | "honnef.co/go/tools/analysis/lint/testutil" 9 | ) 10 | 11 | func TestTestdata(t *testing.T) { 12 | testutil.Run(t, SCAnalyzer) 13 | } 14 | -------------------------------------------------------------------------------- /simple/s1016/testdata/go1.7/CheckSimplerStructConversion/convert.go: -------------------------------------------------------------------------------- 1 | package pkg 2 | 3 | type t1 struct { 4 | a int 5 | b int 6 | } 7 | 8 | type t2 struct { 9 | a int 10 | b int 11 | } 12 | 13 | type t3 struct { 14 | a int `tag` 15 | b int `tag` 16 | } 17 | 18 | func fn() { 19 | v1 := t1{1, 2} 20 | _ = t2{v1.a, v1.b} //@ diag(`should convert v1`) 21 | _ = t3{v1.a, v1.b} 22 | } 23 | -------------------------------------------------------------------------------- /simple/s1016/testdata/go1.7/CheckSimplerStructConversion/convert.go.golden: -------------------------------------------------------------------------------- 1 | package pkg 2 | 3 | type t1 struct { 4 | a int 5 | b int 6 | } 7 | 8 | type t2 struct { 9 | a int 10 | b int 11 | } 12 | 13 | type t3 struct { 14 | a int `tag` 15 | b int `tag` 16 | } 17 | 18 | func fn() { 19 | v1 := t1{1, 2} 20 | _ = t2(v1) //@ diag(`should convert v1`) 21 | _ = t3{v1.a, v1.b} 22 | } 23 | -------------------------------------------------------------------------------- /simple/s1016/testdata/go1.8/CheckSimplerStructConversion/convert.go: -------------------------------------------------------------------------------- 1 | package pkg 2 | 3 | type t1 struct { 4 | a int 5 | b int 6 | } 7 | 8 | type t2 struct { 9 | a int 10 | b int 11 | } 12 | 13 | type t3 struct { 14 | a int `tag` 15 | b int `tag` 16 | } 17 | 18 | func fn() { 19 | v1 := t1{1, 2} 20 | _ = t2{v1.a, v1.b} //@ diag(`should convert v1`) 21 | _ = t3{v1.a, v1.b} //@ diag(`should convert v1`) 22 | } 23 | -------------------------------------------------------------------------------- /simple/s1016/testdata/go1.8/CheckSimplerStructConversion/convert.go.golden: -------------------------------------------------------------------------------- 1 | package pkg 2 | 3 | type t1 struct { 4 | a int 5 | b int 6 | } 7 | 8 | type t2 struct { 9 | a int 10 | b int 11 | } 12 | 13 | type t3 struct { 14 | a int `tag` 15 | b int `tag` 16 | } 17 | 18 | func fn() { 19 | v1 := t1{1, 2} 20 | _ = t2(v1) //@ diag(`should convert v1`) 21 | _ = t3(v1) //@ diag(`should convert v1`) 22 | } 23 | -------------------------------------------------------------------------------- /simple/s1016/testdata/go1.9/CheckSimplerStructConversion/convert_alias.go: -------------------------------------------------------------------------------- 1 | package pkg 2 | 3 | type S1 struct { 4 | A int 5 | } 6 | 7 | type S2 struct { 8 | A int 9 | } 10 | 11 | type Alias = S2 12 | 13 | // XXX the diagnostics depend on GODEBUG 14 | 15 | func foo() { 16 | v1 := S1{A: 1} 17 | v2 := Alias{A: 1} 18 | 19 | _ = Alias{A: v1.A} //@ diag(`should convert v1`) 20 | _ = S1{A: v2.A} //@ diag(`should convert v2`) 21 | } 22 | -------------------------------------------------------------------------------- /simple/s1016/testdata/go1.9/CheckSimplerStructConversion/convert_alias.go.golden: -------------------------------------------------------------------------------- 1 | package pkg 2 | 3 | type S1 struct { 4 | A int 5 | } 6 | 7 | type S2 struct { 8 | A int 9 | } 10 | 11 | type Alias = S2 12 | 13 | // XXX the diagnostics depend on GODEBUG 14 | 15 | func foo() { 16 | v1 := S1{A: 1} 17 | v2 := Alias{A: 1} 18 | 19 | _ = Alias(v1) //@ diag(`should convert v1`) 20 | _ = S1(v2) //@ diag(`should convert v2`) 21 | } 22 | -------------------------------------------------------------------------------- /simple/s1017/s1017_test.go: -------------------------------------------------------------------------------- 1 | // Code generated by generate.go. DO NOT EDIT. 2 | 3 | package s1017 4 | 5 | import ( 6 | "testing" 7 | 8 | "honnef.co/go/tools/analysis/lint/testutil" 9 | ) 10 | 11 | func TestTestdata(t *testing.T) { 12 | testutil.Run(t, SCAnalyzer) 13 | } 14 | -------------------------------------------------------------------------------- /simple/s1018/s1018_test.go: -------------------------------------------------------------------------------- 1 | // Code generated by generate.go. DO NOT EDIT. 2 | 3 | package s1018 4 | 5 | import ( 6 | "testing" 7 | 8 | "honnef.co/go/tools/analysis/lint/testutil" 9 | ) 10 | 11 | func TestTestdata(t *testing.T) { 12 | testutil.Run(t, SCAnalyzer) 13 | } 14 | -------------------------------------------------------------------------------- /simple/s1018/testdata/go1.0/CheckLoopSlide/LintLoopSlide.go: -------------------------------------------------------------------------------- 1 | package pkg 2 | 3 | func fn() { 4 | var n int 5 | var bs []int 6 | var offset int 7 | 8 | for i := 0; i < n; i++ { //@ diag(`should use copy() instead of loop for sliding slice elements`) 9 | bs[i] = bs[offset+i] 10 | } 11 | 12 | for i := 1; i < n; i++ { // not currently supported 13 | bs[i] = bs[offset+i] 14 | } 15 | 16 | for i := 1; i < n; i++ { // not currently supported 17 | bs[i] = bs[i+offset] 18 | } 19 | 20 | for i := 0; i <= n; i++ { 21 | bs[i] = bs[offset+i] 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /simple/s1018/testdata/go1.0/CheckLoopSlide/LintLoopSlide.go.golden: -------------------------------------------------------------------------------- 1 | package pkg 2 | 3 | func fn() { 4 | var n int 5 | var bs []int 6 | var offset int 7 | 8 | copy(bs[:n], bs[offset:]) 9 | 10 | for i := 1; i < n; i++ { // not currently supported 11 | bs[i] = bs[offset+i] 12 | } 13 | 14 | for i := 1; i < n; i++ { // not currently supported 15 | bs[i] = bs[i+offset] 16 | } 17 | 18 | for i := 0; i <= n; i++ { 19 | bs[i] = bs[offset+i] 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /simple/s1018/testdata/go1.18/CheckLoopSlide/generics.go: -------------------------------------------------------------------------------- 1 | package pkg 2 | 3 | func tpfn[T []int]() { 4 | var n int 5 | var bs T 6 | var offset int 7 | 8 | for i := 0; i < n; i++ { //@ diag(`should use copy() instead of loop for sliding slice elements`) 9 | bs[i] = bs[offset+i] 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /simple/s1018/testdata/go1.18/CheckLoopSlide/generics.go.golden: -------------------------------------------------------------------------------- 1 | package pkg 2 | 3 | func tpfn[T []int]() { 4 | var n int 5 | var bs T 6 | var offset int 7 | 8 | copy(bs[:n], bs[offset:]) 9 | } 10 | -------------------------------------------------------------------------------- /simple/s1019/s1019_test.go: -------------------------------------------------------------------------------- 1 | // Code generated by generate.go. DO NOT EDIT. 2 | 3 | package s1019 4 | 5 | import ( 6 | "testing" 7 | 8 | "honnef.co/go/tools/analysis/lint/testutil" 9 | ) 10 | 11 | func TestTestdata(t *testing.T) { 12 | testutil.Run(t, SCAnalyzer) 13 | } 14 | -------------------------------------------------------------------------------- /simple/s1020/s1020_test.go: -------------------------------------------------------------------------------- 1 | // Code generated by generate.go. DO NOT EDIT. 2 | 3 | package s1020 4 | 5 | import ( 6 | "testing" 7 | 8 | "honnef.co/go/tools/analysis/lint/testutil" 9 | ) 10 | 11 | func TestTestdata(t *testing.T) { 12 | testutil.Run(t, SCAnalyzer) 13 | } 14 | -------------------------------------------------------------------------------- /simple/s1021/s1021_test.go: -------------------------------------------------------------------------------- 1 | // Code generated by generate.go. DO NOT EDIT. 2 | 3 | package s1021 4 | 5 | import ( 6 | "testing" 7 | 8 | "honnef.co/go/tools/analysis/lint/testutil" 9 | ) 10 | 11 | func TestTestdata(t *testing.T) { 12 | testutil.Run(t, SCAnalyzer) 13 | } 14 | -------------------------------------------------------------------------------- /simple/s1023/s1023_test.go: -------------------------------------------------------------------------------- 1 | // Code generated by generate.go. DO NOT EDIT. 2 | 3 | package s1023 4 | 5 | import ( 6 | "testing" 7 | 8 | "honnef.co/go/tools/analysis/lint/testutil" 9 | ) 10 | 11 | func TestTestdata(t *testing.T) { 12 | testutil.Run(t, SCAnalyzer) 13 | } 14 | -------------------------------------------------------------------------------- /simple/s1024/s1024_test.go: -------------------------------------------------------------------------------- 1 | // Code generated by generate.go. DO NOT EDIT. 2 | 3 | package s1024 4 | 5 | import ( 6 | "testing" 7 | 8 | "honnef.co/go/tools/analysis/lint/testutil" 9 | ) 10 | 11 | func TestTestdata(t *testing.T) { 12 | testutil.Run(t, SCAnalyzer) 13 | } 14 | -------------------------------------------------------------------------------- /simple/s1024/testdata/go1.7/CheckTimeUntil/LimeTimeUntil.go: -------------------------------------------------------------------------------- 1 | package pkg 2 | 3 | import "time" 4 | 5 | func fn(t time.Time) { 6 | t.Sub(time.Now()) 7 | } 8 | -------------------------------------------------------------------------------- /simple/s1024/testdata/go1.8/CheckTimeUntil/LimeTimeUntil.go: -------------------------------------------------------------------------------- 1 | package pkg 2 | 3 | import "time" 4 | 5 | func fn(t time.Time) { 6 | t.Sub(time.Now()) //@ diag(`time.Until`) 7 | t.Sub(t) 8 | t2 := time.Now() 9 | t.Sub(t2) 10 | } 11 | -------------------------------------------------------------------------------- /simple/s1024/testdata/go1.8/CheckTimeUntil/LimeTimeUntil.go.golden: -------------------------------------------------------------------------------- 1 | package pkg 2 | 3 | import "time" 4 | 5 | func fn(t time.Time) { 6 | time.Until(t) //@ diag(`time.Until`) 7 | t.Sub(t) 8 | t2 := time.Now() 9 | t.Sub(t2) 10 | } 11 | -------------------------------------------------------------------------------- /simple/s1025/s1025_test.go: -------------------------------------------------------------------------------- 1 | // Code generated by generate.go. DO NOT EDIT. 2 | 3 | package s1025 4 | 5 | import ( 6 | "testing" 7 | 8 | "honnef.co/go/tools/analysis/lint/testutil" 9 | ) 10 | 11 | func TestTestdata(t *testing.T) { 12 | testutil.Run(t, SCAnalyzer) 13 | } 14 | -------------------------------------------------------------------------------- /simple/s1025/testdata/go1.17/CheckRedundantSprintf/LintRedundantSprintf.go: -------------------------------------------------------------------------------- 1 | package pkg 2 | 3 | import "fmt" 4 | 5 | type MyByte byte 6 | type T1 []MyByte 7 | 8 | func fn() { 9 | var t1 T1 10 | _ = fmt.Sprintf("%s", t1) 11 | } 12 | -------------------------------------------------------------------------------- /simple/s1025/testdata/go1.17/CheckRedundantSprintf/LintRedundantSprintf.go.golden: -------------------------------------------------------------------------------- 1 | package pkg 2 | 3 | import "fmt" 4 | 5 | type MyByte byte 6 | type T1 []MyByte 7 | 8 | func fn() { 9 | var t1 T1 10 | _ = fmt.Sprintf("%s", t1) 11 | } 12 | -------------------------------------------------------------------------------- /simple/s1025/testdata/go1.18/CheckRedundantSprintf/LintRedundantSprintf.go: -------------------------------------------------------------------------------- 1 | package pkg 2 | 3 | import "fmt" 4 | 5 | type MyByte byte 6 | type T1 []MyByte 7 | 8 | func fn() { 9 | var t1 T1 10 | _ = fmt.Sprintf("%s", t1) //@ diag(`underlying type is a slice of bytes`) 11 | } 12 | -------------------------------------------------------------------------------- /simple/s1025/testdata/go1.18/CheckRedundantSprintf/LintRedundantSprintf.go.golden: -------------------------------------------------------------------------------- 1 | package pkg 2 | 3 | import "fmt" 4 | 5 | type MyByte byte 6 | type T1 []MyByte 7 | 8 | func fn() { 9 | var t1 T1 10 | _ = string(t1) //@ diag(`underlying type is a slice of bytes`) 11 | } 12 | -------------------------------------------------------------------------------- /simple/s1028/s1028_test.go: -------------------------------------------------------------------------------- 1 | // Code generated by generate.go. DO NOT EDIT. 2 | 3 | package s1028 4 | 5 | import ( 6 | "testing" 7 | 8 | "honnef.co/go/tools/analysis/lint/testutil" 9 | ) 10 | 11 | func TestTestdata(t *testing.T) { 12 | testutil.Run(t, SCAnalyzer) 13 | } 14 | -------------------------------------------------------------------------------- /simple/s1028/testdata/go1.0/CheckErrorsNewSprintf/LintErrorsNewSprintf.go: -------------------------------------------------------------------------------- 1 | package pkg 2 | 3 | import ( 4 | "errors" 5 | "fmt" 6 | ) 7 | 8 | func fn() { 9 | _ = fmt.Errorf("%d", 0) 10 | _ = errors.New("") 11 | _ = errors.New(fmt.Sprintf("%d", 0)) //@ diag(`should use fmt.Errorf`) 12 | } 13 | -------------------------------------------------------------------------------- /simple/s1028/testdata/go1.0/CheckErrorsNewSprintf/LintErrorsNewSprintf.go.golden: -------------------------------------------------------------------------------- 1 | package pkg 2 | 3 | import ( 4 | "errors" 5 | "fmt" 6 | ) 7 | 8 | func fn() { 9 | _ = fmt.Errorf("%d", 0) 10 | _ = errors.New("") 11 | _ = fmt.Errorf("%d", 0) //@ diag(`should use fmt.Errorf`) 12 | } 13 | -------------------------------------------------------------------------------- /simple/s1029/s1029_test.go: -------------------------------------------------------------------------------- 1 | // Code generated by generate.go. DO NOT EDIT. 2 | 3 | package s1029 4 | 5 | import ( 6 | "testing" 7 | 8 | "honnef.co/go/tools/analysis/lint/testutil" 9 | ) 10 | 11 | func TestTestdata(t *testing.T) { 12 | testutil.Run(t, SCAnalyzer) 13 | } 14 | -------------------------------------------------------------------------------- /simple/s1029/testdata/go1.18/CheckRangeStringRunes/generics.go: -------------------------------------------------------------------------------- 1 | package pkg 2 | 3 | func tpfn1[T string](x T) { 4 | for _, c := range []rune(x) { //@ diag(`should range over string`) 5 | println(c) 6 | } 7 | } 8 | 9 | func tpfn2[T1 string, T2 []rune](x T1) { 10 | for _, c := range T2(x) { //@ diag(`should range over string`) 11 | println(c) 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /simple/s1030/s1030_test.go: -------------------------------------------------------------------------------- 1 | // Code generated by generate.go. DO NOT EDIT. 2 | 3 | package s1030 4 | 5 | import ( 6 | "testing" 7 | 8 | "honnef.co/go/tools/analysis/lint/testutil" 9 | ) 10 | 11 | func TestTestdata(t *testing.T) { 12 | testutil.Run(t, SCAnalyzer) 13 | } 14 | -------------------------------------------------------------------------------- /simple/s1031/s1031_test.go: -------------------------------------------------------------------------------- 1 | // Code generated by generate.go. DO NOT EDIT. 2 | 3 | package s1031 4 | 5 | import ( 6 | "testing" 7 | 8 | "honnef.co/go/tools/analysis/lint/testutil" 9 | ) 10 | 11 | func TestTestdata(t *testing.T) { 12 | testutil.Run(t, SCAnalyzer) 13 | } 14 | -------------------------------------------------------------------------------- /simple/s1032/s1032_test.go: -------------------------------------------------------------------------------- 1 | // Code generated by generate.go. DO NOT EDIT. 2 | 3 | package s1032 4 | 5 | import ( 6 | "testing" 7 | 8 | "honnef.co/go/tools/analysis/lint/testutil" 9 | ) 10 | 11 | func TestTestdata(t *testing.T) { 12 | testutil.Run(t, SCAnalyzer) 13 | } 14 | -------------------------------------------------------------------------------- /simple/s1033/s1033_test.go: -------------------------------------------------------------------------------- 1 | // Code generated by generate.go. DO NOT EDIT. 2 | 3 | package s1033 4 | 5 | import ( 6 | "testing" 7 | 8 | "honnef.co/go/tools/analysis/lint/testutil" 9 | ) 10 | 11 | func TestTestdata(t *testing.T) { 12 | testutil.Run(t, SCAnalyzer) 13 | } 14 | -------------------------------------------------------------------------------- /simple/s1034/s1034_test.go: -------------------------------------------------------------------------------- 1 | // Code generated by generate.go. DO NOT EDIT. 2 | 3 | package s1034 4 | 5 | import ( 6 | "testing" 7 | 8 | "honnef.co/go/tools/analysis/lint/testutil" 9 | ) 10 | 11 | func TestTestdata(t *testing.T) { 12 | testutil.Run(t, SCAnalyzer) 13 | } 14 | -------------------------------------------------------------------------------- /simple/s1035/s1035_test.go: -------------------------------------------------------------------------------- 1 | // Code generated by generate.go. DO NOT EDIT. 2 | 3 | package s1035 4 | 5 | import ( 6 | "testing" 7 | 8 | "honnef.co/go/tools/analysis/lint/testutil" 9 | ) 10 | 11 | func TestTestdata(t *testing.T) { 12 | testutil.Run(t, SCAnalyzer) 13 | } 14 | -------------------------------------------------------------------------------- /simple/s1036/s1036_test.go: -------------------------------------------------------------------------------- 1 | // Code generated by generate.go. DO NOT EDIT. 2 | 3 | package s1036 4 | 5 | import ( 6 | "testing" 7 | 8 | "honnef.co/go/tools/analysis/lint/testutil" 9 | ) 10 | 11 | func TestTestdata(t *testing.T) { 12 | testutil.Run(t, SCAnalyzer) 13 | } 14 | -------------------------------------------------------------------------------- /simple/s1037/s1037_test.go: -------------------------------------------------------------------------------- 1 | // Code generated by generate.go. DO NOT EDIT. 2 | 3 | package s1037 4 | 5 | import ( 6 | "testing" 7 | 8 | "honnef.co/go/tools/analysis/lint/testutil" 9 | ) 10 | 11 | func TestTestdata(t *testing.T) { 12 | testutil.Run(t, SCAnalyzer) 13 | } 14 | -------------------------------------------------------------------------------- /simple/s1037/testdata/go1.0/CheckElaborateSleep/LintElaborateSleep.go: -------------------------------------------------------------------------------- 1 | package pkg 2 | 3 | import ( 4 | "fmt" 5 | "time" 6 | ) 7 | 8 | func fn() { 9 | time.Sleep(0) 10 | 11 | select { //@ diag(`should use time.Sleep`) 12 | case <-time.After(0): 13 | } 14 | 15 | select { //@ diag(`should use time.Sleep`) 16 | case <-time.After(0): 17 | fmt.Println("yay") 18 | } 19 | 20 | const d = 0 21 | select { //@ diag(`should use time.Sleep`) 22 | case <-time.After(d): 23 | } 24 | 25 | var ch chan int 26 | select { 27 | case <-time.After(0): 28 | case <-ch: 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /simple/s1037/testdata/go1.0/CheckElaborateSleep/LintElaborateSleep.go.golden: -------------------------------------------------------------------------------- 1 | package pkg 2 | 3 | import ( 4 | "fmt" 5 | "time" 6 | ) 7 | 8 | func fn() { 9 | time.Sleep(0) 10 | 11 | time.Sleep(0) 12 | 13 | select { //@ diag(`should use time.Sleep`) 14 | case <-time.After(0): 15 | fmt.Println("yay") 16 | } 17 | 18 | const d = 0 19 | time.Sleep(d) 20 | 21 | var ch chan int 22 | select { 23 | case <-time.After(0): 24 | case <-ch: 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /simple/s1038/s1038_test.go: -------------------------------------------------------------------------------- 1 | // Code generated by generate.go. DO NOT EDIT. 2 | 3 | package s1038 4 | 5 | import ( 6 | "testing" 7 | 8 | "honnef.co/go/tools/analysis/lint/testutil" 9 | ) 10 | 11 | func TestTestdata(t *testing.T) { 12 | testutil.Run(t, SCAnalyzer) 13 | } 14 | -------------------------------------------------------------------------------- /simple/s1039/s1039_test.go: -------------------------------------------------------------------------------- 1 | // Code generated by generate.go. DO NOT EDIT. 2 | 3 | package s1039 4 | 5 | import ( 6 | "testing" 7 | 8 | "honnef.co/go/tools/analysis/lint/testutil" 9 | ) 10 | 11 | func TestTestdata(t *testing.T) { 12 | testutil.Run(t, SCAnalyzer) 13 | } 14 | -------------------------------------------------------------------------------- /simple/s1039/testdata/go1.0/CheckSprintLiteral/CheckSprintLiteral.go: -------------------------------------------------------------------------------- 1 | package pkg 2 | 3 | import "fmt" 4 | 5 | func fn() { 6 | _ = fmt.Sprint("foo") //@ diag(`unnecessary use of fmt.Sprint`) 7 | _ = fmt.Sprintf("foo") //@ diag(`unnecessary use of fmt.Sprintf`) 8 | _ = fmt.Sprintf("foo %d") 9 | _ = fmt.Sprintf("foo %d", 1) 10 | 11 | var x string 12 | _ = fmt.Sprint(x) 13 | } 14 | -------------------------------------------------------------------------------- /simple/s1039/testdata/go1.0/CheckSprintLiteral/CheckSprintLiteral.go.golden: -------------------------------------------------------------------------------- 1 | package pkg 2 | 3 | import "fmt" 4 | 5 | func fn() { 6 | _ = "foo" //@ diag(`unnecessary use of fmt.Sprint`) 7 | _ = "foo" //@ diag(`unnecessary use of fmt.Sprintf`) 8 | _ = fmt.Sprintf("foo %d") 9 | _ = fmt.Sprintf("foo %d", 1) 10 | 11 | var x string 12 | _ = fmt.Sprint(x) 13 | } 14 | -------------------------------------------------------------------------------- /simple/s1040/s1040_test.go: -------------------------------------------------------------------------------- 1 | // Code generated by generate.go. DO NOT EDIT. 2 | 3 | package s1040 4 | 5 | import ( 6 | "testing" 7 | 8 | "honnef.co/go/tools/analysis/lint/testutil" 9 | ) 10 | 11 | func TestTestdata(t *testing.T) { 12 | testutil.Run(t, SCAnalyzer) 13 | } 14 | -------------------------------------------------------------------------------- /staticcheck.conf: -------------------------------------------------------------------------------- 1 | checks = ["inherit", "-SA9003"] 2 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /staticcheck/sa1000/sa1000_test.go: -------------------------------------------------------------------------------- 1 | // Code generated by generate.go. DO NOT EDIT. 2 | 3 | package sa1000 4 | 5 | import ( 6 | "testing" 7 | 8 | "honnef.co/go/tools/analysis/lint/testutil" 9 | ) 10 | 11 | func TestTestdata(t *testing.T) { 12 | testutil.Run(t, SCAnalyzer) 13 | } 14 | -------------------------------------------------------------------------------- /staticcheck/sa1001/sa1001_test.go: -------------------------------------------------------------------------------- 1 | // Code generated by generate.go. DO NOT EDIT. 2 | 3 | package sa1001 4 | 5 | import ( 6 | "testing" 7 | 8 | "honnef.co/go/tools/analysis/lint/testutil" 9 | ) 10 | 11 | func TestTestdata(t *testing.T) { 12 | testutil.Run(t, SCAnalyzer) 13 | } 14 | -------------------------------------------------------------------------------- /staticcheck/sa1001/testdata/go1.0/CheckTemplate/CheckTemplate.go: -------------------------------------------------------------------------------- 1 | package pkg 2 | 3 | import ( 4 | th "html/template" 5 | tt "text/template" 6 | ) 7 | 8 | const tmpl1 = `{{.Name}} {{.LastName}` 9 | const tmpl2 = `{{fn}}` 10 | 11 | func fn() { 12 | tt.New("").Parse(tmpl1) //@ diag(`template`) 13 | tt.New("").Parse(tmpl2) 14 | t1 := tt.New("") 15 | t1.Parse(tmpl1) 16 | th.New("").Parse(tmpl1) //@ diag(`template`) 17 | th.New("").Parse(tmpl2) 18 | t2 := th.New("") 19 | t2.Parse(tmpl1) 20 | tt.New("").Delims("[[", "]]").Parse("{{abc-}}") 21 | } 22 | -------------------------------------------------------------------------------- /staticcheck/sa1002/sa1002_test.go: -------------------------------------------------------------------------------- 1 | // Code generated by generate.go. DO NOT EDIT. 2 | 3 | package sa1002 4 | 5 | import ( 6 | "testing" 7 | 8 | "honnef.co/go/tools/analysis/lint/testutil" 9 | ) 10 | 11 | func TestTestdata(t *testing.T) { 12 | testutil.Run(t, SCAnalyzer) 13 | } 14 | -------------------------------------------------------------------------------- /staticcheck/sa1002/testdata/go1.0/CheckTimeParse/CheckTimeParse.go: -------------------------------------------------------------------------------- 1 | package pkg 2 | 3 | import "time" 4 | 5 | const c1 = "12345" 6 | const c2 = "2006" 7 | 8 | func fn() { 9 | time.Parse("12345", "") //@ diag(`parsing time`) 10 | time.Parse(c1, "") //@ diag(`parsing time`) 11 | time.Parse(c2, "") 12 | time.Parse(time.RFC3339Nano, "") 13 | time.Parse(time.Kitchen, "") 14 | } 15 | -------------------------------------------------------------------------------- /staticcheck/sa1003/sa1003_test.go: -------------------------------------------------------------------------------- 1 | // Code generated by generate.go. DO NOT EDIT. 2 | 3 | package sa1003 4 | 5 | import ( 6 | "testing" 7 | 8 | "honnef.co/go/tools/analysis/lint/testutil" 9 | ) 10 | 11 | func TestTestdata(t *testing.T) { 12 | testutil.Run(t, SCAnalyzer) 13 | } 14 | -------------------------------------------------------------------------------- /staticcheck/sa1003/testdata/go1.7/CheckEncodingBinary/CheckEncodingBinary.go: -------------------------------------------------------------------------------- 1 | package pkg 2 | 3 | import ( 4 | "encoding/binary" 5 | "io/ioutil" 6 | "log" 7 | ) 8 | 9 | func fn() { 10 | var x bool 11 | log.Println(binary.Write(ioutil.Discard, binary.LittleEndian, x)) //@ diag(`cannot be used with binary.Write`) 12 | } 13 | -------------------------------------------------------------------------------- /staticcheck/sa1003/testdata/go1.8/CheckEncodingBinary/CheckEncodingBinary.go: -------------------------------------------------------------------------------- 1 | package pkg 2 | 3 | import ( 4 | "encoding/binary" 5 | "io/ioutil" 6 | ) 7 | 8 | func fn() { 9 | var x bool 10 | binary.Write(ioutil.Discard, binary.LittleEndian, x) 11 | } 12 | -------------------------------------------------------------------------------- /staticcheck/sa1004/sa1004_test.go: -------------------------------------------------------------------------------- 1 | // Code generated by generate.go. DO NOT EDIT. 2 | 3 | package sa1004 4 | 5 | import ( 6 | "testing" 7 | 8 | "honnef.co/go/tools/analysis/lint/testutil" 9 | ) 10 | 11 | func TestTestdata(t *testing.T) { 12 | testutil.Run(t, SCAnalyzer) 13 | } 14 | -------------------------------------------------------------------------------- /staticcheck/sa1004/testdata/go1.0/CheckTimeSleepConstant/CheckTimeSleepConstant.go: -------------------------------------------------------------------------------- 1 | package pkg 2 | 3 | import "time" 4 | 5 | const c1 = 1 6 | const c2 = 200 7 | 8 | func fn() { 9 | time.Sleep(1) //@ diag(`sleeping for 1`) 10 | time.Sleep(42) //@ diag(`sleeping for 42`) 11 | time.Sleep(201) 12 | time.Sleep(c1) 13 | time.Sleep(c2) 14 | time.Sleep(2 * time.Nanosecond) 15 | time.Sleep(time.Nanosecond) 16 | } 17 | -------------------------------------------------------------------------------- /staticcheck/sa1005/sa1005_test.go: -------------------------------------------------------------------------------- 1 | // Code generated by generate.go. DO NOT EDIT. 2 | 3 | package sa1005 4 | 5 | import ( 6 | "testing" 7 | 8 | "honnef.co/go/tools/analysis/lint/testutil" 9 | ) 10 | 11 | func TestTestdata(t *testing.T) { 12 | testutil.Run(t, SCAnalyzer) 13 | } 14 | -------------------------------------------------------------------------------- /staticcheck/sa1005/testdata/go1.0/CheckExec/CheckExec.go: -------------------------------------------------------------------------------- 1 | package pkg 2 | 3 | import "os/exec" 4 | 5 | func fn() { 6 | exec.Command("ls") 7 | exec.Command("ls arg1") //@ diag(`first argument to exec`) 8 | exec.Command(`C:\Program Files\this\is\insane.exe`) 9 | exec.Command("/Library/Application Support/VMware Tools/vmware-tools-daemon") 10 | } 11 | -------------------------------------------------------------------------------- /staticcheck/sa1006/sa1006_test.go: -------------------------------------------------------------------------------- 1 | // Code generated by generate.go. DO NOT EDIT. 2 | 3 | package sa1006 4 | 5 | import ( 6 | "testing" 7 | 8 | "honnef.co/go/tools/analysis/lint/testutil" 9 | ) 10 | 11 | func TestTestdata(t *testing.T) { 12 | testutil.Run(t, SCAnalyzer) 13 | } 14 | -------------------------------------------------------------------------------- /staticcheck/sa1007/sa1007_test.go: -------------------------------------------------------------------------------- 1 | // Code generated by generate.go. DO NOT EDIT. 2 | 3 | package sa1007 4 | 5 | import ( 6 | "testing" 7 | 8 | "honnef.co/go/tools/analysis/lint/testutil" 9 | ) 10 | 11 | func TestTestdata(t *testing.T) { 12 | testutil.Run(t, SCAnalyzer) 13 | } 14 | -------------------------------------------------------------------------------- /staticcheck/sa1007/testdata/go1.0/CheckURLs/CheckURLs.go: -------------------------------------------------------------------------------- 1 | package pkg 2 | 3 | import "net/url" 4 | 5 | func fn() { 6 | url.Parse("foobar") 7 | url.Parse(":") //@ diag(`is not a valid URL`) 8 | url.Parse("https://golang.org") 9 | } 10 | -------------------------------------------------------------------------------- /staticcheck/sa1008/sa1008_test.go: -------------------------------------------------------------------------------- 1 | // Code generated by generate.go. DO NOT EDIT. 2 | 3 | package sa1008 4 | 5 | import ( 6 | "testing" 7 | 8 | "honnef.co/go/tools/analysis/lint/testutil" 9 | ) 10 | 11 | func TestTestdata(t *testing.T) { 12 | testutil.Run(t, SCAnalyzer) 13 | } 14 | -------------------------------------------------------------------------------- /staticcheck/sa1008/testdata/go1.0/CheckCanonicalHeaderKey/CheckCanonicalHeaderKey.go: -------------------------------------------------------------------------------- 1 | package pkg 2 | 3 | import "net/http" 4 | 5 | func fn() { 6 | const hdr = "foo" 7 | var r http.Request 8 | h := http.Header{} 9 | var m map[string][]string 10 | _ = h["foo"] //@ diag(`keys in http.Header are canonicalized`) 11 | _ = h[hdr] //@ diag(`keys in http.Header are canonicalized`) 12 | h["foo"] = nil 13 | _ = r.Header["foo"] //@ diag(`keys in http.Header are canonicalized`) 14 | r.Header["foo"] = nil 15 | _ = m["foo"] 16 | } 17 | -------------------------------------------------------------------------------- /staticcheck/sa1008/testdata/go1.0/CheckCanonicalHeaderKey/CheckCanonicalHeaderKey.go.golden: -------------------------------------------------------------------------------- 1 | package pkg 2 | 3 | import "net/http" 4 | 5 | func fn() { 6 | const hdr = "foo" 7 | var r http.Request 8 | h := http.Header{} 9 | var m map[string][]string 10 | _ = h["Foo"] //@ diag(`keys in http.Header are canonicalized`) 11 | _ = h[http.CanonicalHeaderKey(hdr)] //@ diag(`keys in http.Header are canonicalized`) 12 | h["foo"] = nil 13 | _ = r.Header["Foo"] //@ diag(`keys in http.Header are canonicalized`) 14 | r.Header["foo"] = nil 15 | _ = m["foo"] 16 | } 17 | -------------------------------------------------------------------------------- /staticcheck/sa1010/sa1010_test.go: -------------------------------------------------------------------------------- 1 | // Code generated by generate.go. DO NOT EDIT. 2 | 3 | package sa1010 4 | 5 | import ( 6 | "testing" 7 | 8 | "honnef.co/go/tools/analysis/lint/testutil" 9 | ) 10 | 11 | func TestTestdata(t *testing.T) { 12 | testutil.Run(t, SCAnalyzer) 13 | } 14 | -------------------------------------------------------------------------------- /staticcheck/sa1010/testdata/go1.0/checkStdlibUsageRegexpFindAll/checkStdlibUsageRegexpFindAll.go: -------------------------------------------------------------------------------- 1 | package pkg 2 | 3 | import "regexp" 4 | 5 | func fn() { 6 | var r *regexp.Regexp 7 | _ = r.FindAll(nil, 0) //@ diag(`calling a FindAll method with n == 0 will return no results`) 8 | } 9 | 10 | func fn2() { 11 | regexp.MustCompile("foo(").FindAll(nil, 0) //@ diag(`calling a FindAll`) 12 | } 13 | -------------------------------------------------------------------------------- /staticcheck/sa1011/sa1011_test.go: -------------------------------------------------------------------------------- 1 | // Code generated by generate.go. DO NOT EDIT. 2 | 3 | package sa1011 4 | 5 | import ( 6 | "testing" 7 | 8 | "honnef.co/go/tools/analysis/lint/testutil" 9 | ) 10 | 11 | func TestTestdata(t *testing.T) { 12 | testutil.Run(t, SCAnalyzer) 13 | } 14 | -------------------------------------------------------------------------------- /staticcheck/sa1011/testdata/go1.0/checkStdlibUsageUTF8Cutset/checkStdlibUsageUTF8Cutset.go: -------------------------------------------------------------------------------- 1 | package pkg 2 | 3 | import "strings" 4 | 5 | func fn() { 6 | println(strings.Trim("\x80test\xff", "\xff")) //@ diag(`is not a valid UTF-8 encoded string`) 7 | println(strings.Trim("foo", "bar")) 8 | 9 | s := "\xff" 10 | if true { 11 | s = "" 12 | } 13 | println(strings.Trim("", s)) 14 | } 15 | -------------------------------------------------------------------------------- /staticcheck/sa1012/sa1012_test.go: -------------------------------------------------------------------------------- 1 | // Code generated by generate.go. DO NOT EDIT. 2 | 3 | package sa1012 4 | 5 | import ( 6 | "testing" 7 | 8 | "honnef.co/go/tools/analysis/lint/testutil" 9 | ) 10 | 11 | func TestTestdata(t *testing.T) { 12 | testutil.Run(t, SCAnalyzer) 13 | } 14 | -------------------------------------------------------------------------------- /staticcheck/sa1012/testdata/go1.18/checkStdlibUsageNilContext/checkStdlibUsageNilContext_generics.go: -------------------------------------------------------------------------------- 1 | package pkg 2 | 3 | import "context" 4 | 5 | func tpfn1[T any](ctx context.Context, x T) {} 6 | func tpfn2[T1, T2 any](ctx context.Context, x T1, y T2) {} 7 | 8 | func tpbar() { 9 | tpfn1[int](nil, 0) //@ diag(`do not pass a nil Context`) 10 | tpfn1(nil, 0) //@ diag(`do not pass a nil Context`) 11 | 12 | tpfn2[int, int](nil, 0, 0) //@ diag(`do not pass a nil Context`) 13 | tpfn2(nil, 0, 0) //@ diag(`do not pass a nil Context`) 14 | } 15 | -------------------------------------------------------------------------------- /staticcheck/sa1013/sa1013_test.go: -------------------------------------------------------------------------------- 1 | // Code generated by generate.go. DO NOT EDIT. 2 | 3 | package sa1013 4 | 5 | import ( 6 | "testing" 7 | 8 | "honnef.co/go/tools/analysis/lint/testutil" 9 | ) 10 | 11 | func TestTestdata(t *testing.T) { 12 | testutil.Run(t, SCAnalyzer) 13 | } 14 | -------------------------------------------------------------------------------- /staticcheck/sa1014/sa1014_test.go: -------------------------------------------------------------------------------- 1 | // Code generated by generate.go. DO NOT EDIT. 2 | 3 | package sa1014 4 | 5 | import ( 6 | "testing" 7 | 8 | "honnef.co/go/tools/analysis/lint/testutil" 9 | ) 10 | 11 | func TestTestdata(t *testing.T) { 12 | testutil.Run(t, SCAnalyzer) 13 | } 14 | -------------------------------------------------------------------------------- /staticcheck/sa1015/sa1015_test.go: -------------------------------------------------------------------------------- 1 | // Code generated by generate.go. DO NOT EDIT. 2 | 3 | package sa1015 4 | 5 | import ( 6 | "testing" 7 | 8 | "honnef.co/go/tools/analysis/lint/testutil" 9 | ) 10 | 11 | func TestTestdata(t *testing.T) { 12 | testutil.Run(t, SCAnalyzer) 13 | } 14 | -------------------------------------------------------------------------------- /staticcheck/sa1015/testdata/go1.0/CheckLeakyTimeTick-main/CheckLeakyTimeTick-main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "time" 4 | 5 | func fn2() { 6 | for range time.Tick(0) { 7 | println("") 8 | if true { 9 | break 10 | } 11 | } 12 | } 13 | 14 | func main() { 15 | _ = time.Tick(0) 16 | } 17 | -------------------------------------------------------------------------------- /staticcheck/sa1015/testdata/go1.23/CheckLeakyTimeTick/CheckLeakyTimeTick.go: -------------------------------------------------------------------------------- 1 | package pkg 2 | 3 | import "time" 4 | 5 | func fn1() { 6 | // Not flagged because this is no longer a problem in Go 1.23. 7 | for range time.Tick(0) { 8 | println("") 9 | if true { 10 | break 11 | } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /staticcheck/sa1016/sa1016_test.go: -------------------------------------------------------------------------------- 1 | // Code generated by generate.go. DO NOT EDIT. 2 | 3 | package sa1016 4 | 5 | import ( 6 | "testing" 7 | 8 | "honnef.co/go/tools/analysis/lint/testutil" 9 | ) 10 | 11 | func TestTestdata(t *testing.T) { 12 | testutil.Run(t, SCAnalyzer) 13 | } 14 | -------------------------------------------------------------------------------- /staticcheck/sa1016/testdata/go1.0/CheckUntrappableSignal/CheckUntrappableSignal_unix.go.golden: -------------------------------------------------------------------------------- 1 | //go:build android || darwin || dragonfly || freebsd || linux || netbsd || openbsd || solaris 2 | // +build android darwin dragonfly freebsd linux netbsd openbsd solaris 3 | 4 | package main 5 | 6 | import ( 7 | "os" 8 | "os/signal" 9 | "syscall" 10 | ) 11 | 12 | func fn2() { 13 | c := make(chan os.Signal, 1) 14 | signal.Ignore() //@ diag(`cannot be trapped`) 15 | signal.Notify(c) //@ diag(`cannot be trapped`) 16 | signal.Reset() //@ diag(`cannot be trapped`) 17 | } 18 | -------------------------------------------------------------------------------- /staticcheck/sa1017/sa1017_test.go: -------------------------------------------------------------------------------- 1 | // Code generated by generate.go. DO NOT EDIT. 2 | 3 | package sa1017 4 | 5 | import ( 6 | "testing" 7 | 8 | "honnef.co/go/tools/analysis/lint/testutil" 9 | ) 10 | 11 | func TestTestdata(t *testing.T) { 12 | testutil.Run(t, SCAnalyzer) 13 | } 14 | -------------------------------------------------------------------------------- /staticcheck/sa1017/testdata/go1.0/CheckUnbufferedSignalChan/CheckUnbufferedSignalChan.go: -------------------------------------------------------------------------------- 1 | package pkg 2 | 3 | import ( 4 | "os" 5 | "os/signal" 6 | "syscall" 7 | ) 8 | 9 | func fn(b bool) { 10 | c0 := make(chan os.Signal) 11 | signal.Notify(c0, os.Interrupt) //@ diag(`the channel used with signal.Notify should be buffered`) 12 | 13 | c1 := make(chan os.Signal, 1) 14 | signal.Notify(c1, os.Interrupt, syscall.SIGHUP) 15 | 16 | c2 := c0 17 | if b { 18 | c2 = c1 19 | } 20 | signal.Notify(c2, os.Interrupt, syscall.SIGHUP) 21 | } 22 | -------------------------------------------------------------------------------- /staticcheck/sa1018/sa1018_test.go: -------------------------------------------------------------------------------- 1 | // Code generated by generate.go. DO NOT EDIT. 2 | 3 | package sa1018 4 | 5 | import ( 6 | "testing" 7 | 8 | "honnef.co/go/tools/analysis/lint/testutil" 9 | ) 10 | 11 | func TestTestdata(t *testing.T) { 12 | testutil.Run(t, SCAnalyzer) 13 | } 14 | -------------------------------------------------------------------------------- /staticcheck/sa1018/testdata/go1.0/CheckStringsReplaceZero/CheckStringsReplaceZero.go: -------------------------------------------------------------------------------- 1 | package pkg 2 | 3 | import "strings" 4 | 5 | func fn() { 6 | _ = strings.Replace("", "", "", 0) //@ diag(`calling strings.Replace with n == 0`) 7 | _ = strings.Replace("", "", "", -1) 8 | _ = strings.Replace("", "", "", 1) 9 | } 10 | -------------------------------------------------------------------------------- /staticcheck/sa1019/sa1019_test.go: -------------------------------------------------------------------------------- 1 | // Code generated by generate.go. DO NOT EDIT. 2 | 3 | package sa1019 4 | 5 | import ( 6 | "testing" 7 | 8 | "honnef.co/go/tools/analysis/lint/testutil" 9 | ) 10 | 11 | func TestTestdata(t *testing.T) { 12 | testutil.Run(t, SCAnalyzer) 13 | } 14 | -------------------------------------------------------------------------------- /staticcheck/sa1019/testdata/go1.0/AnotherCheckDeprecated.assist/CheckDeprecatedassist.go: -------------------------------------------------------------------------------- 1 | // Package pkg is a nice package. 2 | // 3 | // Deprecated: Alas, it is deprecated. 4 | package AnotherCheckDeprecatedassist 5 | 6 | func Fn() {} 7 | -------------------------------------------------------------------------------- /staticcheck/sa1019/testdata/go1.0/CheckDeprecated.assist/CheckDeprecatedassist.go: -------------------------------------------------------------------------------- 1 | // Package pkg is a nice package. 2 | // 3 | // Deprecated: Alas, it is deprecated. 4 | package pkg 5 | -------------------------------------------------------------------------------- /staticcheck/sa1019/testdata/go1.0/CheckDeprecated/not-protobuf.go: -------------------------------------------------------------------------------- 1 | package pkg 2 | 3 | import _ "github.com/golang/protobuf/proto" //@ diag(`Alas, it is deprecated.`) 4 | -------------------------------------------------------------------------------- /staticcheck/sa1019/testdata/go1.0/CheckDeprecated/protobuf.go: -------------------------------------------------------------------------------- 1 | // Code generated by protoc-gen-go. DO NOT EDIT. 2 | 3 | package pkg 4 | 5 | import _ "github.com/golang/protobuf/proto" 6 | -------------------------------------------------------------------------------- /staticcheck/sa1019/testdata/go1.0/vendor/github.com/golang/protobuf/proto/pkg.go: -------------------------------------------------------------------------------- 1 | // Package proto exists. 2 | // 3 | // Deprecated: Alas, it is deprecated. 4 | package proto 5 | -------------------------------------------------------------------------------- /staticcheck/sa1019/testdata/go1.18/CheckDeprecated.assist/CheckDeprecatedassist_generics.go: -------------------------------------------------------------------------------- 1 | package pkg 2 | 3 | type S[T any] struct { 4 | Field1 T 5 | // Deprecated: don't use me 6 | Field2 T 7 | } 8 | 9 | func (S[T]) Foo() {} 10 | 11 | // Deprecated: don't use me 12 | func (S[T]) Bar() {} 13 | 14 | // Deprecated: don't use me 15 | func (S[T]) Baz() {} 16 | 17 | func (S[T]) Qux() {} 18 | -------------------------------------------------------------------------------- /staticcheck/sa1019/testdata/go1.18/CheckDeprecated/CheckDeprecated_generics.go: -------------------------------------------------------------------------------- 1 | package pkg 2 | 3 | import pkg "example.com/CheckDeprecated.assist" 4 | 5 | func tpFn() { 6 | var x pkg.S[int] 7 | x.Foo() 8 | x.Bar() //@ diag(`deprecated`) 9 | x.Baz() //@ diag(`deprecated`) 10 | x.Qux() 11 | _ = x.Field1 12 | _ = x.Field2 // This should be flagged, but see issue 1215 13 | } 14 | -------------------------------------------------------------------------------- /staticcheck/sa1019/testdata/go1.19/CheckDeprecated/CheckDeprecated.go: -------------------------------------------------------------------------------- 1 | package pkg 2 | 3 | import _ "io/ioutil" //@ diag("has been deprecated") 4 | 5 | // We test this in Go 1.19 even though io/ioutil has technically been deprecated since Go 1.16, because only in Go 1.19 6 | // was the proper deprecation marker added. 7 | -------------------------------------------------------------------------------- /staticcheck/sa1019/testdata/go1.19/CheckDeprecated/stub.go: -------------------------------------------------------------------------------- 1 | package pkg 2 | -------------------------------------------------------------------------------- /staticcheck/sa1019/testdata/go1.3/CheckDeprecated/CheckDeprecated.go: -------------------------------------------------------------------------------- 1 | package pkg 2 | 3 | import ( 4 | "crypto/x509" 5 | "net/http/httputil" 6 | "path/filepath" 7 | ) 8 | 9 | func fn() { 10 | filepath.HasPrefix("", "") //@ diag(`filepath.HasPrefix has been deprecated since Go 1.0 because it shouldn't be used:`) 11 | _ = httputil.ErrPersistEOF //@ diag(`httputil.ErrPersistEOF has been deprecated since Go 1.0:`) 12 | _ = httputil.ServerConn{} //@ diag(`httputil.ServerConn has been deprecated since Go 1.0:`) 13 | _ = x509.CertificateRequest{}.Attributes 14 | } 15 | -------------------------------------------------------------------------------- /staticcheck/sa1020/sa1020_test.go: -------------------------------------------------------------------------------- 1 | // Code generated by generate.go. DO NOT EDIT. 2 | 3 | package sa1020 4 | 5 | import ( 6 | "testing" 7 | 8 | "honnef.co/go/tools/analysis/lint/testutil" 9 | ) 10 | 11 | func TestTestdata(t *testing.T) { 12 | testutil.Run(t, SCAnalyzer) 13 | } 14 | -------------------------------------------------------------------------------- /staticcheck/sa1021/sa1021_test.go: -------------------------------------------------------------------------------- 1 | // Code generated by generate.go. DO NOT EDIT. 2 | 3 | package sa1021 4 | 5 | import ( 6 | "testing" 7 | 8 | "honnef.co/go/tools/analysis/lint/testutil" 9 | ) 10 | 11 | func TestTestdata(t *testing.T) { 12 | testutil.Run(t, SCAnalyzer) 13 | } 14 | -------------------------------------------------------------------------------- /staticcheck/sa1021/testdata/go1.0/CheckBytesEqualIP/CheckBytesEqualIP.go: -------------------------------------------------------------------------------- 1 | package pkg 2 | 3 | import ( 4 | "bytes" 5 | "net" 6 | ) 7 | 8 | func fn() { 9 | type T []byte 10 | var i1, i2 net.IP 11 | var b1, b2 []byte 12 | var t1, t2 T 13 | 14 | bytes.Equal(i1, i2) //@ diag(`use net.IP.Equal to compare net.IPs, not bytes.Equal`) 15 | bytes.Equal(b1, b2) 16 | bytes.Equal(t1, t2) 17 | 18 | bytes.Equal(i1, b1) 19 | bytes.Equal(b1, i1) 20 | } 21 | -------------------------------------------------------------------------------- /staticcheck/sa1023/sa1023_test.go: -------------------------------------------------------------------------------- 1 | // Code generated by generate.go. DO NOT EDIT. 2 | 3 | package sa1023 4 | 5 | import ( 6 | "testing" 7 | 8 | "honnef.co/go/tools/analysis/lint/testutil" 9 | ) 10 | 11 | func TestTestdata(t *testing.T) { 12 | testutil.Run(t, SCAnalyzer) 13 | } 14 | -------------------------------------------------------------------------------- /staticcheck/sa1024/sa1024_test.go: -------------------------------------------------------------------------------- 1 | // Code generated by generate.go. DO NOT EDIT. 2 | 3 | package sa1024 4 | 5 | import ( 6 | "testing" 7 | 8 | "honnef.co/go/tools/analysis/lint/testutil" 9 | ) 10 | 11 | func TestTestdata(t *testing.T) { 12 | testutil.Run(t, SCAnalyzer) 13 | } 14 | -------------------------------------------------------------------------------- /staticcheck/sa1024/testdata/go1.0/CheckNonUniqueCutset/CheckNonUniqueCutset.go: -------------------------------------------------------------------------------- 1 | package pkg 2 | 3 | import "strings" 4 | 5 | func fn(s string) { 6 | _ = strings.TrimLeft(s, "") 7 | _ = strings.TrimLeft(s, "a") 8 | _ = strings.TrimLeft(s, "µ") 9 | _ = strings.TrimLeft(s, "abc") 10 | _ = strings.TrimLeft(s, "http://") //@ diag(`duplicate characters`) 11 | } 12 | -------------------------------------------------------------------------------- /staticcheck/sa1025/sa1025_test.go: -------------------------------------------------------------------------------- 1 | // Code generated by generate.go. DO NOT EDIT. 2 | 3 | package sa1025 4 | 5 | import ( 6 | "testing" 7 | 8 | "honnef.co/go/tools/analysis/lint/testutil" 9 | ) 10 | 11 | func TestTestdata(t *testing.T) { 12 | testutil.Run(t, SCAnalyzer) 13 | } 14 | -------------------------------------------------------------------------------- /staticcheck/sa1026/sa1026_test.go: -------------------------------------------------------------------------------- 1 | // Code generated by generate.go. DO NOT EDIT. 2 | 3 | package sa1026 4 | 5 | import ( 6 | "testing" 7 | 8 | "honnef.co/go/tools/analysis/lint/testutil" 9 | ) 10 | 11 | func TestTestdata(t *testing.T) { 12 | testutil.Run(t, SCAnalyzer) 13 | } 14 | -------------------------------------------------------------------------------- /staticcheck/sa1027/sa1027_test.go: -------------------------------------------------------------------------------- 1 | // Code generated by generate.go. DO NOT EDIT. 2 | 3 | package sa1027 4 | 5 | import ( 6 | "testing" 7 | 8 | "honnef.co/go/tools/analysis/lint/testutil" 9 | ) 10 | 11 | func TestTestdata(t *testing.T) { 12 | testutil.Run(t, SCAnalyzer) 13 | } 14 | -------------------------------------------------------------------------------- /staticcheck/sa1027/testdata/go1.0/CheckAtomicAlignment/atomic64.go: -------------------------------------------------------------------------------- 1 | // +build amd64 amd64p32 arm64 ppc64 ppc64le mips64 mips64le mips64p32 mips64p32le sparc64 riscv64 loong64 2 | 3 | package pkg 4 | 5 | import "sync/atomic" 6 | 7 | type T struct { 8 | A int64 9 | B int32 10 | C int64 11 | } 12 | 13 | func fn() { 14 | var v T 15 | atomic.AddInt64(&v.A, 0) 16 | atomic.AddInt64(&v.C, 0) 17 | atomic.LoadInt64(&v.C) 18 | } 19 | -------------------------------------------------------------------------------- /staticcheck/sa1028/sa1028_test.go: -------------------------------------------------------------------------------- 1 | // Code generated by generate.go. DO NOT EDIT. 2 | 3 | package sa1028 4 | 5 | import ( 6 | "testing" 7 | 8 | "honnef.co/go/tools/analysis/lint/testutil" 9 | ) 10 | 11 | func TestTestdata(t *testing.T) { 12 | testutil.Run(t, SCAnalyzer) 13 | } 14 | -------------------------------------------------------------------------------- /staticcheck/sa1029/sa1029_test.go: -------------------------------------------------------------------------------- 1 | // Code generated by generate.go. DO NOT EDIT. 2 | 3 | package sa1029 4 | 5 | import ( 6 | "testing" 7 | 8 | "honnef.co/go/tools/analysis/lint/testutil" 9 | ) 10 | 11 | func TestTestdata(t *testing.T) { 12 | testutil.Run(t, SCAnalyzer) 13 | } 14 | -------------------------------------------------------------------------------- /staticcheck/sa1030/sa1030_test.go: -------------------------------------------------------------------------------- 1 | // Code generated by generate.go. DO NOT EDIT. 2 | 3 | package sa1030 4 | 5 | import ( 6 | "testing" 7 | 8 | "honnef.co/go/tools/analysis/lint/testutil" 9 | ) 10 | 11 | func TestTestdata(t *testing.T) { 12 | testutil.Run(t, SCAnalyzer) 13 | } 14 | -------------------------------------------------------------------------------- /staticcheck/sa1030/testdata/go1.15/CheckStrconv/stub.go: -------------------------------------------------------------------------------- 1 | package pkg 2 | -------------------------------------------------------------------------------- /staticcheck/sa1031/sa1031_test.go: -------------------------------------------------------------------------------- 1 | // Code generated by generate.go. DO NOT EDIT. 2 | 3 | package sa1031 4 | 5 | import ( 6 | "testing" 7 | 8 | "honnef.co/go/tools/analysis/lint/testutil" 9 | ) 10 | 11 | func TestTestdata(t *testing.T) { 12 | testutil.Run(t, SCAnalyzer) 13 | } 14 | -------------------------------------------------------------------------------- /staticcheck/sa1032/sa1032_test.go: -------------------------------------------------------------------------------- 1 | // Code generated by generate.go. DO NOT EDIT. 2 | 3 | package sa1032 4 | 5 | import ( 6 | "testing" 7 | 8 | "honnef.co/go/tools/analysis/lint/testutil" 9 | ) 10 | 11 | func TestTestdata(t *testing.T) { 12 | testutil.Run(t, SCAnalyzer) 13 | } 14 | -------------------------------------------------------------------------------- /staticcheck/sa2000/sa2000_test.go: -------------------------------------------------------------------------------- 1 | // Code generated by generate.go. DO NOT EDIT. 2 | 3 | package sa2000 4 | 5 | import ( 6 | "testing" 7 | 8 | "honnef.co/go/tools/analysis/lint/testutil" 9 | ) 10 | 11 | func TestTestdata(t *testing.T) { 12 | testutil.Run(t, SCAnalyzer) 13 | } 14 | -------------------------------------------------------------------------------- /staticcheck/sa2001/sa2001_test.go: -------------------------------------------------------------------------------- 1 | // Code generated by generate.go. DO NOT EDIT. 2 | 3 | package sa2001 4 | 5 | import ( 6 | "testing" 7 | 8 | "honnef.co/go/tools/analysis/lint/testutil" 9 | ) 10 | 11 | func TestTestdata(t *testing.T) { 12 | testutil.Run(t, SCAnalyzer) 13 | } 14 | -------------------------------------------------------------------------------- /staticcheck/sa2002/sa2002_test.go: -------------------------------------------------------------------------------- 1 | // Code generated by generate.go. DO NOT EDIT. 2 | 3 | package sa2002 4 | 5 | import ( 6 | "testing" 7 | 8 | "honnef.co/go/tools/analysis/lint/testutil" 9 | ) 10 | 11 | func TestTestdata(t *testing.T) { 12 | testutil.Run(t, SCAnalyzer) 13 | } 14 | -------------------------------------------------------------------------------- /staticcheck/sa2003/sa2003_test.go: -------------------------------------------------------------------------------- 1 | // Code generated by generate.go. DO NOT EDIT. 2 | 3 | package sa2003 4 | 5 | import ( 6 | "testing" 7 | 8 | "honnef.co/go/tools/analysis/lint/testutil" 9 | ) 10 | 11 | func TestTestdata(t *testing.T) { 12 | testutil.Run(t, SCAnalyzer) 13 | } 14 | -------------------------------------------------------------------------------- /staticcheck/sa3000/sa3000_test.go: -------------------------------------------------------------------------------- 1 | // Code generated by generate.go. DO NOT EDIT. 2 | 3 | package sa3000 4 | 5 | import ( 6 | "testing" 7 | 8 | "honnef.co/go/tools/analysis/lint/testutil" 9 | ) 10 | 11 | func TestTestdata(t *testing.T) { 12 | testutil.Run(t, SCAnalyzer) 13 | } 14 | -------------------------------------------------------------------------------- /staticcheck/sa3000/testdata/go1.15/CheckTestMainExit-1/CheckTestMainExit-1.go: -------------------------------------------------------------------------------- 1 | package pkg 2 | 3 | import "testing" 4 | 5 | func TestMain(m *testing.M) { 6 | m.Run() 7 | } 8 | -------------------------------------------------------------------------------- /staticcheck/sa3000/testdata/go1.4/CheckTestMainExit-1/CheckTestMainExit-1.go: -------------------------------------------------------------------------------- 1 | package pkg 2 | 3 | import "testing" 4 | 5 | func TestMain(m *testing.M) { //@ diag(`should call os.Exit`) 6 | m.Run() 7 | } 8 | -------------------------------------------------------------------------------- /staticcheck/sa3000/testdata/go1.4/CheckTestMainExit-2/CheckTestMainExit-2.go: -------------------------------------------------------------------------------- 1 | package pkg 2 | 3 | import ( 4 | "os" 5 | "testing" 6 | ) 7 | 8 | func TestMain(m *testing.M) { 9 | m.Run() 10 | os.Exit(1) 11 | } 12 | -------------------------------------------------------------------------------- /staticcheck/sa3000/testdata/go1.4/CheckTestMainExit-3/CheckTestMainExit-3.go: -------------------------------------------------------------------------------- 1 | package pkg 2 | 3 | import "testing" 4 | 5 | func TestMain(t *testing.T) { 6 | } 7 | -------------------------------------------------------------------------------- /staticcheck/sa3000/testdata/go1.4/CheckTestMainExit-4/CheckTestMainExit-4.go: -------------------------------------------------------------------------------- 1 | package pkg 2 | 3 | import ( 4 | "os" 5 | "testing" 6 | ) 7 | 8 | func helper() { os.Exit(1) } 9 | 10 | func TestMain(m *testing.M) { //@ diag(`should call os.Exit`) 11 | // FIXME(dominikh): this is a false positive 12 | m.Run() 13 | helper() 14 | } 15 | -------------------------------------------------------------------------------- /staticcheck/sa3000/testdata/go1.4/CheckTestMainExit-5/CheckTestMainExit-5.go: -------------------------------------------------------------------------------- 1 | package pkg 2 | 3 | import ( 4 | "os" 5 | "testing" 6 | ) 7 | 8 | func helper(m *testing.M) { os.Exit(m.Run()) } 9 | 10 | func TestMain(m *testing.M) { 11 | helper(m) 12 | } 13 | -------------------------------------------------------------------------------- /staticcheck/sa3001/sa3001_test.go: -------------------------------------------------------------------------------- 1 | // Code generated by generate.go. DO NOT EDIT. 2 | 3 | package sa3001 4 | 5 | import ( 6 | "testing" 7 | 8 | "honnef.co/go/tools/analysis/lint/testutil" 9 | ) 10 | 11 | func TestTestdata(t *testing.T) { 12 | testutil.Run(t, SCAnalyzer) 13 | } 14 | -------------------------------------------------------------------------------- /staticcheck/sa3001/testdata/go1.0/CheckBenchmarkN/CheckBenchmarkN.go: -------------------------------------------------------------------------------- 1 | package foo 2 | 3 | import "testing" 4 | 5 | func foo() { 6 | var b *testing.B 7 | b.N = 1 //@ diag(`should not assign to b.N`) 8 | _ = b 9 | } 10 | -------------------------------------------------------------------------------- /staticcheck/sa4000/sa4000_test.go: -------------------------------------------------------------------------------- 1 | // Code generated by generate.go. DO NOT EDIT. 2 | 3 | package sa4000 4 | 5 | import ( 6 | "testing" 7 | 8 | "honnef.co/go/tools/analysis/lint/testutil" 9 | ) 10 | 11 | func TestTestdata(t *testing.T) { 12 | testutil.Run(t, SCAnalyzer) 13 | } 14 | -------------------------------------------------------------------------------- /staticcheck/sa4000/testdata/go1.0/CheckLhsRhsIdentical/cgo.go: -------------------------------------------------------------------------------- 1 | package pkg 2 | 3 | // void foo(void **p) {} 4 | import "C" 5 | import "unsafe" 6 | 7 | func Foo() { 8 | var p unsafe.Pointer 9 | 10 | C.foo(&p) 11 | if 0 == 0 { 12 | // We don't currently flag this instance of 0 == 0 because of 13 | // our cgo-specific exception. 14 | println() 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /staticcheck/sa4000/testdata/go1.18/CheckLhsRhsIdentical/generics.go: -------------------------------------------------------------------------------- 1 | package pkg 2 | 3 | func tpfn1[T comparable](x T) { 4 | if x != x { 5 | } 6 | } 7 | 8 | func tpfn2[T int | string](x T) { 9 | if x != x { //@ diag(`identical expressions`) 10 | } 11 | } 12 | 13 | func tpfn3[T int | float64](x T) { 14 | if x != x { 15 | } 16 | } 17 | 18 | func tpfn4[E int | int64, T [4]E](x T) { 19 | if x != x { //@ diag(`identical expressions`) 20 | } 21 | } 22 | 23 | func tpfn5[E int | float64, T [4]E](x T) { 24 | if x != x { 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /staticcheck/sa4001/sa4001_test.go: -------------------------------------------------------------------------------- 1 | // Code generated by generate.go. DO NOT EDIT. 2 | 3 | package sa4001 4 | 5 | import ( 6 | "testing" 7 | 8 | "honnef.co/go/tools/analysis/lint/testutil" 9 | ) 10 | 11 | func TestTestdata(t *testing.T) { 12 | testutil.Run(t, SCAnalyzer) 13 | } 14 | -------------------------------------------------------------------------------- /staticcheck/sa4001/testdata/go1.0/CheckIneffectiveCopy/CheckIneffectiveCopy.go: -------------------------------------------------------------------------------- 1 | package pkg 2 | 3 | type T struct{} 4 | 5 | func fn1(_ *T) {} 6 | 7 | func fn2() { 8 | t1 := &T{} 9 | fn1(&*t1) //@ diag(`will not copy`) 10 | fn1(*&t1) //@ diag(`will not copy`) 11 | 12 | _Cvar_something := &T{} 13 | fn1(&*_Cvar_something) 14 | } 15 | -------------------------------------------------------------------------------- /staticcheck/sa4003/sa4003_test.go: -------------------------------------------------------------------------------- 1 | // Code generated by generate.go. DO NOT EDIT. 2 | 3 | package sa4003 4 | 5 | import ( 6 | "testing" 7 | 8 | "honnef.co/go/tools/analysis/lint/testutil" 9 | ) 10 | 11 | func TestTestdata(t *testing.T) { 12 | testutil.Run(t, SCAnalyzer) 13 | } 14 | -------------------------------------------------------------------------------- /staticcheck/sa4004/sa4004_test.go: -------------------------------------------------------------------------------- 1 | // Code generated by generate.go. DO NOT EDIT. 2 | 3 | package sa4004 4 | 5 | import ( 6 | "testing" 7 | 8 | "honnef.co/go/tools/analysis/lint/testutil" 9 | ) 10 | 11 | func TestTestdata(t *testing.T) { 12 | testutil.Run(t, SCAnalyzer) 13 | } 14 | -------------------------------------------------------------------------------- /staticcheck/sa4005/sa4005_test.go: -------------------------------------------------------------------------------- 1 | // Code generated by generate.go. DO NOT EDIT. 2 | 3 | package sa4005 4 | 5 | import ( 6 | "testing" 7 | 8 | "honnef.co/go/tools/analysis/lint/testutil" 9 | ) 10 | 11 | func TestTestdata(t *testing.T) { 12 | testutil.Run(t, SCAnalyzer) 13 | } 14 | -------------------------------------------------------------------------------- /staticcheck/sa4006/sa4006_test.go: -------------------------------------------------------------------------------- 1 | // Code generated by generate.go. DO NOT EDIT. 2 | 3 | package sa4006 4 | 5 | import ( 6 | "testing" 7 | 8 | "honnef.co/go/tools/analysis/lint/testutil" 9 | ) 10 | 11 | func TestTestdata(t *testing.T) { 12 | testutil.Run(t, SCAnalyzer) 13 | } 14 | -------------------------------------------------------------------------------- /staticcheck/sa4006/testdata/go1.0/CheckUnreadVariableValues/CheckUnreadVariableValues_test.go: -------------------------------------------------------------------------------- 1 | package pkg 2 | 3 | import "testing" 4 | 5 | func TestFoo(t *testing.T) { 6 | x := fn() //@ diag(`never used`) 7 | x = fn() 8 | println(x) 9 | } 10 | 11 | func ExampleFoo() { 12 | x := fn() 13 | x = fn() 14 | println(x) 15 | } 16 | -------------------------------------------------------------------------------- /staticcheck/sa4008/sa4008_test.go: -------------------------------------------------------------------------------- 1 | // Code generated by generate.go. DO NOT EDIT. 2 | 3 | package sa4008 4 | 5 | import ( 6 | "testing" 7 | 8 | "honnef.co/go/tools/analysis/lint/testutil" 9 | ) 10 | 11 | func TestTestdata(t *testing.T) { 12 | testutil.Run(t, SCAnalyzer) 13 | } 14 | -------------------------------------------------------------------------------- /staticcheck/sa4008/testdata/go1.0/CheckLoopCondition/CheckLoopCondition.go: -------------------------------------------------------------------------------- 1 | package pkg 2 | 3 | func fn() { 4 | for i := 0; i < 10; i++ { 5 | for j := 0; j < 10; i++ { //@ diag(`variable in loop condition never changes`) 6 | } 7 | } 8 | 9 | counter := 0 10 | for i := 0; i < 10; i++ { 11 | for j := 0; j < 10; counter++ { 12 | x := &j 13 | *x++ 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /staticcheck/sa4009/sa4009_test.go: -------------------------------------------------------------------------------- 1 | // Code generated by generate.go. DO NOT EDIT. 2 | 3 | package sa4009 4 | 5 | import ( 6 | "testing" 7 | 8 | "honnef.co/go/tools/analysis/lint/testutil" 9 | ) 10 | 11 | func TestTestdata(t *testing.T) { 12 | testutil.Run(t, SCAnalyzer) 13 | } 14 | -------------------------------------------------------------------------------- /staticcheck/sa4009/testdata/go1.0/CheckArgOverwritten/CheckArgOverwritten.go: -------------------------------------------------------------------------------- 1 | package pkg 2 | 3 | var x = func(arg int) { //@ diag(`overwritten`) 4 | arg = 1 5 | println(arg) 6 | } 7 | -------------------------------------------------------------------------------- /staticcheck/sa4010/sa4010_test.go: -------------------------------------------------------------------------------- 1 | // Code generated by generate.go. DO NOT EDIT. 2 | 3 | package sa4010 4 | 5 | import ( 6 | "testing" 7 | 8 | "honnef.co/go/tools/analysis/lint/testutil" 9 | ) 10 | 11 | func TestTestdata(t *testing.T) { 12 | testutil.Run(t, SCAnalyzer) 13 | } 14 | -------------------------------------------------------------------------------- /staticcheck/sa4011/sa4011_test.go: -------------------------------------------------------------------------------- 1 | // Code generated by generate.go. DO NOT EDIT. 2 | 3 | package sa4011 4 | 5 | import ( 6 | "testing" 7 | 8 | "honnef.co/go/tools/analysis/lint/testutil" 9 | ) 10 | 11 | func TestTestdata(t *testing.T) { 12 | testutil.Run(t, SCAnalyzer) 13 | } 14 | -------------------------------------------------------------------------------- /staticcheck/sa4012/sa4012_test.go: -------------------------------------------------------------------------------- 1 | // Code generated by generate.go. DO NOT EDIT. 2 | 3 | package sa4012 4 | 5 | import ( 6 | "testing" 7 | 8 | "honnef.co/go/tools/analysis/lint/testutil" 9 | ) 10 | 11 | func TestTestdata(t *testing.T) { 12 | testutil.Run(t, SCAnalyzer) 13 | } 14 | -------------------------------------------------------------------------------- /staticcheck/sa4012/testdata/go1.0/CheckNaNComparison/CheckNaNComparison.go: -------------------------------------------------------------------------------- 1 | package pkg 2 | 3 | import "math" 4 | 5 | func fn(f float64) { 6 | _ = f == math.NaN() //@ diag(`no value is equal to NaN`) 7 | _ = f > math.NaN() //@ diag(`no value is equal to NaN`) 8 | _ = f != math.NaN() //@ diag(`no value is equal to NaN`) 9 | } 10 | 11 | func fn2(f float64) { 12 | x := math.NaN() 13 | if true { 14 | if f == x { //@ diag(`no value is equal to NaN`) 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /staticcheck/sa4013/sa4013_test.go: -------------------------------------------------------------------------------- 1 | // Code generated by generate.go. DO NOT EDIT. 2 | 3 | package sa4013 4 | 5 | import ( 6 | "testing" 7 | 8 | "honnef.co/go/tools/analysis/lint/testutil" 9 | ) 10 | 11 | func TestTestdata(t *testing.T) { 12 | testutil.Run(t, SCAnalyzer) 13 | } 14 | -------------------------------------------------------------------------------- /staticcheck/sa4013/testdata/go1.0/CheckDoubleNegation/CheckDoubleNegation.go: -------------------------------------------------------------------------------- 1 | package pkg 2 | 3 | func fn(b1, b2 bool) { 4 | if !!b1 { //@ diag(`negating a boolean twice`) 5 | println() 6 | } 7 | 8 | if b1 && !!b2 { //@ diag(`negating a boolean twice`) 9 | println() 10 | } 11 | 12 | if !(!b1) { //@ diag(`negating a boolean twice`) 13 | println() 14 | } 15 | 16 | if !b1 { 17 | println() 18 | } 19 | 20 | if !b1 && !b2 { 21 | println() 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /staticcheck/sa4014/sa4014_test.go: -------------------------------------------------------------------------------- 1 | // Code generated by generate.go. DO NOT EDIT. 2 | 3 | package sa4014 4 | 5 | import ( 6 | "testing" 7 | 8 | "honnef.co/go/tools/analysis/lint/testutil" 9 | ) 10 | 11 | func TestTestdata(t *testing.T) { 12 | testutil.Run(t, SCAnalyzer) 13 | } 14 | -------------------------------------------------------------------------------- /staticcheck/sa4015/sa4015_test.go: -------------------------------------------------------------------------------- 1 | // Code generated by generate.go. DO NOT EDIT. 2 | 3 | package sa4015 4 | 5 | import ( 6 | "testing" 7 | 8 | "honnef.co/go/tools/analysis/lint/testutil" 9 | ) 10 | 11 | func TestTestdata(t *testing.T) { 12 | testutil.Run(t, SCAnalyzer) 13 | } 14 | -------------------------------------------------------------------------------- /staticcheck/sa4015/testdata/go1.0/CheckMathInt/CheckMathInt.go: -------------------------------------------------------------------------------- 1 | package pkg 2 | 3 | import "math" 4 | 5 | func fn(x int) { 6 | math.Ceil(float64(x)) //@ diag(`on a converted integer is pointless`) 7 | math.Floor(float64(x * 2)) //@ diag(`on a converted integer is pointless`) 8 | } 9 | -------------------------------------------------------------------------------- /staticcheck/sa4015/testdata/go1.18/CheckMathInt/CheckMathInt.go: -------------------------------------------------------------------------------- 1 | package pkg 2 | 3 | import "math" 4 | 5 | func fn3[S int8 | int16](x S) { 6 | math.Ceil(float64(x)) //@ diag(`on a converted integer is pointless`) 7 | } 8 | 9 | func fn4[S int8 | int16 | float32](x S) { 10 | math.Ceil(float64(x)) 11 | } 12 | -------------------------------------------------------------------------------- /staticcheck/sa4016/sa4016_test.go: -------------------------------------------------------------------------------- 1 | // Code generated by generate.go. DO NOT EDIT. 2 | 3 | package sa4016 4 | 5 | import ( 6 | "testing" 7 | 8 | "honnef.co/go/tools/analysis/lint/testutil" 9 | ) 10 | 11 | func TestTestdata(t *testing.T) { 12 | testutil.Run(t, SCAnalyzer) 13 | } 14 | -------------------------------------------------------------------------------- /staticcheck/sa4016/testdata/go1.0/CheckSillyBitwiseOps_dotImport/foo.go: -------------------------------------------------------------------------------- 1 | package foo 2 | 3 | const X = 0 4 | -------------------------------------------------------------------------------- /staticcheck/sa4016/testdata/go1.0/CheckSillyBitwiseOps_dotImport/foo_test.go: -------------------------------------------------------------------------------- 1 | package foo_test 2 | 3 | import . "example.com/CheckSillyBitwiseOps_dotImport" 4 | 5 | var _ = 1 | X 6 | -------------------------------------------------------------------------------- /staticcheck/sa4016/testdata/go1.0/CheckSillyBitwiseOps_shadowedIota/shadowed.go: -------------------------------------------------------------------------------- 1 | package pkg 2 | 3 | const iota = 0 4 | 5 | const ( 6 | a = iota 7 | ) 8 | 9 | func fn(x int) { 10 | _ = x | a 11 | } 12 | -------------------------------------------------------------------------------- /staticcheck/sa4016/testdata/go1.18/CheckSillyBitwiseOps/generics.go: -------------------------------------------------------------------------------- 1 | package pkg 2 | 3 | func tpfn[T int](x T) { 4 | _ = x & 0 //@ diag(`always equals 0`) 5 | } 6 | -------------------------------------------------------------------------------- /staticcheck/sa4017/sa4017_test.go: -------------------------------------------------------------------------------- 1 | // Code generated by generate.go. DO NOT EDIT. 2 | 3 | package sa4017 4 | 5 | import ( 6 | "testing" 7 | 8 | "honnef.co/go/tools/analysis/lint/testutil" 9 | ) 10 | 11 | func TestTestdata(t *testing.T) { 12 | testutil.Run(t, SCAnalyzer) 13 | } 14 | -------------------------------------------------------------------------------- /staticcheck/sa4017/testdata/go1.0/CheckSideEffectFreeCalls/CheckSideEffectFreeCalls_test.go: -------------------------------------------------------------------------------- 1 | package pkg 2 | 3 | import ( 4 | "strings" 5 | "testing" 6 | ) 7 | 8 | func TestFoo(t *testing.T) { 9 | strings.Replace("", "", "", 1) //@ diag(`doesn't have side effects`) 10 | } 11 | 12 | func BenchmarkFoo(b *testing.B) { 13 | strings.Replace("", "", "", 1) 14 | } 15 | 16 | func doBenchmark(s string, b *testing.B) { 17 | strings.Replace("", "", "", 1) 18 | } 19 | 20 | func BenchmarkBar(b *testing.B) { 21 | doBenchmark("", b) 22 | } 23 | -------------------------------------------------------------------------------- /staticcheck/sa4018/sa4018_test.go: -------------------------------------------------------------------------------- 1 | // Code generated by generate.go. DO NOT EDIT. 2 | 3 | package sa4018 4 | 5 | import ( 6 | "testing" 7 | 8 | "honnef.co/go/tools/analysis/lint/testutil" 9 | ) 10 | 11 | func TestTestdata(t *testing.T) { 12 | testutil.Run(t, SCAnalyzer) 13 | } 14 | -------------------------------------------------------------------------------- /staticcheck/sa4019/sa4019_test.go: -------------------------------------------------------------------------------- 1 | // Code generated by generate.go. DO NOT EDIT. 2 | 3 | package sa4019 4 | 5 | import ( 6 | "testing" 7 | 8 | "honnef.co/go/tools/analysis/lint/testutil" 9 | ) 10 | 11 | func TestTestdata(t *testing.T) { 12 | testutil.Run(t, SCAnalyzer) 13 | } 14 | -------------------------------------------------------------------------------- /staticcheck/sa4019/testdata/go1.1/CheckDuplicateBuildConstraints/CheckDuplicateBuildConstraints.go: -------------------------------------------------------------------------------- 1 | //go:build (one || two || three || go1.1) && (three || one || two || go1.1) 2 | // +build one two three go1.1 3 | // +build three one two go1.1 4 | 5 | package pkg //@ diag(`identical build constraints`) 6 | -------------------------------------------------------------------------------- /staticcheck/sa4020/sa4020_test.go: -------------------------------------------------------------------------------- 1 | // Code generated by generate.go. DO NOT EDIT. 2 | 3 | package sa4020 4 | 5 | import ( 6 | "testing" 7 | 8 | "honnef.co/go/tools/analysis/lint/testutil" 9 | ) 10 | 11 | func TestTestdata(t *testing.T) { 12 | testutil.Run(t, SCAnalyzer) 13 | } 14 | -------------------------------------------------------------------------------- /staticcheck/sa4020/testdata/go1.18/CheckUnreachableTypeCases/typeparams.go: -------------------------------------------------------------------------------- 1 | package pkg 2 | 3 | func tp1[T any](x interface{}) { 4 | switch x.(type) { 5 | case T: 6 | case int: 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /staticcheck/sa4021/sa4021_test.go: -------------------------------------------------------------------------------- 1 | // Code generated by generate.go. DO NOT EDIT. 2 | 3 | package sa4021 4 | 5 | import ( 6 | "testing" 7 | 8 | "honnef.co/go/tools/analysis/lint/testutil" 9 | ) 10 | 11 | func TestTestdata(t *testing.T) { 12 | testutil.Run(t, SCAnalyzer) 13 | } 14 | -------------------------------------------------------------------------------- /staticcheck/sa4021/testdata/go1.0/CheckSingleArgAppend/CheckSingleArgAppend.go: -------------------------------------------------------------------------------- 1 | package pkg 2 | 3 | func fn(arg []int) { 4 | x := append(arg) //@ diag(`x = append(y) is equivalent to x = y`) 5 | _ = x 6 | y := append(arg, 1) 7 | _ = y 8 | arg = append(arg) //@ diag(`x = append(y) is equivalent to x = y`) 9 | arg = append(arg, 1, 2, 3) 10 | var nilly []int 11 | arg = append(arg, nilly...) 12 | arg = append(arg, arg...) 13 | 14 | append := func([]int) []int { return nil } 15 | arg = append(arg) 16 | } 17 | -------------------------------------------------------------------------------- /staticcheck/sa4022/sa4022_test.go: -------------------------------------------------------------------------------- 1 | // Code generated by generate.go. DO NOT EDIT. 2 | 3 | package sa4022 4 | 5 | import ( 6 | "testing" 7 | 8 | "honnef.co/go/tools/analysis/lint/testutil" 9 | ) 10 | 11 | func TestTestdata(t *testing.T) { 12 | testutil.Run(t, SCAnalyzer) 13 | } 14 | -------------------------------------------------------------------------------- /staticcheck/sa4022/testdata/go1.0/CheckAddressIsNil/CheckAddressIsNil.go: -------------------------------------------------------------------------------- 1 | package pkg 2 | 3 | func fn(x int, y *int) { 4 | _ = &x == nil //@ diag(`the address of a variable cannot be nil`) 5 | _ = &y != nil //@ diag(`the address of a variable cannot be nil`) 6 | 7 | if &x != nil { //@ diag(`the address of a variable cannot be nil`) 8 | println("obviously.") 9 | } 10 | 11 | if y == nil { 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /staticcheck/sa4023/sa4023_test.go: -------------------------------------------------------------------------------- 1 | // Code generated by generate.go. DO NOT EDIT. 2 | 3 | package sa4023 4 | 5 | import ( 6 | "testing" 7 | 8 | "honnef.co/go/tools/analysis/lint/testutil" 9 | ) 10 | 11 | func TestTestdata(t *testing.T) { 12 | testutil.Run(t, SCAnalyzer) 13 | } 14 | -------------------------------------------------------------------------------- /staticcheck/sa4023/testdata/go1.0/i27815/27815.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | ) 6 | 7 | type MyError struct { 8 | x string 9 | } 10 | 11 | func (e *MyError) Error() string { 12 | return e.x 13 | } 14 | 15 | func f() *MyError { 16 | return nil 17 | } 18 | 19 | func main() { 20 | var e error 21 | e = f() 22 | // e should be nil ? 23 | if e != nil { //@ diag(`this comparison is always true`) 24 | fmt.Println("NOT NIL") 25 | } else { 26 | fmt.Println("NIL") 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /staticcheck/sa4023/testdata/go1.0/i31873/31873.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "fmt" 4 | 5 | type S struct{} 6 | 7 | func (s *S) Error() string { 8 | return "error for S" 9 | } 10 | 11 | func structNil() *S { 12 | return nil 13 | } 14 | 15 | func errorNil() error { 16 | return nil 17 | } 18 | 19 | func main() { 20 | err := errorNil() 21 | fmt.Println(err != nil) 22 | err = structNil() 23 | fmt.Println(err != nil) //@ diag(`this comparison is always true`) 24 | err = errorNil() 25 | fmt.Println(err != nil) 26 | } 27 | -------------------------------------------------------------------------------- /staticcheck/sa4023/testdata/go1.0/i35217/35217.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "errors" 5 | "fmt" 6 | ) 7 | 8 | type someError struct { 9 | Msg string 10 | } 11 | 12 | func (e *someError) Error() string { 13 | return "someError: " + e.Msg 14 | } 15 | 16 | func calculate() (int, *someError) { 17 | return 42, nil 18 | } 19 | 20 | func main() { 21 | err := errors.New("ERROR") 22 | num, err := calculate() 23 | fmt.Println(num, err, err == nil) //@ diag(`this comparison is never true`) 24 | } 25 | -------------------------------------------------------------------------------- /staticcheck/sa4023/testdata/go1.9/CheckTypedNilInterface/CheckTypedNilInterface.go: -------------------------------------------------------------------------------- 1 | package pkg 2 | 3 | type any = interface{} 4 | 5 | func test() { 6 | _ = any((*int)(nil)) == nil //@ diag(`never true`) 7 | _ = any((error)(nil)) == nil 8 | } 9 | -------------------------------------------------------------------------------- /staticcheck/sa4024/sa4024_test.go: -------------------------------------------------------------------------------- 1 | // Code generated by generate.go. DO NOT EDIT. 2 | 3 | package sa4024 4 | 5 | import ( 6 | "testing" 7 | 8 | "honnef.co/go/tools/analysis/lint/testutil" 9 | ) 10 | 11 | func TestTestdata(t *testing.T) { 12 | testutil.Run(t, SCAnalyzer) 13 | } 14 | -------------------------------------------------------------------------------- /staticcheck/sa4025/sa4025_test.go: -------------------------------------------------------------------------------- 1 | // Code generated by generate.go. DO NOT EDIT. 2 | 3 | package sa4025 4 | 5 | import ( 6 | "testing" 7 | 8 | "honnef.co/go/tools/analysis/lint/testutil" 9 | ) 10 | 11 | func TestTestdata(t *testing.T) { 12 | testutil.Run(t, SCAnalyzer) 13 | } 14 | -------------------------------------------------------------------------------- /staticcheck/sa4025/testdata/go1.0/CheckIntegerDivisionEqualsZero/CheckIntegerDivisionEqualsZero.go: -------------------------------------------------------------------------------- 1 | package pkg 2 | 3 | func foo(x float64) {} 4 | 5 | func fn() { 6 | _ = 2 / 3 //@ diag(`results in zero`) 7 | _ = 4 / 2 8 | _ = 4 / 3 9 | _ = 0 / 2 //@ diag(`results in zero`) 10 | _ = 2 / 3. 11 | _ = 2 / 3.0 12 | _ = 2.0 / 3 13 | const _ = 2 / 3 //@ diag(`results in zero`) 14 | const _ float64 = 2 / 3 //@ diag(`results in zero`) 15 | _ = float64(2 / 3) //@ diag(`results in zero`) 16 | 17 | foo(1 / 2) //@ diag(`results in zero`) 18 | } 19 | -------------------------------------------------------------------------------- /staticcheck/sa4026/sa4026_test.go: -------------------------------------------------------------------------------- 1 | // Code generated by generate.go. DO NOT EDIT. 2 | 3 | package sa4026 4 | 5 | import ( 6 | "testing" 7 | 8 | "honnef.co/go/tools/analysis/lint/testutil" 9 | ) 10 | 11 | func TestTestdata(t *testing.T) { 12 | testutil.Run(t, SCAnalyzer) 13 | } 14 | -------------------------------------------------------------------------------- /staticcheck/sa4027/sa4027_test.go: -------------------------------------------------------------------------------- 1 | // Code generated by generate.go. DO NOT EDIT. 2 | 3 | package sa4027 4 | 5 | import ( 6 | "testing" 7 | 8 | "honnef.co/go/tools/analysis/lint/testutil" 9 | ) 10 | 11 | func TestTestdata(t *testing.T) { 12 | testutil.Run(t, SCAnalyzer) 13 | } 14 | -------------------------------------------------------------------------------- /staticcheck/sa4027/testdata/go1.0/CheckIneffectiveURLQueryModification/CheckIneffectiveURLQueryModification.go: -------------------------------------------------------------------------------- 1 | package pkg 2 | 3 | import "net/url" 4 | 5 | func fn(u *url.URL) { 6 | u.Query().Add("", "") //@ diag(`returns a copy`) 7 | u.Query().Set("", "") //@ diag(`returns a copy`) 8 | u.Query().Del("") //@ diag(`returns a copy`) 9 | u.Query().Encode() 10 | 11 | var t T 12 | t.Query().Add("", "") 13 | } 14 | 15 | type T struct{} 16 | 17 | func (v T) Query() T { return v } 18 | func (v T) Add(arg1, arg2 string) {} 19 | -------------------------------------------------------------------------------- /staticcheck/sa4028/sa4028_test.go: -------------------------------------------------------------------------------- 1 | // Code generated by generate.go. DO NOT EDIT. 2 | 3 | package sa4028 4 | 5 | import ( 6 | "testing" 7 | 8 | "honnef.co/go/tools/analysis/lint/testutil" 9 | ) 10 | 11 | func TestTestdata(t *testing.T) { 12 | testutil.Run(t, SCAnalyzer) 13 | } 14 | -------------------------------------------------------------------------------- /staticcheck/sa4028/testdata/go1.0/CheckModuloOne/CheckModuloOne.go: -------------------------------------------------------------------------------- 1 | package pkg 2 | 3 | func fn() { 4 | var a int 5 | var b uint 6 | _ = a % 1 //@ diag(`x % 1 is always zero`) 7 | _ = a % 2 8 | _ = b % 1 //@ diag(`x % 1 is always zero`) 9 | } 10 | -------------------------------------------------------------------------------- /staticcheck/sa4029/sa4029_test.go: -------------------------------------------------------------------------------- 1 | // Code generated by generate.go. DO NOT EDIT. 2 | 3 | package sa4029 4 | 5 | import ( 6 | "testing" 7 | 8 | "honnef.co/go/tools/analysis/lint/testutil" 9 | ) 10 | 11 | func TestTestdata(t *testing.T) { 12 | testutil.Run(t, SCAnalyzer) 13 | } 14 | -------------------------------------------------------------------------------- /staticcheck/sa4029/testdata/go1.0/CheckIneffectiveSort/CheckIneffectiveSort.go: -------------------------------------------------------------------------------- 1 | package pkg 2 | 3 | import "sort" 4 | 5 | func fn() { 6 | var a []string 7 | var b []float64 8 | var c sort.StringSlice 9 | 10 | a = sort.StringSlice(a) //@ diag(re`sort\.StringSlice is a type.+consider using sort\.Strings instead`) 11 | b = sort.Float64Slice(b) //@ diag(re`sort\.Float64Slice is a type.+consider using sort\.Float64s instead`) 12 | c = sort.StringSlice(c) 13 | } 14 | -------------------------------------------------------------------------------- /staticcheck/sa4029/testdata/go1.0/CheckIneffectiveSort/CheckIneffectiveSort.go.golden: -------------------------------------------------------------------------------- 1 | package pkg 2 | 3 | import "sort" 4 | 5 | func fn() { 6 | var a []string 7 | var b []float64 8 | var c sort.StringSlice 9 | 10 | sort.Strings(a) //@ diag(re`sort\.StringSlice is a type.+consider using sort\.Strings instead`) 11 | sort.Float64s(b) //@ diag(re`sort\.Float64Slice is a type.+consider using sort\.Float64s instead`) 12 | c = sort.StringSlice(c) 13 | } 14 | -------------------------------------------------------------------------------- /staticcheck/sa4029/testdata/go1.9/CheckIneffectiveSort/CheckIneffectiveSort.go: -------------------------------------------------------------------------------- 1 | package pkg 2 | 3 | import "sort" 4 | 5 | func fn() { 6 | type Strings = []string 7 | var d Strings 8 | 9 | d = sort.StringSlice(d) //@ diag(re`sort\.StringSlice is a type.+consider using sort\.Strings instead`) 10 | } 11 | -------------------------------------------------------------------------------- /staticcheck/sa4029/testdata/go1.9/CheckIneffectiveSort/CheckIneffectiveSort.go.golden: -------------------------------------------------------------------------------- 1 | package pkg 2 | 3 | import "sort" 4 | 5 | func fn() { 6 | type Strings = []string 7 | var d Strings 8 | 9 | sort.Strings(d) //@ diag(re`sort\.StringSlice is a type.+consider using sort\.Strings instead`) 10 | } 11 | -------------------------------------------------------------------------------- /staticcheck/sa4030/sa4030_test.go: -------------------------------------------------------------------------------- 1 | // Code generated by generate.go. DO NOT EDIT. 2 | 3 | package sa4030 4 | 5 | import ( 6 | "testing" 7 | 8 | "honnef.co/go/tools/analysis/lint/testutil" 9 | ) 10 | 11 | func TestTestdata(t *testing.T) { 12 | testutil.Run(t, SCAnalyzer) 13 | } 14 | -------------------------------------------------------------------------------- /staticcheck/sa4030/testdata/go1.0/CheckIneffectiveRandInt/CheckIneffectiveRandInt.go: -------------------------------------------------------------------------------- 1 | package pkg 2 | 3 | import "math/rand" 4 | 5 | func fn() { 6 | type T struct { 7 | rng rand.Rand 8 | } 9 | 10 | _ = rand.Intn(1) //@ diag(re`rand\.Intn\(n\) generates.+rand\.Intn\(1\) therefore`) 11 | _ = rand.Int63n(1) //@ diag(re`rand\.Int63n\(n\) generates.+rand\.Int63n\(1\) therefore`) 12 | var t T 13 | _ = t.rng.Intn(1) //@ diag(re`\(\*math/rand\.Rand\)\.Intn\(n\) generates.+t\.rng\.Intn\(1\) therefore`) 14 | 15 | _ = rand.Intn(2) 16 | } 17 | -------------------------------------------------------------------------------- /staticcheck/sa4031/sa4031_test.go: -------------------------------------------------------------------------------- 1 | // Code generated by generate.go. DO NOT EDIT. 2 | 3 | package sa4031 4 | 5 | import ( 6 | "testing" 7 | 8 | "honnef.co/go/tools/analysis/lint/testutil" 9 | ) 10 | 11 | func TestTestdata(t *testing.T) { 12 | testutil.Run(t, SCAnalyzer) 13 | } 14 | -------------------------------------------------------------------------------- /staticcheck/sa4032/sa4032_test.go: -------------------------------------------------------------------------------- 1 | // Code generated by generate.go. DO NOT EDIT. 2 | 3 | package sa4032 4 | 5 | import ( 6 | "testing" 7 | 8 | "honnef.co/go/tools/analysis/lint/testutil" 9 | ) 10 | 11 | func TestTestdata(t *testing.T) { 12 | testutil.Run(t, SCAnalyzer) 13 | } 14 | -------------------------------------------------------------------------------- /staticcheck/sa4032/testdata/go1.0/CheckGOOSComparison/complex.go: -------------------------------------------------------------------------------- 1 | //go:build linux || windows 2 | 3 | package pkg 4 | 5 | import "runtime" 6 | 7 | func complex() { 8 | if runtime.GOOS == "linux" { 9 | } 10 | if runtime.GOOS == "android" { 11 | } 12 | if runtime.GOOS == "windows" { 13 | } 14 | if runtime.GOOS == "darwin" { //@ diag(`runtime.GOOS will never equal "darwin"`) 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /staticcheck/sa4032/testdata/go1.0/CheckGOOSComparison/f_linux.go: -------------------------------------------------------------------------------- 1 | package pkg 2 | 3 | import "runtime" 4 | 5 | func fileLinux() { 6 | if runtime.GOOS == "windows" { //@ diag(`runtime.GOOS will never equal "windows"`) 7 | } 8 | if runtime.GOOS == "android" { 9 | } 10 | if runtime.GOOS == "linux" { 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /staticcheck/sa4032/testdata/go1.0/CheckGOOSComparison/f_unix.go: -------------------------------------------------------------------------------- 1 | package pkg 2 | 3 | import "runtime" 4 | 5 | func fileUnix() { 6 | // "unix" is not a magic file name suffix, so all of these branches are fine 7 | if runtime.GOOS == "windows" { 8 | } 9 | if runtime.GOOS == "android" { 10 | } 11 | if runtime.GOOS == "linux" { 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /staticcheck/sa4032/testdata/go1.0/CheckGOOSComparison/f_windows.go: -------------------------------------------------------------------------------- 1 | package pkg 2 | 3 | import "runtime" 4 | 5 | func fileWindows() { 6 | if runtime.GOOS == "windows" { 7 | } 8 | if runtime.GOOS == "linux" { //@ diag(`runtime.GOOS will never equal "linux"`) 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /staticcheck/sa4032/testdata/go1.0/CheckGOOSComparison/other.go: -------------------------------------------------------------------------------- 1 | //go:build !(linux || windows || unix) 2 | 3 | package pkg 4 | 5 | import "runtime" 6 | 7 | func other() { 8 | if runtime.GOOS == "linux" { //@ diag(`runtime.GOOS will never equal "linux"`) 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /staticcheck/sa4032/testdata/go1.0/CheckGOOSComparison/tlinux.go: -------------------------------------------------------------------------------- 1 | //go:build linux 2 | 3 | package pkg 4 | 5 | import "runtime" 6 | 7 | func linux() { 8 | if runtime.GOOS == "windows" { //@ diag(`runtime.GOOS will never equal "windows"`) 9 | } 10 | if runtime.GOOS == "android" { 11 | } 12 | if runtime.GOOS == "linux" { 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /staticcheck/sa4032/testdata/go1.0/CheckGOOSComparison/tunix.go: -------------------------------------------------------------------------------- 1 | //go:build unix 2 | 3 | package pkg 4 | 5 | import "runtime" 6 | 7 | func unix() { 8 | if runtime.GOOS == "windows" { //@ diag(`runtime.GOOS will never equal "windows"`) 9 | } 10 | if runtime.GOOS == "linux" { 11 | } 12 | if runtime.GOOS == "darwin" { 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /staticcheck/sa4032/testdata/go1.0/CheckGOOSComparison/twindows.go: -------------------------------------------------------------------------------- 1 | //go:build windows 2 | 3 | package pkg 4 | 5 | import "runtime" 6 | 7 | func windows() { 8 | if runtime.GOOS == "windows" { 9 | } 10 | if runtime.GOOS == "linux" { //@ diag(`runtime.GOOS will never equal "linux"`) 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /staticcheck/sa4032/testdata/go1.0/CheckGOOSComparison/unknown.go: -------------------------------------------------------------------------------- 1 | //go:build unix || windows 2 | 3 | package pkg 4 | 5 | import "runtime" 6 | 7 | func unknown() { 8 | // don't flag this, we don't know what DomOS is. 9 | if runtime.GOOS == "DomOS" { 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /staticcheck/sa5000/sa5000_test.go: -------------------------------------------------------------------------------- 1 | // Code generated by generate.go. DO NOT EDIT. 2 | 3 | package sa5000 4 | 5 | import ( 6 | "testing" 7 | 8 | "honnef.co/go/tools/analysis/lint/testutil" 9 | ) 10 | 11 | func TestTestdata(t *testing.T) { 12 | testutil.Run(t, SCAnalyzer) 13 | } 14 | -------------------------------------------------------------------------------- /staticcheck/sa5000/testdata/go1.0/CheckNilMaps/CheckNilMaps.go: -------------------------------------------------------------------------------- 1 | package pkg 2 | 3 | import "fmt" 4 | 5 | func fn1() { 6 | var m map[int]int 7 | m[1] = 1 //@ diag(`assignment to nil map`) 8 | } 9 | 10 | func fn2(m map[int]int) { 11 | m[1] = 1 12 | } 13 | 14 | func fn3() { 15 | v := []int{1, 2, 3} 16 | var m map[string]int 17 | for i := range v { 18 | m["a"] = i //@ diag(`assignment to nil map`) 19 | } 20 | fmt.Println(m["a"]) 21 | } 22 | 23 | func fn4() { 24 | m := map[string]int{} 25 | if true { 26 | if true { 27 | m[""] = 0 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /staticcheck/sa5001/sa5001_test.go: -------------------------------------------------------------------------------- 1 | // Code generated by generate.go. DO NOT EDIT. 2 | 3 | package sa5001 4 | 5 | import ( 6 | "testing" 7 | 8 | "honnef.co/go/tools/analysis/lint/testutil" 9 | ) 10 | 11 | func TestTestdata(t *testing.T) { 12 | testutil.Run(t, SCAnalyzer) 13 | } 14 | -------------------------------------------------------------------------------- /staticcheck/sa5002/sa5002_test.go: -------------------------------------------------------------------------------- 1 | // Code generated by generate.go. DO NOT EDIT. 2 | 3 | package sa5002 4 | 5 | import ( 6 | "testing" 7 | 8 | "honnef.co/go/tools/analysis/lint/testutil" 9 | ) 10 | 11 | func TestTestdata(t *testing.T) { 12 | testutil.Run(t, SCAnalyzer) 13 | } 14 | -------------------------------------------------------------------------------- /staticcheck/sa5003/sa5003_test.go: -------------------------------------------------------------------------------- 1 | // Code generated by generate.go. DO NOT EDIT. 2 | 3 | package sa5003 4 | 5 | import ( 6 | "testing" 7 | 8 | "honnef.co/go/tools/analysis/lint/testutil" 9 | ) 10 | 11 | func TestTestdata(t *testing.T) { 12 | testutil.Run(t, SCAnalyzer) 13 | } 14 | -------------------------------------------------------------------------------- /staticcheck/sa5004/sa5004_test.go: -------------------------------------------------------------------------------- 1 | // Code generated by generate.go. DO NOT EDIT. 2 | 3 | package sa5004 4 | 5 | import ( 6 | "testing" 7 | 8 | "honnef.co/go/tools/analysis/lint/testutil" 9 | ) 10 | 11 | func TestTestdata(t *testing.T) { 12 | testutil.Run(t, SCAnalyzer) 13 | } 14 | -------------------------------------------------------------------------------- /staticcheck/sa5004/testdata/go1.0/CheckLoopEmptyDefault/CheckLoopEmptyDefault.go: -------------------------------------------------------------------------------- 1 | package pkg 2 | 3 | func fn() { 4 | var ch chan int 5 | select { 6 | case <-ch: 7 | default: 8 | } 9 | 10 | for { 11 | select { 12 | case <-ch: 13 | default: //@ diag(`should not have an empty default case`) 14 | } 15 | } 16 | 17 | for { 18 | select { 19 | case <-ch: 20 | default: 21 | println("foo") 22 | } 23 | } 24 | 25 | for { 26 | select { 27 | case <-ch: 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /staticcheck/sa5004/testdata/go1.0/CheckLoopEmptyDefault/CheckLoopEmptyDefault.go.golden: -------------------------------------------------------------------------------- 1 | package pkg 2 | 3 | func fn() { 4 | var ch chan int 5 | select { 6 | case <-ch: 7 | default: 8 | } 9 | 10 | for { 11 | select { 12 | case <-ch: 13 | //@ diag(`should not have an empty default case`) 14 | } 15 | } 16 | 17 | for { 18 | select { 19 | case <-ch: 20 | default: 21 | println("foo") 22 | } 23 | } 24 | 25 | for { 26 | select { 27 | case <-ch: 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /staticcheck/sa5005/sa5005_test.go: -------------------------------------------------------------------------------- 1 | // Code generated by generate.go. DO NOT EDIT. 2 | 3 | package sa5005 4 | 5 | import ( 6 | "testing" 7 | 8 | "honnef.co/go/tools/analysis/lint/testutil" 9 | ) 10 | 11 | func TestTestdata(t *testing.T) { 12 | testutil.Run(t, SCAnalyzer) 13 | } 14 | -------------------------------------------------------------------------------- /staticcheck/sa5007/sa5007_test.go: -------------------------------------------------------------------------------- 1 | // Code generated by generate.go. DO NOT EDIT. 2 | 3 | package sa5007 4 | 5 | import ( 6 | "testing" 7 | 8 | "honnef.co/go/tools/analysis/lint/testutil" 9 | ) 10 | 11 | func TestTestdata(t *testing.T) { 12 | testutil.Run(t, SCAnalyzer) 13 | } 14 | -------------------------------------------------------------------------------- /staticcheck/sa5008/sa5008_test.go: -------------------------------------------------------------------------------- 1 | // Code generated by generate.go. DO NOT EDIT. 2 | 3 | package sa5008 4 | 5 | import ( 6 | "testing" 7 | 8 | "honnef.co/go/tools/analysis/lint/testutil" 9 | ) 10 | 11 | func TestTestdata(t *testing.T) { 12 | testutil.Run(t, SCAnalyzer) 13 | } 14 | -------------------------------------------------------------------------------- /staticcheck/sa5008/testdata/go1.0/CheckStructTags2/CheckStructTags2.go: -------------------------------------------------------------------------------- 1 | package pkg 2 | 3 | type T5 struct { 4 | A int `choice:"foo" choice:"bar"` //@ diag(`duplicate struct tag`) 5 | B []int `optional-value:"foo" optional-value:"bar"` //@ diag(`duplicate struct tag`) 6 | C []int `default:"foo" default:"bar"` //@ diag(`duplicate struct tag`) 7 | } 8 | -------------------------------------------------------------------------------- /staticcheck/sa5008/testdata/go1.0/vendor/github.com/jessevdk/go-flags/pkg.go: -------------------------------------------------------------------------------- 1 | package pkg 2 | -------------------------------------------------------------------------------- /staticcheck/sa5009/sa5009_test.go: -------------------------------------------------------------------------------- 1 | // Code generated by generate.go. DO NOT EDIT. 2 | 3 | package sa5009 4 | 5 | import ( 6 | "testing" 7 | 8 | "honnef.co/go/tools/analysis/lint/testutil" 9 | ) 10 | 11 | func TestTestdata(t *testing.T) { 12 | testutil.Run(t, SCAnalyzer) 13 | } 14 | -------------------------------------------------------------------------------- /staticcheck/sa5010/sa5010_test.go: -------------------------------------------------------------------------------- 1 | // Code generated by generate.go. DO NOT EDIT. 2 | 3 | package sa5010 4 | 5 | import ( 6 | "testing" 7 | 8 | "honnef.co/go/tools/analysis/lint/testutil" 9 | ) 10 | 11 | func TestTestdata(t *testing.T) { 12 | testutil.Run(t, SCAnalyzer) 13 | } 14 | -------------------------------------------------------------------------------- /staticcheck/sa5011/sa5011_test.go: -------------------------------------------------------------------------------- 1 | // Code generated by generate.go. DO NOT EDIT. 2 | 3 | package sa5011 4 | 5 | import ( 6 | "testing" 7 | 8 | "honnef.co/go/tools/analysis/lint/testutil" 9 | ) 10 | 11 | func TestTestdata(t *testing.T) { 12 | testutil.Run(t, SCAnalyzer) 13 | } 14 | -------------------------------------------------------------------------------- /staticcheck/sa5011/testdata/go1.18/CheckMaybeNil/generics.go: -------------------------------------------------------------------------------- 1 | package pkg 2 | 3 | func tpfn1[T []int](x T) { 4 | // don't flag, T is a slice 5 | _ = x[0] 6 | if x == nil { 7 | return 8 | } 9 | println() 10 | } 11 | 12 | func tpfn2[T *int,](x T) { 13 | _ = *x //@ diag(`possible nil pointer dereference`) 14 | if x == nil { 15 | return 16 | } 17 | println() 18 | } 19 | -------------------------------------------------------------------------------- /staticcheck/sa5012/sa5012_test.go: -------------------------------------------------------------------------------- 1 | // Code generated by generate.go. DO NOT EDIT. 2 | 3 | package sa5012 4 | 5 | import ( 6 | "testing" 7 | 8 | "honnef.co/go/tools/analysis/lint/testutil" 9 | ) 10 | 11 | func TestTestdata(t *testing.T) { 12 | testutil.Run(t, SCAnalyzer) 13 | } 14 | -------------------------------------------------------------------------------- /staticcheck/sa6000/sa6000_test.go: -------------------------------------------------------------------------------- 1 | // Code generated by generate.go. DO NOT EDIT. 2 | 3 | package sa6000 4 | 5 | import ( 6 | "testing" 7 | 8 | "honnef.co/go/tools/analysis/lint/testutil" 9 | ) 10 | 11 | func TestTestdata(t *testing.T) { 12 | testutil.Run(t, SCAnalyzer) 13 | } 14 | -------------------------------------------------------------------------------- /staticcheck/sa6000/testdata/go1.0/CheckRegexpMatchLoop/CheckRegexpMatchLoop.go: -------------------------------------------------------------------------------- 1 | package pkg 2 | 3 | import "regexp" 4 | 5 | func fn() { 6 | regexp.Match(".", nil) 7 | regexp.MatchString(".", "") 8 | regexp.MatchReader(".", nil) 9 | 10 | for { 11 | regexp.Match(".", nil) //@ diag(`calling regexp.Match in a loop has poor performance`) 12 | regexp.MatchString(".", "") //@ diag(`calling regexp.MatchString in a loop has poor performance`) 13 | regexp.MatchReader(".", nil) //@ diag(`calling regexp.MatchReader in a loop has poor performance`) 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /staticcheck/sa6001/sa6001_test.go: -------------------------------------------------------------------------------- 1 | // Code generated by generate.go. DO NOT EDIT. 2 | 3 | package sa6001 4 | 5 | import ( 6 | "testing" 7 | 8 | "honnef.co/go/tools/analysis/lint/testutil" 9 | ) 10 | 11 | func TestTestdata(t *testing.T) { 12 | testutil.Run(t, SCAnalyzer) 13 | } 14 | -------------------------------------------------------------------------------- /staticcheck/sa6001/testdata/go1.0/CheckMapBytesKey/key.go: -------------------------------------------------------------------------------- 1 | package pkg 2 | 3 | func fn() { 4 | var m map[string]int 5 | var b []byte 6 | _ = m[string(b)] 7 | _ = m[string(b)] 8 | s1 := string(b) //@ diag(`m[string(key)] would be more efficient than k := string(key); m[k]`) 9 | _ = m[s1] 10 | _ = m[s1] 11 | 12 | s2 := string(b) 13 | _ = m[s2] 14 | _ = m[s2] 15 | println(s2) 16 | } 17 | -------------------------------------------------------------------------------- /staticcheck/sa6001/testdata/go1.18/CheckMapBytesKey/key_generics.go: -------------------------------------------------------------------------------- 1 | package pkg 2 | 3 | func tpfn[T ~string | []byte | int](b T) { 4 | var m map[string]int 5 | k := string(b) //@ diag(`would be more efficient`) 6 | _ = m[k] 7 | } 8 | -------------------------------------------------------------------------------- /staticcheck/sa6002/sa6002_test.go: -------------------------------------------------------------------------------- 1 | // Code generated by generate.go. DO NOT EDIT. 2 | 3 | package sa6002 4 | 5 | import ( 6 | "testing" 7 | 8 | "honnef.co/go/tools/analysis/lint/testutil" 9 | ) 10 | 11 | func TestTestdata(t *testing.T) { 12 | testutil.Run(t, SCAnalyzer) 13 | } 14 | -------------------------------------------------------------------------------- /staticcheck/sa6003/sa6003_test.go: -------------------------------------------------------------------------------- 1 | // Code generated by generate.go. DO NOT EDIT. 2 | 3 | package sa6003 4 | 5 | import ( 6 | "testing" 7 | 8 | "honnef.co/go/tools/analysis/lint/testutil" 9 | ) 10 | 11 | func TestTestdata(t *testing.T) { 12 | testutil.Run(t, SCAnalyzer) 13 | } 14 | -------------------------------------------------------------------------------- /staticcheck/sa6003/testdata/go1.18/CheckRangeStringRunes/generics.go: -------------------------------------------------------------------------------- 1 | package pkg 2 | 3 | func tpfn1[T string](x T) { 4 | for _, c := range []rune(x) { //@ diag(`should range over string`) 5 | println(c) 6 | } 7 | } 8 | 9 | func tpfn2[T1 string, T2 []rune](x T1) { 10 | for _, c := range T2(x) { //@ diag(`should range over string`) 11 | println(c) 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /staticcheck/sa6005/sa6005_test.go: -------------------------------------------------------------------------------- 1 | // Code generated by generate.go. DO NOT EDIT. 2 | 3 | package sa6005 4 | 5 | import ( 6 | "testing" 7 | 8 | "honnef.co/go/tools/analysis/lint/testutil" 9 | ) 10 | 11 | func TestTestdata(t *testing.T) { 12 | testutil.Run(t, SCAnalyzer) 13 | } 14 | -------------------------------------------------------------------------------- /staticcheck/sa6006/sa6006_test.go: -------------------------------------------------------------------------------- 1 | // Code generated by generate.go. DO NOT EDIT. 2 | 3 | package sa6006 4 | 5 | import ( 6 | "testing" 7 | 8 | "honnef.co/go/tools/analysis/lint/testutil" 9 | ) 10 | 11 | func TestTestdata(t *testing.T) { 12 | testutil.Run(t, SCAnalyzer) 13 | } 14 | -------------------------------------------------------------------------------- /staticcheck/sa9001/sa9001_test.go: -------------------------------------------------------------------------------- 1 | // Code generated by generate.go. DO NOT EDIT. 2 | 3 | package sa9001 4 | 5 | import ( 6 | "testing" 7 | 8 | "honnef.co/go/tools/analysis/lint/testutil" 9 | ) 10 | 11 | func TestTestdata(t *testing.T) { 12 | testutil.Run(t, SCAnalyzer) 13 | } 14 | -------------------------------------------------------------------------------- /staticcheck/sa9001/testdata/go1.0/CheckDubiousDeferInChannelRangeLoop/CheckDubiousDeferInChannelRangeLoop.go: -------------------------------------------------------------------------------- 1 | package pkg 2 | 3 | func fn() { 4 | var ch chan int 5 | for range ch { 6 | defer println() //@ diag(`defers in this range loop`) 7 | } 8 | } 9 | 10 | func fn2() { 11 | var ch chan int 12 | for range ch { 13 | defer println() 14 | break 15 | } 16 | 17 | for range ch { 18 | defer println() 19 | return 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /staticcheck/sa9001/testdata/go1.18/CheckDubiousDeferInChannelRangeLoop/generics.go: -------------------------------------------------------------------------------- 1 | package pkg 2 | 3 | func tpfn[T chan int]() { 4 | var ch T 5 | for range ch { 6 | defer println() //@ diag(`defers in this range loop`) 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /staticcheck/sa9002/sa9002_test.go: -------------------------------------------------------------------------------- 1 | // Code generated by generate.go. DO NOT EDIT. 2 | 3 | package sa9002 4 | 5 | import ( 6 | "testing" 7 | 8 | "honnef.co/go/tools/analysis/lint/testutil" 9 | ) 10 | 11 | func TestTestdata(t *testing.T) { 12 | testutil.Run(t, SCAnalyzer) 13 | } 14 | -------------------------------------------------------------------------------- /staticcheck/sa9002/testdata/go1.0/CheckNonOctalFileMode/CheckNonOctalFileMode.go: -------------------------------------------------------------------------------- 1 | package pkg 2 | 3 | import "os" 4 | 5 | func fn() { 6 | os.OpenFile("", 0, 644) //@ diag(`file mode`) 7 | } 8 | 9 | func fn2() (string, int, os.FileMode) { 10 | return "", 0, 0 11 | } 12 | 13 | func fn3() { 14 | os.OpenFile(fn2()) 15 | } 16 | -------------------------------------------------------------------------------- /staticcheck/sa9002/testdata/go1.0/CheckNonOctalFileMode/CheckNonOctalFileMode.go.golden: -------------------------------------------------------------------------------- 1 | package pkg 2 | 3 | import "os" 4 | 5 | func fn() { 6 | os.OpenFile("", 0, 0644) //@ diag(`file mode`) 7 | } 8 | 9 | func fn2() (string, int, os.FileMode) { 10 | return "", 0, 0 11 | } 12 | 13 | func fn3() { 14 | os.OpenFile(fn2()) 15 | } 16 | -------------------------------------------------------------------------------- /staticcheck/sa9003/sa9003_test.go: -------------------------------------------------------------------------------- 1 | // Code generated by generate.go. DO NOT EDIT. 2 | 3 | package sa9003 4 | 5 | import ( 6 | "testing" 7 | 8 | "honnef.co/go/tools/analysis/lint/testutil" 9 | ) 10 | 11 | func TestTestdata(t *testing.T) { 12 | testutil.Run(t, SCAnalyzer) 13 | } 14 | -------------------------------------------------------------------------------- /staticcheck/sa9003/testdata/go1.0/CheckEmptyBranch/CheckEmptyBranch_generated.go: -------------------------------------------------------------------------------- 1 | // Code generated by a human. DO NOT EDIT. 2 | 3 | package pkg 4 | 5 | func fn2() { 6 | if true { 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /staticcheck/sa9003/testdata/go1.0/CheckEmptyBranch/CheckEmptyBranch_test.go: -------------------------------------------------------------------------------- 1 | package pkg 2 | 3 | import "testing" 4 | 5 | func TestFoo(t *testing.T) { 6 | if true { //@ diag(`empty branch`) 7 | // TODO 8 | } 9 | } 10 | 11 | func ExampleFoo() { 12 | if true { 13 | // TODO 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /staticcheck/sa9004/sa9004_test.go: -------------------------------------------------------------------------------- 1 | // Code generated by generate.go. DO NOT EDIT. 2 | 3 | package sa9004 4 | 5 | import ( 6 | "testing" 7 | 8 | "honnef.co/go/tools/analysis/lint/testutil" 9 | ) 10 | 11 | func TestTestdata(t *testing.T) { 12 | testutil.Run(t, SCAnalyzer) 13 | } 14 | -------------------------------------------------------------------------------- /staticcheck/sa9005/sa9005_test.go: -------------------------------------------------------------------------------- 1 | // Code generated by generate.go. DO NOT EDIT. 2 | 3 | package sa9005 4 | 5 | import ( 6 | "testing" 7 | 8 | "honnef.co/go/tools/analysis/lint/testutil" 9 | ) 10 | 11 | func TestTestdata(t *testing.T) { 12 | testutil.Run(t, SCAnalyzer) 13 | } 14 | -------------------------------------------------------------------------------- /staticcheck/sa9006/sa9006_test.go: -------------------------------------------------------------------------------- 1 | // Code generated by generate.go. DO NOT EDIT. 2 | 3 | package sa9006 4 | 5 | import ( 6 | "testing" 7 | 8 | "honnef.co/go/tools/analysis/lint/testutil" 9 | ) 10 | 11 | func TestTestdata(t *testing.T) { 12 | testutil.Run(t, SCAnalyzer) 13 | } 14 | -------------------------------------------------------------------------------- /staticcheck/sa9007/sa9007_test.go: -------------------------------------------------------------------------------- 1 | // Code generated by generate.go. DO NOT EDIT. 2 | 3 | package sa9007 4 | 5 | import ( 6 | "testing" 7 | 8 | "honnef.co/go/tools/analysis/lint/testutil" 9 | ) 10 | 11 | func TestTestdata(t *testing.T) { 12 | testutil.Run(t, SCAnalyzer) 13 | } 14 | -------------------------------------------------------------------------------- /staticcheck/sa9008/sa9008_test.go: -------------------------------------------------------------------------------- 1 | // Code generated by generate.go. DO NOT EDIT. 2 | 3 | package sa9008 4 | 5 | import ( 6 | "testing" 7 | 8 | "honnef.co/go/tools/analysis/lint/testutil" 9 | ) 10 | 11 | func TestTestdata(t *testing.T) { 12 | testutil.Run(t, SCAnalyzer) 13 | } 14 | -------------------------------------------------------------------------------- /staticcheck/sa9009/sa9009_test.go: -------------------------------------------------------------------------------- 1 | // Code generated by generate.go. DO NOT EDIT. 2 | 3 | package sa9009 4 | 5 | import ( 6 | "testing" 7 | 8 | "honnef.co/go/tools/analysis/lint/testutil" 9 | ) 10 | 11 | func TestTestdata(t *testing.T) { 12 | testutil.Run(t, SCAnalyzer) 13 | } 14 | -------------------------------------------------------------------------------- /stylecheck/st1000/st1000_test.go: -------------------------------------------------------------------------------- 1 | // Code generated by generate.go. DO NOT EDIT. 2 | 3 | package st1000 4 | 5 | import ( 6 | "testing" 7 | 8 | "honnef.co/go/tools/analysis/lint/testutil" 9 | ) 10 | 11 | func TestTestdata(t *testing.T) { 12 | testutil.Run(t, SCAnalyzer) 13 | } 14 | -------------------------------------------------------------------------------- /stylecheck/st1000/testdata/go1.0/CheckPackageComment-1/CheckPackageComment-1.go: -------------------------------------------------------------------------------- 1 | package pkg //@ diag(`at least one file in a package should have a package comment`) 2 | -------------------------------------------------------------------------------- /stylecheck/st1000/testdata/go1.0/CheckPackageComment-2/CheckPackageComment-2.go: -------------------------------------------------------------------------------- 1 | // This package is great //@ diag(`package comment should be of the form`) 2 | package pkg 3 | -------------------------------------------------------------------------------- /stylecheck/st1000/testdata/go1.0/CheckPackageComment-3/CheckPackageComment-3.go: -------------------------------------------------------------------------------- 1 | /* 2 | Package pkg is useful. 3 | */ 4 | package pkg 5 | -------------------------------------------------------------------------------- /stylecheck/st1000/testdata/go1.0/CheckPackageComment-4/CheckPackageComment-4.go: -------------------------------------------------------------------------------- 1 | // Package pkg, while not being very long, sure likes punctuation. 2 | package pkg 3 | -------------------------------------------------------------------------------- /stylecheck/st1000/testdata/go1.0/CheckPackageComment-5/CheckPackageComment-5.go: -------------------------------------------------------------------------------- 1 | // Package pkg 2 | package pkg 3 | -------------------------------------------------------------------------------- /stylecheck/st1000/testdata/go1.0/CheckPackageComment-6/CheckPackageComment-6.go: -------------------------------------------------------------------------------- 1 | // Package pkg2 //@ diag(`package comment should be of the form`) 2 | package pkg 3 | -------------------------------------------------------------------------------- /stylecheck/st1001/st1001_test.go: -------------------------------------------------------------------------------- 1 | // Code generated by generate.go. DO NOT EDIT. 2 | 3 | package st1001 4 | 5 | import ( 6 | "testing" 7 | 8 | "honnef.co/go/tools/analysis/lint/testutil" 9 | ) 10 | 11 | func TestTestdata(t *testing.T) { 12 | testutil.Run(t, SCAnalyzer) 13 | } 14 | -------------------------------------------------------------------------------- /stylecheck/st1001/testdata/go1.0/CheckDotImports/CheckDotImports.go: -------------------------------------------------------------------------------- 1 | // Package pkg ... 2 | package pkg 3 | 4 | import . "fmt" //@ diag(`should not use dot imports`) 5 | 6 | var _ = Println 7 | -------------------------------------------------------------------------------- /stylecheck/st1001/testdata/go1.0/CheckDotImports/CheckDotImports_test.go: -------------------------------------------------------------------------------- 1 | package pkg 2 | 3 | import . "fmt" 4 | 5 | var _ = Println 6 | -------------------------------------------------------------------------------- /stylecheck/st1003/st1003_test.go: -------------------------------------------------------------------------------- 1 | // Code generated by generate.go. DO NOT EDIT. 2 | 3 | package st1003 4 | 5 | import ( 6 | "testing" 7 | 8 | "honnef.co/go/tools/analysis/lint/testutil" 9 | ) 10 | 11 | func TestTestdata(t *testing.T) { 12 | testutil.Run(t, SCAnalyzer) 13 | } 14 | -------------------------------------------------------------------------------- /stylecheck/st1003/testdata/go1.0/CheckNames_generated/CheckNames_generated.go: -------------------------------------------------------------------------------- 1 | // Code generated by an actual human. DO NOT EDIT. 2 | 3 | // Package pkg_foo ... 4 | package pkg_foo 5 | -------------------------------------------------------------------------------- /stylecheck/st1005/st1005_test.go: -------------------------------------------------------------------------------- 1 | // Code generated by generate.go. DO NOT EDIT. 2 | 3 | package st1005 4 | 5 | import ( 6 | "testing" 7 | 8 | "honnef.co/go/tools/analysis/lint/testutil" 9 | ) 10 | 11 | func TestTestdata(t *testing.T) { 12 | testutil.Run(t, SCAnalyzer) 13 | } 14 | -------------------------------------------------------------------------------- /stylecheck/st1006/st1006_test.go: -------------------------------------------------------------------------------- 1 | // Code generated by generate.go. DO NOT EDIT. 2 | 3 | package st1006 4 | 5 | import ( 6 | "testing" 7 | 8 | "honnef.co/go/tools/analysis/lint/testutil" 9 | ) 10 | 11 | func TestTestdata(t *testing.T) { 12 | testutil.Run(t, SCAnalyzer) 13 | } 14 | -------------------------------------------------------------------------------- /stylecheck/st1006/testdata/go1.0/CheckReceiverNames/CheckReceiverNames.go: -------------------------------------------------------------------------------- 1 | // Package pkg ... 2 | package pkg 3 | 4 | type T1 int 5 | 6 | func (x T1) Fn1() {} 7 | func (y T1) Fn2() {} 8 | func (x T1) Fn3() {} 9 | func (T1) Fn4() {} 10 | func (_ T1) Fn5() {} //@ diag(`receiver name should not be an underscore, omit the name if it is unused`) 11 | func (self T1) Fn6() {} //@ diag(`receiver name should be a reflection of its identity`) 12 | -------------------------------------------------------------------------------- /stylecheck/st1008/st1008_test.go: -------------------------------------------------------------------------------- 1 | // Code generated by generate.go. DO NOT EDIT. 2 | 3 | package st1008 4 | 5 | import ( 6 | "testing" 7 | 8 | "honnef.co/go/tools/analysis/lint/testutil" 9 | ) 10 | 11 | func TestTestdata(t *testing.T) { 12 | testutil.Run(t, SCAnalyzer) 13 | } 14 | -------------------------------------------------------------------------------- /stylecheck/st1008/testdata/go1.9/CheckErrorReturn/CheckErrorReturn.go: -------------------------------------------------------------------------------- 1 | // Package pkg ... 2 | package pkg 3 | 4 | type Alias = error 5 | 6 | func fn10() (Alias, int) { return nil, 0 } //@ diag(`error should be returned as the last argument`) 7 | -------------------------------------------------------------------------------- /stylecheck/st1011/st1011_test.go: -------------------------------------------------------------------------------- 1 | // Code generated by generate.go. DO NOT EDIT. 2 | 3 | package st1011 4 | 5 | import ( 6 | "testing" 7 | 8 | "honnef.co/go/tools/analysis/lint/testutil" 9 | ) 10 | 11 | func TestTestdata(t *testing.T) { 12 | testutil.Run(t, SCAnalyzer) 13 | } 14 | -------------------------------------------------------------------------------- /stylecheck/st1012/st1012_test.go: -------------------------------------------------------------------------------- 1 | // Code generated by generate.go. DO NOT EDIT. 2 | 3 | package st1012 4 | 5 | import ( 6 | "testing" 7 | 8 | "honnef.co/go/tools/analysis/lint/testutil" 9 | ) 10 | 11 | func TestTestdata(t *testing.T) { 12 | testutil.Run(t, SCAnalyzer) 13 | } 14 | -------------------------------------------------------------------------------- /stylecheck/st1013/st1013_test.go: -------------------------------------------------------------------------------- 1 | // Code generated by generate.go. DO NOT EDIT. 2 | 3 | package st1013 4 | 5 | import ( 6 | "testing" 7 | 8 | "honnef.co/go/tools/analysis/lint/testutil" 9 | ) 10 | 11 | func TestTestdata(t *testing.T) { 12 | testutil.Run(t, SCAnalyzer) 13 | } 14 | -------------------------------------------------------------------------------- /stylecheck/st1015/st1015_test.go: -------------------------------------------------------------------------------- 1 | // Code generated by generate.go. DO NOT EDIT. 2 | 3 | package st1015 4 | 5 | import ( 6 | "testing" 7 | 8 | "honnef.co/go/tools/analysis/lint/testutil" 9 | ) 10 | 11 | func TestTestdata(t *testing.T) { 12 | testutil.Run(t, SCAnalyzer) 13 | } 14 | -------------------------------------------------------------------------------- /stylecheck/st1016/st1016_test.go: -------------------------------------------------------------------------------- 1 | // Code generated by generate.go. DO NOT EDIT. 2 | 3 | package st1016 4 | 5 | import ( 6 | "testing" 7 | 8 | "honnef.co/go/tools/analysis/lint/testutil" 9 | ) 10 | 11 | func TestTestdata(t *testing.T) { 12 | testutil.Run(t, SCAnalyzer) 13 | } 14 | -------------------------------------------------------------------------------- /stylecheck/st1016/testdata/go1.0/CheckReceiverNamesIdentical/CheckReceiverNames.go: -------------------------------------------------------------------------------- 1 | // Package pkg ... 2 | package pkg 3 | 4 | type T1 int 5 | 6 | func (x T1) Fn1() {} //@ diag(`methods on the same type should have the same receiver name`) 7 | func (y T1) Fn2() {} 8 | func (x T1) Fn3() {} 9 | func (T1) Fn4() {} 10 | func (_ T1) Fn5() {} 11 | func (self T1) Fn6() {} 12 | 13 | func (bar T3) Fn2() {} //@ diag(`1x "bar", 1x "meow"`) 14 | func (meow T3) Fn3() {} 15 | 16 | func (bar T4) Fn2() {} 17 | -------------------------------------------------------------------------------- /stylecheck/st1016/testdata/go1.0/CheckReceiverNamesIdentical/generated.go: -------------------------------------------------------------------------------- 1 | // Code generated by hand. DO NOT EDIT. 2 | 3 | package pkg 4 | 5 | // Methods on T2 are only defined in this generated file 6 | // Methods on T3 and T4 are defined in this file and a non-generated file 7 | 8 | type T2 struct{} 9 | 10 | func (foo T2) Fn1() {} 11 | func (bar T2) Fn2() {} 12 | 13 | type T3 struct{} 14 | 15 | func (foo T3) Fn1() {} 16 | 17 | type T4 struct{} 18 | 19 | func (foo T4) Fn1() {} 20 | -------------------------------------------------------------------------------- /stylecheck/st1017/st1017_test.go: -------------------------------------------------------------------------------- 1 | // Code generated by generate.go. DO NOT EDIT. 2 | 3 | package st1017 4 | 5 | import ( 6 | "testing" 7 | 8 | "honnef.co/go/tools/analysis/lint/testutil" 9 | ) 10 | 11 | func TestTestdata(t *testing.T) { 12 | testutil.Run(t, SCAnalyzer) 13 | } 14 | -------------------------------------------------------------------------------- /stylecheck/st1017/testdata/go1.0/CheckYodaConditions/CheckYodaConditions.go: -------------------------------------------------------------------------------- 1 | // Package pkg ... 2 | package pkg 3 | 4 | func fn(x string, y int) { 5 | if "" == x { //@ diag(`Yoda`) 6 | } 7 | if 0 == y { //@ diag(`Yoda`) 8 | } 9 | if 0 > y { 10 | } 11 | if "" == "" { 12 | } 13 | 14 | if "" == "" || 0 == y { //@ diag(`Yoda`) 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /stylecheck/st1017/testdata/go1.0/CheckYodaConditions/CheckYodaConditions.go.golden: -------------------------------------------------------------------------------- 1 | // Package pkg ... 2 | package pkg 3 | 4 | func fn(x string, y int) { 5 | if x == "" { //@ diag(`Yoda`) 6 | } 7 | if y == 0 { //@ diag(`Yoda`) 8 | } 9 | if 0 > y { 10 | } 11 | if "" == "" { 12 | } 13 | 14 | if "" == "" || y == 0 { //@ diag(`Yoda`) 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /stylecheck/st1018/st1018_test.go: -------------------------------------------------------------------------------- 1 | // Code generated by generate.go. DO NOT EDIT. 2 | 3 | package st1018 4 | 5 | import ( 6 | "testing" 7 | 8 | "honnef.co/go/tools/analysis/lint/testutil" 9 | ) 10 | 11 | func TestTestdata(t *testing.T) { 12 | testutil.Run(t, SCAnalyzer) 13 | } 14 | -------------------------------------------------------------------------------- /stylecheck/st1019/st1019_test.go: -------------------------------------------------------------------------------- 1 | // Code generated by generate.go. DO NOT EDIT. 2 | 3 | package st1019 4 | 5 | import ( 6 | "testing" 7 | 8 | "honnef.co/go/tools/analysis/lint/testutil" 9 | ) 10 | 11 | func TestTestdata(t *testing.T) { 12 | testutil.Run(t, SCAnalyzer) 13 | } 14 | -------------------------------------------------------------------------------- /stylecheck/st1019/testdata/go1.0/CheckDuplicatedImports/CheckDuplicatedImports.go: -------------------------------------------------------------------------------- 1 | // Package pkg ... 2 | package pkg 3 | 4 | import ( 5 | "fmt" //@ diag(`package "fmt" is being imported more than once`) 6 | fmt1 "fmt" 7 | fmt2 "fmt" 8 | 9 | fine "net/http" 10 | 11 | "os" //@ diag(`package "os" is being imported more than once`) 12 | os1 "os" 13 | 14 | "C" 15 | _ "unsafe" 16 | ) 17 | 18 | var _ = fmt.Println 19 | var _ = fmt1.Println 20 | var _ = fmt2.Println 21 | var _ = fine.ListenAndServe 22 | var _ = os.Getenv 23 | var _ = os1.Getenv 24 | -------------------------------------------------------------------------------- /stylecheck/st1020/st1020_test.go: -------------------------------------------------------------------------------- 1 | // Code generated by generate.go. DO NOT EDIT. 2 | 3 | package st1020 4 | 5 | import ( 6 | "testing" 7 | 8 | "honnef.co/go/tools/analysis/lint/testutil" 9 | ) 10 | 11 | func TestTestdata(t *testing.T) { 12 | testutil.Run(t, SCAnalyzer) 13 | } 14 | -------------------------------------------------------------------------------- /stylecheck/st1020/testdata/go1.0/CheckExportedFunctionDocs/foo_test.go: -------------------------------------------------------------------------------- 1 | package pkg 2 | 3 | import "testing" 4 | 5 | // This is a test 6 | func TestFoo(t *testing.T) {} 7 | -------------------------------------------------------------------------------- /stylecheck/st1021/st1021_test.go: -------------------------------------------------------------------------------- 1 | // Code generated by generate.go. DO NOT EDIT. 2 | 3 | package st1021 4 | 5 | import ( 6 | "testing" 7 | 8 | "honnef.co/go/tools/analysis/lint/testutil" 9 | ) 10 | 11 | func TestTestdata(t *testing.T) { 12 | testutil.Run(t, SCAnalyzer) 13 | } 14 | -------------------------------------------------------------------------------- /stylecheck/st1022/st1022_test.go: -------------------------------------------------------------------------------- 1 | // Code generated by generate.go. DO NOT EDIT. 2 | 3 | package st1022 4 | 5 | import ( 6 | "testing" 7 | 8 | "honnef.co/go/tools/analysis/lint/testutil" 9 | ) 10 | 11 | func TestTestdata(t *testing.T) { 12 | testutil.Run(t, SCAnalyzer) 13 | } 14 | -------------------------------------------------------------------------------- /stylecheck/st1023/st1023_test.go: -------------------------------------------------------------------------------- 1 | // Code generated by generate.go. DO NOT EDIT. 2 | 3 | package st1023 4 | 5 | import ( 6 | "testing" 7 | 8 | "honnef.co/go/tools/analysis/lint/testutil" 9 | ) 10 | 11 | func TestTestdata(t *testing.T) { 12 | testutil.Run(t, SCAnalyzer) 13 | } 14 | -------------------------------------------------------------------------------- /stylecheck/st1023/testdata/go1.0/CheckRedundantTypeInDeclaration_syscall/CheckRedundantTypeInDeclaration_syscall.go: -------------------------------------------------------------------------------- 1 | package pkg 2 | 3 | import _ "syscall" 4 | 5 | func fn() { 6 | // not flagged because we're importing syscall 7 | var x int = 1 8 | _ = x 9 | } 10 | -------------------------------------------------------------------------------- /unused/testdata/src/example.com/anonymous/anonymous.go: -------------------------------------------------------------------------------- 1 | package pkg 2 | 3 | import "fmt" 4 | 5 | type Node interface { //@ used("Node", true) 6 | position() int //@ used("position", true) 7 | } 8 | 9 | type noder struct{} //@ used("noder", true) 10 | 11 | func (noder) position() int { panic("unreachable") } //@ used("position", true) 12 | 13 | func Fn() { //@ used("Fn", true) 14 | nodes := []Node{struct { //@ used("nodes", true) 15 | noder //@ used("noder", true) 16 | }{}} 17 | fmt.Println(nodes) 18 | } 19 | -------------------------------------------------------------------------------- /unused/testdata/src/example.com/blank-function-parameter/blank.go: -------------------------------------------------------------------------------- 1 | package pkg 2 | 3 | type customType int //@ used("customType", true) 4 | 5 | func Foo(customType) {} //@ used("Foo", true), used("", true) 6 | func bar(customType) {} //@ used("bar", false), quiet("") 7 | -------------------------------------------------------------------------------- /unused/testdata/src/example.com/cgo/cgo.go: -------------------------------------------------------------------------------- 1 | package pkg 2 | 3 | //go:cgo_export_dynamic 4 | func foo() {} //@ used("foo", true) 5 | 6 | func bar() {} //@ used("bar", false) 7 | -------------------------------------------------------------------------------- /unused/testdata/src/example.com/constexpr/constexpr.go: -------------------------------------------------------------------------------- 1 | package pkg 2 | 3 | import ( 4 | "io" 5 | "unsafe" 6 | ) 7 | 8 | // https://staticcheck.dev/issues/812 9 | 10 | var ( 11 | w io.Writer //@ used("w", true) 12 | sz = unsafe.Sizeof(w) //@ used("sz", true) 13 | ) 14 | 15 | var _ = sz //@ used("_", true) 16 | 17 | type t struct { //@ used("t", true) 18 | F int //@ used("F", true) 19 | } 20 | 21 | const S = unsafe.Sizeof(t{}) //@ used("S", true) 22 | -------------------------------------------------------------------------------- /unused/testdata/src/example.com/cyclic/cyclic.go: -------------------------------------------------------------------------------- 1 | package pkg 2 | 3 | func a() { //@ used("a", false) 4 | b() 5 | } 6 | 7 | func b() { //@ used("b", false) 8 | a() 9 | } 10 | -------------------------------------------------------------------------------- /unused/testdata/src/example.com/defer/defer.go: -------------------------------------------------------------------------------- 1 | package pkg 2 | 3 | type t struct{} //@ used("t", true) 4 | 5 | func (t) fn1() {} //@ used("fn1", true) 6 | func (t) fn2() {} //@ used("fn2", true) 7 | func fn1() {} //@ used("fn1", true) 8 | func fn2() {} //@ used("fn2", true) 9 | 10 | func Fn() { //@ used("Fn", true) 11 | var v t //@ used("v", true) 12 | defer fn1() 13 | defer v.fn1() 14 | go fn2() 15 | go v.fn2() 16 | } 17 | -------------------------------------------------------------------------------- /unused/testdata/src/example.com/elem/elem.go: -------------------------------------------------------------------------------- 1 | // Test of field usage detection 2 | 3 | package pkg 4 | 5 | type t15 struct { //@ used("t15", true) 6 | f151 int //@ used("f151", true) 7 | } 8 | type a2 [1]t15 //@ used("a2", true) 9 | 10 | type t16 struct{} //@ used("t16", true) 11 | type a3 [1][1]t16 //@ used("a3", true) 12 | 13 | func foo() { //@ used("foo", true) 14 | _ = a2{0: {1}} 15 | _ = a3{{{}}} 16 | } 17 | 18 | func init() { foo() } //@ used("init", true) 19 | -------------------------------------------------------------------------------- /unused/testdata/src/example.com/exported_fields_main/exported_fields_main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | type t1 struct { //@ used("t1", true) 4 | F1 int //@ used("F1", true) 5 | } 6 | 7 | type T2 struct { //@ used("T2", true) 8 | F2 int //@ used("F2", true) 9 | } 10 | 11 | func init() { //@ used("init", true) 12 | _ = t1{} 13 | _ = T2{} 14 | } 15 | -------------------------------------------------------------------------------- /unused/testdata/src/example.com/exported_method_test/exported_method.go: -------------------------------------------------------------------------------- 1 | package pkg 2 | -------------------------------------------------------------------------------- /unused/testdata/src/example.com/generated/generated.go: -------------------------------------------------------------------------------- 1 | // Code generated by a monkey. DO NOT EDIT. 2 | 3 | // https://staticcheck.dev/issues/1333 4 | 5 | package pkg 6 | 7 | func generated1() {} //@ used("generated1", true) 8 | func generated2() { normal2() } //@ used("generated2", true) 9 | 10 | var x = normal4() //@ used("x", true) 11 | -------------------------------------------------------------------------------- /unused/testdata/src/example.com/generated/normal.go: -------------------------------------------------------------------------------- 1 | package pkg 2 | 3 | // https://staticcheck.dev/issues/1333 4 | 5 | func normal1() {} //@ used("normal1", false) 6 | func normal2() {} //@ used("normal2", true) 7 | func normal3() int { return 0 } //@ used("normal3", false) 8 | func normal4() int { return 0 } //@ used("normal4", true) 9 | -------------------------------------------------------------------------------- /unused/testdata/src/example.com/ignored/ignored2.go: -------------------------------------------------------------------------------- 1 | package pkg 2 | 3 | func (t1) fn4() {} //@ used("fn4", true) 4 | -------------------------------------------------------------------------------- /unused/testdata/src/example.com/ignored/ignored3.go: -------------------------------------------------------------------------------- 1 | //lint:file-ignore U1000 consider everything in here used 2 | 3 | package pkg 4 | 5 | type t9 struct{} //@ used("t9", true) 6 | 7 | func (t9) fn1() {} //@ used("fn1", true) 8 | -------------------------------------------------------------------------------- /unused/testdata/src/example.com/ignored/ignored4.go: -------------------------------------------------------------------------------- 1 | package pkg 2 | 3 | func (t9) fn2() {} //@ used("fn2", true) 4 | -------------------------------------------------------------------------------- /unused/testdata/src/example.com/implicit-conversion/implicit-conversion.go: -------------------------------------------------------------------------------- 1 | package pkg 2 | 3 | // https://staticcheck.dev/issues/810 4 | 5 | type Thing struct { //@ used("Thing", true) 6 | has struct { //@ used("has", true) 7 | a bool //@ used("a", true) 8 | } 9 | } 10 | 11 | func Fn() { //@ used("Fn", true) 12 | type temp struct { //@ used("temp", true) 13 | a bool //@ used("a", true) 14 | } 15 | 16 | x := Thing{ //@ used("x", true) 17 | has: temp{true}, 18 | } 19 | _ = x 20 | } 21 | -------------------------------------------------------------------------------- /unused/testdata/src/example.com/increment/increment.go: -------------------------------------------------------------------------------- 1 | package pkg 2 | 3 | type T struct { //@ used("T", true), used_test("T", true) 4 | // Writing to fields uses them 5 | f int //@ used("f", true), used_test("f", true) 6 | } 7 | 8 | // Not used, v is only written to 9 | var v int //@ used("v", false), used_test("v", false) 10 | 11 | func Foo() { //@ used("Foo", true), used_test("Foo", true) 12 | var x T //@ used("x", true), used_test("x", true) 13 | x.f++ 14 | v++ 15 | } 16 | -------------------------------------------------------------------------------- /unused/testdata/src/example.com/increment/increment_test.go: -------------------------------------------------------------------------------- 1 | package pkg 2 | 3 | // Used because v2 is a sink 4 | var v2 int //@ used_test("v2", true) 5 | 6 | func Bar() { //@ used_test("Bar", true) 7 | v2++ 8 | } 9 | -------------------------------------------------------------------------------- /unused/testdata/src/example.com/index-write/write.go: -------------------------------------------------------------------------------- 1 | package pkg 2 | 3 | var x int //@ used("x", true) 4 | 5 | func Foo() { //@ used("Foo", true) 6 | var s []int //@ used("s", true) 7 | s[x] = 0 8 | } 9 | -------------------------------------------------------------------------------- /unused/testdata/src/example.com/initializers/initializers.go: -------------------------------------------------------------------------------- 1 | package pkg 2 | 3 | // https://staticcheck.dev/issues/507 4 | 5 | var x = [3]int{1, 2, 3} //@ used("x", false) 6 | -------------------------------------------------------------------------------- /unused/testdata/src/example.com/instantiated-functions/instantiated-functions.go: -------------------------------------------------------------------------------- 1 | package pkg 2 | 3 | // https://staticcheck.dev/issues/1199 4 | 5 | type c1 struct{} //@ used("c1", false) 6 | 7 | func Fn[T any]() {} //@ used("Fn", true), used("T", true) 8 | 9 | func uncalled() { //@ used("uncalled", false) 10 | Fn[c1]() 11 | } 12 | 13 | type c2 struct{} //@ used("c2", true) 14 | 15 | func Called() { //@ used("Called", true) 16 | Fn[c2]() 17 | } 18 | -------------------------------------------------------------------------------- /unused/testdata/src/example.com/interfaces2/interfaces.go: -------------------------------------------------------------------------------- 1 | package pkg 2 | 3 | type I interface { //@ used("I", true) 4 | foo() //@ used("foo", true) 5 | } 6 | 7 | type T struct{} //@ used("T", true) 8 | 9 | func (T) foo() {} //@ used("foo", true) 10 | func (T) bar() {} //@ used("bar", false) 11 | 12 | var _ struct { //@ used("_", true) 13 | T //@ used("T", true) 14 | } 15 | -------------------------------------------------------------------------------- /unused/testdata/src/example.com/local-type-param-sink/typeparam.go: -------------------------------------------------------------------------------- 1 | package tparamsource 2 | 3 | // https://staticcheck.dev/issues/1282 4 | 5 | import "reflect" 6 | 7 | func TypeOfType[T any]() reflect.Type { //@ used("TypeOfType", true), used("T", true) 8 | var t *T //@ used("t", true) 9 | return reflect.TypeOf(t).Elem() 10 | } 11 | -------------------------------------------------------------------------------- /unused/testdata/src/example.com/local-type-param-source/typeparam.go: -------------------------------------------------------------------------------- 1 | package tparamsource 2 | 3 | // https://staticcheck.dev/issues/1282 4 | 5 | import ( 6 | "testing" 7 | 8 | tparamsink "example.com/local-type-param-sink" 9 | ) 10 | 11 | func TestFoo(t *testing.T) { //@ used("TestFoo", true), used("t", true) 12 | type EmptyStruct struct{} //@ used("EmptyStruct", true) 13 | _ = tparamsink.TypeOfType[EmptyStruct]() 14 | } 15 | -------------------------------------------------------------------------------- /unused/testdata/src/example.com/main/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | func Fn1() {} //@ used("Fn1", true) 4 | func Fn2() {} //@ used("Fn2", true) 5 | func fn3() {} //@ used("fn3", false) 6 | 7 | const X = 1 //@ used("X", true) 8 | 9 | var Y = 2 //@ used("Y", true) 10 | 11 | type Z struct{} //@ used("Z", true) 12 | 13 | func main() { //@ used("main", true) 14 | Fn1() 15 | } 16 | -------------------------------------------------------------------------------- /unused/testdata/src/example.com/mapslice/mapslice.go: -------------------------------------------------------------------------------- 1 | package pkg 2 | 3 | type M map[int]int //@ used("M", true) 4 | 5 | func Fn() { //@ used("Fn", true) 6 | var n M //@ used("n", true) 7 | _ = []M{n} 8 | } 9 | -------------------------------------------------------------------------------- /unused/testdata/src/example.com/methods/methods.go: -------------------------------------------------------------------------------- 1 | package pkg 2 | 3 | type t1 struct{} //@ used("t1", true) 4 | type t2 struct { //@ used("t2", true) 5 | t3 //@ used("t3", true) 6 | } 7 | type t3 struct{} //@ used("t3", true) 8 | 9 | func (t1) Foo() {} //@ used("Foo", true) 10 | func (t3) Foo() {} //@ used("Foo", true) 11 | func (t3) foo() {} //@ used("foo", false) 12 | 13 | func init() { //@ used("init", true) 14 | _ = t1{} 15 | _ = t2{} 16 | } 17 | -------------------------------------------------------------------------------- /unused/testdata/src/example.com/named/named.go: -------------------------------------------------------------------------------- 1 | package pkg 2 | 3 | type t1 struct{} //@ used("t1", true) 4 | type T2 t1 //@ used("T2", true) 5 | -------------------------------------------------------------------------------- /unused/testdata/src/example.com/nocopy-main/stub.go: -------------------------------------------------------------------------------- 1 | package main 2 | -------------------------------------------------------------------------------- /unused/testdata/src/example.com/parens/parens.go: -------------------------------------------------------------------------------- 1 | package p 2 | 3 | func F(c chan bool) { //@ used("F", true), used("c", true) 4 | select { 5 | case (<-c): 6 | case _ = (<-c): 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /unused/testdata/src/example.com/pointer-type-embedding/pointer-type-embedding.go: -------------------------------------------------------------------------------- 1 | package pkg 2 | 3 | func init() { //@ used("init", true) 4 | var p P //@ used("p", true) 5 | _ = p.n 6 | } 7 | 8 | type T0 struct { //@ used("T0", true) 9 | m int //@ used("m", false) 10 | n int //@ used("n", true) 11 | } 12 | 13 | type T1 struct { //@ used("T1", true) 14 | T0 //@ used("T0", true) 15 | } 16 | 17 | type P *T1 //@ used("P", true) 18 | -------------------------------------------------------------------------------- /unused/testdata/src/example.com/pointers/pointers.go: -------------------------------------------------------------------------------- 1 | package baz 2 | 3 | import "fmt" 4 | 5 | type Foo interface { //@ used("Foo", true) 6 | bar() //@ used("bar", true) 7 | } 8 | 9 | func Bar(f Foo) { //@ used("Bar", true), used("f", true) 10 | f.bar() 11 | } 12 | 13 | type Buzz struct{} //@ used("Buzz", true) 14 | 15 | func (b *Buzz) bar() { //@ used("bar", true), used("b", true) 16 | fmt.Println("foo bar buzz") 17 | } 18 | -------------------------------------------------------------------------------- /unused/testdata/src/example.com/selectors/selectors.go: -------------------------------------------------------------------------------- 1 | package pkg 2 | 3 | type t struct { //@ used("t", true) 4 | f int //@ used("f", true) 5 | } 6 | 7 | func fn(v *t) { //@ used("fn", true), used("v", true) 8 | println(v.f) 9 | } 10 | 11 | func init() { //@ used("init", true) 12 | var v t //@ used("v", true) 13 | fn(&v) 14 | } 15 | -------------------------------------------------------------------------------- /unused/testdata/src/example.com/skipped-test/skipped_test.go: -------------------------------------------------------------------------------- 1 | package pkg 2 | 3 | // https://staticcheck.dev/issues/633 4 | 5 | import "testing" 6 | 7 | func test() { //@ used_test("test", true) 8 | } 9 | 10 | func TestSum(t *testing.T) { //@ used_test("TestSum", true), used_test("t", true) 11 | t.Skip("skipping for test") 12 | test() 13 | } 14 | -------------------------------------------------------------------------------- /unused/testdata/src/example.com/switch_interface/switch_interface.go: -------------------------------------------------------------------------------- 1 | package pkg 2 | 3 | type t struct{} //@ used("t", true) 4 | 5 | func (t) fragment() {} //@ used("fragment", true) 6 | 7 | func fn() bool { //@ used("fn", true) 8 | var v interface{} = t{} //@ used("v", true) 9 | switch obj := v.(type) { //@ used("obj", true) 10 | case interface { 11 | fragment() //@ used("fragment", true) 12 | }: 13 | obj.fragment() 14 | } 15 | return false 16 | } 17 | 18 | var x = fn() //@ used("x", true) 19 | var _ = x //@ used("_", true) 20 | -------------------------------------------------------------------------------- /unused/testdata/src/example.com/tests-main/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | -------------------------------------------------------------------------------- /unused/testdata/src/example.com/tests-main/main_test.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "testing" 5 | ) 6 | 7 | type t1 struct{} //@ used_test("t1", true) 8 | 9 | func TestFoo(t *testing.T) { //@ used_test("TestFoo", true), used_test("t", true) 10 | _ = t1{} 11 | } 12 | -------------------------------------------------------------------------------- /unused/testdata/src/example.com/tests/tests.go: -------------------------------------------------------------------------------- 1 | package pkg 2 | 3 | func fn() {} //@ used("fn", false), used_test("fn", true) 4 | -------------------------------------------------------------------------------- /unused/testdata/src/example.com/tests/tests_test.go: -------------------------------------------------------------------------------- 1 | package pkg 2 | 3 | import "testing" 4 | 5 | func TestFn(t *testing.T) { //@ used_test("TestFn", true), used_test("t", true) 6 | fn() 7 | } 8 | -------------------------------------------------------------------------------- /unused/testdata/src/example.com/type-dedup/dedup.go: -------------------------------------------------------------------------------- 1 | package pkg 2 | 3 | type t1 struct { //@ used("t1", true) 4 | a int //@ used("a", true) 5 | b int //@ used("b", false) 6 | } 7 | 8 | type t2 struct { //@ used("t2", true) 9 | a int //@ used("a", false) 10 | b int //@ used("b", true) 11 | } 12 | 13 | func Fn() { //@ used("Fn", true) 14 | x := t1{} //@ used("x", true) 15 | y := t2{} //@ used("y", true) 16 | println(x.a) 17 | println(y.b) 18 | } 19 | -------------------------------------------------------------------------------- /unused/testdata/src/example.com/type-dedup2/dedup.go: -------------------------------------------------------------------------------- 1 | package pkg 2 | 3 | func fn1(t struct { //@ used("fn1", true), used("t", true) 4 | a int //@ used("a", true) 5 | b int //@ used("b", true) 6 | }) { 7 | println(t.a) 8 | fn2(t) 9 | } 10 | 11 | func fn2(t struct { //@ used("fn2", true), used("t", true) 12 | a int //@ used("a", true) 13 | b int //@ used("b", true) 14 | }) { 15 | println(t.b) 16 | } 17 | 18 | func Fn() { //@ used("Fn", true) 19 | fn1(struct { 20 | a int //@ used("a", true) 21 | b int //@ used("b", true) 22 | }{}) 23 | } 24 | -------------------------------------------------------------------------------- /unused/testdata/src/example.com/type-dedup3/dedup.go: -------------------------------------------------------------------------------- 1 | package pkg 2 | 3 | func fn1(t struct { //@ used("fn1", true), used("t", true) 4 | a int //@ used("a", true) 5 | b int //@ used("b", true) 6 | }) { 7 | fn2(t) 8 | } 9 | 10 | func fn2(t struct { //@ used("fn2", true), used("t", true) 11 | a int //@ used("a", true) 12 | b int //@ used("b", true) 13 | }) { 14 | println(t.a) 15 | println(t.b) 16 | } 17 | 18 | func Fn() { //@ used("Fn", true) 19 | fn1(struct { 20 | a int //@ used("a", true) 21 | b int //@ used("b", true) 22 | }{1, 2}) 23 | } 24 | -------------------------------------------------------------------------------- /unused/testdata/src/example.com/typeparams/typeparams_17.go: -------------------------------------------------------------------------------- 1 | //go:build !go1.18 2 | 3 | package pkg 4 | -------------------------------------------------------------------------------- /unused/testdata/src/example.com/types/types.go: -------------------------------------------------------------------------------- 1 | package pkg 2 | 3 | import "reflect" 4 | 5 | type wkt interface { //@ used("wkt", true) 6 | XXX_WellKnownType() string //@ used("XXX_WellKnownType", true) 7 | } 8 | 9 | var typeOfWkt = reflect.TypeOf((*wkt)(nil)).Elem() //@ used("typeOfWkt", true) 10 | 11 | func Fn() { //@ used("Fn", true) 12 | _ = typeOfWkt 13 | } 14 | 15 | type t *int //@ used("t", true) 16 | 17 | var _ t //@ used("_", true) 18 | -------------------------------------------------------------------------------- /unused/testdata/src/example.com/unused-argument/unused-argument.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | type t1 struct{} //@ used("t1", true) 4 | type t2 struct{} //@ used("t2", true) 5 | 6 | func (t1) foo(arg *t2) {} //@ used("foo", true), used("arg", true) 7 | 8 | func init() { //@ used("init", true) 9 | t1{}.foo(nil) 10 | } 11 | -------------------------------------------------------------------------------- /unused/testdata/src/example.com/unused_type/unused_type.go: -------------------------------------------------------------------------------- 1 | package pkg 2 | 3 | type t1 struct{} //@ used("t1", false) 4 | 5 | func (t1) Fn() {} //@ used("Fn", false) 6 | 7 | type t2 struct{} //@ used("t2", true) 8 | 9 | func (*t2) Fn() {} //@ used("Fn", true) 10 | 11 | func init() { //@ used("init", true) 12 | (*t2).Fn(nil) 13 | } 14 | 15 | type t3 struct{} //@ used("t3", false) 16 | 17 | func (t3) fn() //@ used("fn", false) 18 | -------------------------------------------------------------------------------- /unused/testdata/src/example.com/variables/vartype.go: -------------------------------------------------------------------------------- 1 | package pkg 2 | 3 | type t181025 struct{} //@ used("t181025", true) 4 | 5 | func (t181025) F() {} //@ used("F", true) 6 | 7 | // package-level variable after function declaration used to trigger a 8 | // bug in unused. 9 | 10 | var V181025 t181025 //@ used("V181025", true) 11 | -------------------------------------------------------------------------------- /website/archetypes/default.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: "{{ replace .Name "-" " " | title }}" 3 | date: {{ .Date }} 4 | draft: true 5 | --- 6 | 7 | -------------------------------------------------------------------------------- /website/assets/js/base.js: -------------------------------------------------------------------------------- 1 | // Overwrites Docsy's main.js, which implements various things we don't use 2 | // - a top nav that fades away, looks cool with the promo block 3 | // - popovers for client-side search 4 | // - tooltips for the icons in the footer 5 | 6 | // Pretend that Cash is jQuery 7 | var jQuery = $; 8 | -------------------------------------------------------------------------------- /website/assets/scss/_variables_project.scss: -------------------------------------------------------------------------------- 1 | $primary: #30638E; 2 | $secondary: #CE3262; 3 | -------------------------------------------------------------------------------- /website/build.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | set -e 3 | rm -rf ./public 4 | mkdir -p data 5 | mkdir -p content/docs/configuration/default_config 6 | go run ./cmd/generate_checks/generate_checks.go >data/checks.json 7 | go run ./cmd/generate_config/generate_config.go >content/docs/configuration/default_config/index.md 8 | 9 | ( 10 | cd themes/docsy 11 | # --omit=dev so we don't try to install Hugo as an NPM module 12 | npm install --omit=dev 13 | ) 14 | 15 | go run github.com/gohugoio/hugo@v0.110.0 --minify 16 | -------------------------------------------------------------------------------- /website/content/changes/_index.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Release notes 3 | type: docs 4 | outputs: 5 | - html 6 | - RSS 7 | cascade: 8 | type: docs 9 | --- 10 | 11 | -------------------------------------------------------------------------------- /website/content/docs/changes.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Release notes 3 | manualLinkRelref: "/changes" 4 | --- 5 | -------------------------------------------------------------------------------- /website/content/docs/running-staticcheck/_index.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Running Staticcheck 3 | weight: 2 4 | aliases: 5 | - /docs/run 6 | --- 7 | -------------------------------------------------------------------------------- /website/content/docs/running-staticcheck/ci/_index.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Continuous integration 3 | description: How to run Staticcheck in CI 4 | --- 5 | -------------------------------------------------------------------------------- /website/content/docs/running-staticcheck/editors.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Editors 3 | description: How to run Staticcheck in editors 4 | draft: true 5 | --- 6 | -------------------------------------------------------------------------------- /website/go.mod: -------------------------------------------------------------------------------- 1 | module honnef.co/go/tools/website 2 | 3 | go 1.23 4 | 5 | toolchain go1.24.0 6 | 7 | replace honnef.co/go/tools => ../ 8 | 9 | require ( 10 | github.com/BurntSushi/toml v1.4.1-0.20240526193622-a339e1f7089c 11 | honnef.co/go/tools v0.0.0-00010101000000-000000000000 12 | ) 13 | 14 | require ( 15 | golang.org/x/exp/typeparams v0.0.0-20231108232855-2478ac86f678 // indirect 16 | golang.org/x/mod v0.23.0 // indirect 17 | golang.org/x/sync v0.11.0 // indirect 18 | golang.org/x/tools v0.30.0 // indirect 19 | ) 20 | -------------------------------------------------------------------------------- /website/layouts/shortcodes/check.html: -------------------------------------------------------------------------------- 1 | {{ $name := .Get 0 -}} 2 | {{ $check := index $.Site.Data.checks.Checks $name -}} 3 | {{ with .Get 0 }}{{$name}}{{ end -}} 4 | -------------------------------------------------------------------------------- /website/layouts/shortcodes/commit.html: -------------------------------------------------------------------------------- 1 | {{ with .Get 0 }}{{ . }}{{ end -}} 2 | -------------------------------------------------------------------------------- /website/layouts/shortcodes/content.html: -------------------------------------------------------------------------------- 1 | {{$file := .Get 0}} 2 | {{ with .Site.GetPage $file }}{{ .Content | markdownify }}{{ end }} 3 | -------------------------------------------------------------------------------- /website/layouts/shortcodes/details.html: -------------------------------------------------------------------------------- 1 |
2 | {{ .Get 0 }} 3 | {{ .Inner | markdownify }} 4 |
5 | -------------------------------------------------------------------------------- /website/layouts/shortcodes/faq/list.html: -------------------------------------------------------------------------------- 1 |
2 | {{ .Inner }} 3 |
4 | -------------------------------------------------------------------------------- /website/layouts/shortcodes/faq/question.md: -------------------------------------------------------------------------------- 1 |
2 | 3 | ## {{ .Get "question" }} {#{{ .Get "id" }}} 4 | 5 |
6 |
7 | {{ .Inner }} 8 |
9 |
10 |
11 | -------------------------------------------------------------------------------- /website/layouts/shortcodes/issue.html: -------------------------------------------------------------------------------- 1 | {{ with .Get 0 }}issue {{ . }}{{ end -}} 2 | -------------------------------------------------------------------------------- /website/layouts/shortcodes/issueref.html: -------------------------------------------------------------------------------- 1 | https://staticcheck.dev/issues/{{ .Get 0 }} 2 | -------------------------------------------------------------------------------- /website/layouts/shortcodes/option.html: -------------------------------------------------------------------------------- 1 | {{ .Get 0 }}{{"" -}} 2 | -------------------------------------------------------------------------------- /website/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "dependencies": { 3 | "autoprefixer": "^10.4.13", 4 | "postcss": "^8.4.31", 5 | "postcss-cli": "^10.1.0" 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /website/shell.nix: -------------------------------------------------------------------------------- 1 | { pkgs ? import {} }: 2 | pkgs.mkShell { 3 | # nativeBuildInputs is usually what you want -- tools you need to run 4 | nativeBuildInputs = with pkgs; [ postcss-cli nodejs ]; 5 | } 6 | -------------------------------------------------------------------------------- /website/static/_headers: -------------------------------------------------------------------------------- 1 | /img/* 2 | cache-control: public 3 | cache-control: max-age=604800 4 | cache-control: immutable 5 | 6 | /webfonts/* 7 | cache-control: public 8 | cache-control: max-age=604800 9 | cache-control: immutable 10 | 11 | /scss/*.css 12 | cache-control: public 13 | cache-control: max-age=604800 14 | cache-control: immutable 15 | 16 | /js/*.js 17 | cache-control: public 18 | cache-control: max-age=604800 19 | cache-control: immutable 20 | -------------------------------------------------------------------------------- /website/static/img/logo.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dominikh/go-tools/bbc2f4dd71ea1dd1f0801fd7b7c4b7a22b9a90ba/website/static/img/logo.webp -------------------------------------------------------------------------------- /website/website.go: -------------------------------------------------------------------------------- 1 | package website 2 | --------------------------------------------------------------------------------