{"id":207667,"date":"2025-07-08T13:59:02","date_gmt":"2025-07-08T05:59:02","guid":{"rendered":"https:\/\/server.hk\/cnblog\/207667\/"},"modified":"2025-07-08T13:59:02","modified_gmt":"2025-07-08T05:59:02","slug":"go-gocilint%ef%bc%8c%e5%b0%86%e9%94%99%e8%af%af%e6%a0%87%e8%ae%b0%e5%88%86%e9%85%8d%e7%bb%99%e7%a9%ba%e7%99%bd%e6%a0%87%e8%af%86%e7%ac%a6","status":"publish","type":"post","link":"https:\/\/server.hk\/cnblog\/207667\/","title":{"rendered":"Go GoCILint\uff0c\u5c06\u9519\u8bef\u6807\u8bb0\u5206\u914d\u7ed9\u7a7a\u767d\u6807\u8bc6\u7b26"},"content":{"rendered":"<p><b><\/b> <\/p>\n<p>\u5f53\u524d\u4f4d\u7f6e\uff1a <span>&gt;<\/span> <span>&gt;<\/span> <span>&gt;<\/span> <span>&gt;<\/span> <span>Go GoCILint\uff0c\u5c06\u9519\u8bef\u6807\u8bb0\u5206\u914d\u7ed9\u7a7a\u767d\u6807\u8bc6\u7b26<\/span><\/p>\n<p><span>\u6765\u6e90\uff1astackoverflow<\/span><br \/>\n<span>2024-04-24 14:18:35<\/span><br \/>\n<span><i><\/i>0\u6d4f\u89c8<\/span><br \/>\n<span style=\"cursor: pointer\"><i><\/i>\u6536\u85cf<\/span> <\/p>\n<p>\u4eca\u5929\u5c06\u7ed9\u5927\u5bb6\u5e26\u6765<span style=\"color: #FF6600;, Helvetica, Arial, sans-serif;font-size: 14px;background-color: #FFFFFF\">\u300aGo GoCILint\uff0c\u5c06\u9519\u8bef\u6807\u8bb0\u5206\u914d\u7ed9\u7a7a\u767d\u6807\u8bc6\u7b26\u300b<\/span>\uff0c\u611f\u5174\u8da3\u7684\u670b\u53cb\u8bf7\u7ee7\u7eed\u770b\u4e0b\u53bb\u5427\uff01\u4ee5\u4e0b\u5185\u5bb9\u5c06\u4f1a\u6d89\u53ca\u5230<span style=\"color: #FF6600;, Helvetica, Arial, sans-serif;font-size: 14px;background-color: #FFFFFF\"><\/span>\u7b49\u7b49\u77e5\u8bc6\u70b9\uff0c\u5982\u679c\u4f60\u662f\u6b63\u5728\u5b66\u4e60<span style=\"color: #FF6600;, Helvetica, Arial, sans-serif;font-size: 14px;background-color: #FFFFFF\">Golang<\/span>\u6216\u8005\u5df2\u7ecf\u662f\u5927\u4f6c\u7ea7\u522b\u4e86\uff0c\u90fd\u975e\u5e38\u6b22\u8fce\u4e5f\u5e0c\u671b\u5927\u5bb6\u90fd\u80fd\u7ed9\u6211\u5efa\u8bae\u8bc4\u8bba\u54c8~\u5e0c\u671b\u80fd\u5e2e\u52a9\u5230\u5927\u5bb6\uff01<\/p>\n<p> \u95ee\u9898\u5185\u5bb9<br \/>\n <\/p>\n<p>\u6211\u5df2\u5f00\u59cb\u4f7f\u7528 gocilint\uff0c\u4f46\u5b83\u4e0d\u4f1a\u6807\u8bb0\u5c06\u9519\u8bef\u5206\u914d\u7ed9\u7a7a\u767d\u6807\u8bc6\u7b26\u7684\u4ee3\u7801\u3002<\/p>\n<pre>func someFunc() error{\n\n}\n\n_ := someFunc()<\/pre>\n<p>\u8fd9\u662f\u4e00\u79cd\u4e0d\u6b63\u786e\u7684\u7f16\u7801\u5b9e\u8df5\uff0c\u5176\u4e2d\u9519\u8bef\u88ab\u5206\u914d\u7ed9\u7a7a\u767d\u6807\u8bc6\u7b26\u800c\u4e0d\u8fdb\u884c\u68c0\u67e5\uff0c\u4f46\u8fd9\u5e76\u6ca1\u6709\u88ab gocilint \u6807\u8bb0\u3002 <\/p>\n<p>\u8fd9\u662f lints \u7684\u9650\u5236\u8fd8\u662f\u6211\u5fc5\u987b\u5728\u6b64\u5904\u542f\u7528\u67d0\u4e9b\u529f\u80fd<\/p>\n<p>\u6211\u5df2\u7ecf\u68c0\u67e5\u4e86 errchk\u3001govet\u3001staticanalysis lint \u5de5\u5177\uff0c\u4f46\u5b83\u4eec\u4f3c\u4e4e\u90fd\u6ca1\u6709\u6807\u8bb0\u6b64\u4ee3\u7801<\/p>\n<p> <\/p>\n<h2>\u89e3\u51b3\u65b9\u6848<\/h2>\n<p> <\/p>\n<p> \u9ed8\u8ba4\u63a5\u53d7\u7a7a\u767d\u5206\u914d\uff08\u8fd9\u662f\u6545\u610f\u7684\uff09\u3002<\/p>\n<p>\u4f46\u662f\uff0c\u60a8\u53ef\u4ee5\u4f7f\u7528 <code>-blank<\/code> \u6807\u5fd7\u544a\u8bc9\u5b83\u5728 <code>_<\/code> \u5206\u914d\u4e0a\u89e6\u53d1\u3002<\/p>\n<p>\u8fd9\u8bb0\u5f55\u5728 <code>errcheck<\/code> \u6587\u6863\u7684 \u90e8\u5206\u4e2d\uff1a<\/p>\n<p>-blank \u6807\u5fd7\u5141\u8bb8\u68c0\u67e5\u9519\u8bef\u5206\u914d\u7ed9 \u7a7a\u767d\u6807\u8bc6\u7b26\u3002\u5b83\u4e0d\u9700\u8981\u4efb\u4f55\u53c2\u6570\u3002<\/p>\n<p>\u5728golang-ci\u7ea7\u522b\uff0c\u53ef\u4ee5\u5728\u4e2d\u6307\u5b9a\uff1a<\/p>\n<pre>linters-settings:\n  ...\n  errcheck:\n    ...\n    # report about assignment of errors to blank identifier: `num, _ := strconv.Atoi(numStr)`;\n    # default is false: such cases aren't reported by default.\n    check-blank: false\n    ...<\/pre>\n<p>\u5230\u8fd9\u91cc\uff0c\u6211\u4eec\u4e5f\u5c31\u8bb2\u5b8c\u4e86\u300aGo GoCILint\uff0c\u5c06\u9519\u8bef\u6807\u8bb0\u5206\u914d\u7ed9\u7a7a\u767d\u6807\u8bc6\u7b26\u300b\u7684\u5185\u5bb9\u4e86\u3002\u4e2a\u4eba\u8ba4\u4e3a\uff0c\u57fa\u7840\u77e5\u8bc6\u7684\u5b66\u4e60\u548c\u5de9\u56fa\uff0c\u662f\u4e3a\u4e86\u66f4\u597d\u7684\u5c06\u5176\u8fd0\u7528\u5230\u9879\u76ee\u4e2d\uff0c\u6b22\u8fce\u5173\u6ce8\u516c\u4f17\u53f7\uff0c\u5e26\u4f60\u4e86\u89e3\u66f4\u591a\u5173\u4e8e\u7684\u77e5\u8bc6\u70b9\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5f53\u524d\u4f4d\u7f6e\uff1a &gt; &gt; &#46;&#46;&#46;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4925],"tags":[],"class_list":["post-207667","post","type-post","status-publish","format-standard","hentry","category-4925"],"_links":{"self":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/207667","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/comments?post=207667"}],"version-history":[{"count":0,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/207667\/revisions"}],"wp:attachment":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/media?parent=207667"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/categories?post=207667"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/tags?post=207667"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}