{"id":207372,"date":"2025-07-08T08:26:44","date_gmt":"2025-07-08T00:26:44","guid":{"rendered":"https:\/\/server.hk\/cnblog\/207372\/"},"modified":"2025-07-08T08:26:44","modified_gmt":"2025-07-08T00:26:44","slug":"%e5%a6%82%e4%bd%95%e7%94%a8%e5%87%a0%e8%a1%8c%e4%bb%a3%e7%a0%81%e6%94%b9%e8%bf%9b%e8%bf%99%e4%b8%aa%e7%a8%8b%e5%ba%8f%ef%bc%9f","status":"publish","type":"post","link":"https:\/\/server.hk\/cnblog\/207372\/","title":{"rendered":"\u5982\u4f55\u7528\u51e0\u884c\u4ee3\u7801\u6539\u8fdb\u8fd9\u4e2a\u7a0b\u5e8f\uff1f"},"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>\u5982\u4f55\u7528\u51e0\u884c\u4ee3\u7801\u6539\u8fdb\u8fd9\u4e2a\u7a0b\u5e8f\uff1f<\/span><\/p>\n<p><span>\u6765\u6e90\uff1astackoverflow<\/span><br \/>\n<span>2024-04-21 23:36:21<\/span><br \/>\n<span><i><\/i>0\u6d4f\u89c8<\/span><br \/>\n<span style=\"cursor: pointer\"><i><\/i>\u6536\u85cf<\/span> <\/p>\n<p>\u7f16\u7a0b\u5e76\u4e0d\u662f\u4e00\u4e2a\u673a\u68b0\u6027\u7684\u5de5\u4f5c\uff0c\u800c\u662f\u9700\u8981\u6709\u601d\u8003\uff0c\u6709\u521b\u65b0\u7684\u5de5\u4f5c\uff0c\u8bed\u6cd5\u662f\u56fa\u5b9a\u7684\uff0c\u4f46\u89e3\u51b3\u95ee\u9898\u7684\u601d\u8def\u5219\u662f\u4f9d\u9760\u4eba\u7684\u601d\u7ef4\uff0c\u8fd9\u5c31\u9700\u8981\u6211\u4eec\u575a\u6301\u5b66\u4e60\u548c\u66f4\u65b0\u81ea\u5df1\u7684\u77e5\u8bc6\u3002\u4eca\u5929\u5c31\u6574\u7406\u5206\u4eab\u300a\u5982\u4f55\u7528\u51e0\u884c\u4ee3\u7801\u6539\u8fdb\u8fd9\u4e2a\u7a0b\u5e8f\uff1f\u300b\uff0c\u6587\u7ae0\u8bb2\u89e3\u7684\u77e5\u8bc6\u70b9\u4e3b\u8981\u5305\u62ec\uff0c\u5982\u679c\u4f60\u5bf9Golang\u65b9\u9762\u7684\u77e5\u8bc6\u70b9\u611f\u5174\u8da3\uff0c\u5c31\u4e0d\u8981\u9519\u8fc7\uff0c\u5728\u8fd9\u53ef\u4ee5\u5bf9\u5927\u5bb6\u7684\u77e5\u8bc6\u79ef\u7d2f\u6709\u6240\u5e2e\u52a9\uff0c\u52a9\u529b\u5f00\u53d1\u80fd\u529b\u7684\u63d0\u5347\u3002<\/p>\n<p> \u95ee\u9898\u5185\u5bb9<br \/>\n <\/p>\n<p>\u6211\u6b63\u5728\u5c1d\u8bd5\u521b\u5efa\u4e00\u4e2a\u4e0d\u548c\u8c10\u7684\u673a\u5668\u4eba\u6765\u68c0\u67e5\u6d88\u606f\u662f\u5426\u5305\u542b\u5b58\u50a8\u5728\u6570\u7ec4\u4e2d\u7684\u5b57\u7b26\u4e32\u3002 \u6211\u5c1d\u8bd5\u4f7f\u7528 for \u5faa\u73af\uff0c\u4f46\u5b83\u4e0d\u8d77\u4f5c\u7528\uff0c\u56e0\u4e3a\u5b83\u6c38\u8fdc\u6301\u7eed\u4e0b\u53bb\uff0c\u6211\u60f3\u51cf\u5c11\u4ee3\u7801\u884c\u6570\uff0c\u6709\u4ec0\u4e48\u529e\u6cd5\u53ef\u4ee5\u505a\u5230\u8fd9\u4e00\u70b9\u5417\uff1f<\/p>\n<pre>switch {\n    case strings.Contains(mContent, characterss[0]):\n        currentCharacter = characterss[0]\n        currentDescription = descriptions[0]\n        currentImage = images[0]\n        isCorrect = true\n    case strings.Contains(mContent, characterss[1]):\n        currentCharacter = characterss[1]\n        currentDescription = descriptions[1]\n        currentImage = images[1]\n        isCorrect = true\n    case strings.Contains(mContent, characterss[2]):\n        currentCharacter = characterss[2]\n        currentDescription = descriptions[2]\n        currentImage = images[2]\n        isCorrect = true\n    case strings.Contains(mContent, characterss[3]):\n        currentCharacter = characterss[3]\n        currentDescription = descriptions[3]\n        currentImage = images[3]\n        isCorrect = true\n    case strings.Contains(mContent, characterss[4]):\n        currentCharacter = characterss[4]\n        currentDescription = descriptions[4]\n        currentImage = images[4]\n        isCorrect = true\n    case strings.Contains(mContent, characterss[5]):\n        currentCharacter = characterss[5]\n        currentDescription = descriptions[5]\n        currentImage = images[5]\n        isCorrect = true\n    case strings.Contains(mContent, characterss[6]):\n        currentCharacter = characterss[6]\n        currentDescription = descriptions[6]\n        currentImage = images[6]\n        isCorrect = true\n    }<\/pre>\n<p> <\/p>\n<h2>\u89e3\u51b3\u65b9\u6848<\/h2>\n<p> <\/p>\n<p>\u53ea\u9700\u4f7f\u7528\u5faa\u73af\uff1a<\/p>\n<pre>for i := 0; i &lt;= 6; i ++ {\n    if strings.Contains(mContent, characeterss[i]) {\n        currentCharacter = characterss[i]\n        currentDescription = descriptions[i]\n        currentImage = images[i]\n        isCorrect = true\n        break\n    }\n}\n<\/pre>\n<p>\u597d\u4e86\uff0c\u672c\u6587\u5230\u6b64\u7ed3\u675f\uff0c\u5e26\u5927\u5bb6\u4e86\u89e3\u4e86\u300a\u5982\u4f55\u7528\u51e0\u884c\u4ee3\u7801\u6539\u8fdb\u8fd9\u4e2a\u7a0b\u5e8f\uff1f\u300b\uff0c\u5e0c\u671b\u672c\u6587\u5bf9\u4f60\u6709\u6240\u5e2e\u52a9\uff01\u5173\u6ce8\u516c\u4f17\u53f7\uff0c\u7ed9\u5927\u5bb6\u5206\u4eab\u66f4\u591aGolang\u77e5\u8bc6\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-207372","post","type-post","status-publish","format-standard","hentry","category-4925"],"_links":{"self":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/207372","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=207372"}],"version-history":[{"count":0,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/207372\/revisions"}],"wp:attachment":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/media?parent=207372"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/categories?post=207372"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/tags?post=207372"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}