{"id":206241,"date":"2025-06-12T10:23:42","date_gmt":"2025-06-12T02:23:42","guid":{"rendered":"https:\/\/server.hk\/cnblog\/206241\/"},"modified":"2025-06-12T10:23:42","modified_gmt":"2025-06-12T02:23:42","slug":"%e4%ba%8c%e7%bb%b4%e6%95%b0%e7%bb%84%e5%a6%82%e4%bd%95%e8%bd%ac%e5%8c%96%e4%b8%ba%e7%9b%ae%e5%bd%95%e6%a0%91%e7%bb%93%e6%9e%84%ef%bc%9f","status":"publish","type":"post","link":"https:\/\/server.hk\/cnblog\/206241\/","title":{"rendered":"\u4e8c\u7ef4\u6570\u7ec4\u5982\u4f55\u8f6c\u5316\u4e3a\u76ee\u5f55\u6811\u7ed3\u6784\uff1f"},"content":{"rendered":"<p><span style=\"font-size: 15px\">\u6709\u5fd7\u8005\uff0c\u4e8b\u7adf\u6210\uff01\u5982\u679c\u4f60\u5728\u5b66\u4e60<span style=\"color: #FF6600;, Helvetica, Arial, sans-serif;font-size: 14px;background-color: #FFFFFF\">GOLANG<\/span>\uff0c\u90a3\u4e48\u672c\u6587<span style=\"color: #FF6600;, Helvetica, Arial, sans-serif;font-size: 14px;background-color: #FFFFFF\">\u300a\u4e8c\u7ef4\u6570\u7ec4\u5982\u4f55\u8f6c\u5316\u4e3a\u76ee\u5f55\u6811\u7ed3\u6784\uff1f\u300b<\/span>\uff0c\u5c31\u5f88\u9002\u5408\u4f60\uff01\u6587\u7ae0\u8bb2\u89e3\u7684\u77e5\u8bc6\u70b9\u4e3b\u8981\u5305\u62ec<span style=\"color: #FF6600;, Helvetica, Arial, sans-serif;font-size: 14px;background-color: #FFFFFF\"><\/span>\uff0c\u82e5\u662f\u4f60\u5bf9\u672c\u6587\u611f\u5174\u8da3\uff0c\u6216\u8005\u662f\u60f3\u641e\u61c2\u5176\u4e2d\u67d0\u4e2a\u77e5\u8bc6\u70b9\uff0c\u5c31\u8bf7\u4f60\u7ee7\u7eed\u5f80\u4e0b\u770b\u5427~<\/span>,<br \/>\n<img decoding=\"async\" src=\"https:\/\/www.17golang.com\/uploads\/20241107\/1730944653672c1e8db6477.jpg\" class=\"aligncenter\">,<br \/>\n<strong>\u4e8c\u7ef4\u6570\u7ec4\u8f6c\u76ee\u5f55\u7ed3\u6784\u7b97\u6cd5<\/strong>,\u8981\u521b\u5efa\u4e00\u4e2a\u7c7b\u4f3c rdm \u7684\u76ee\u5f55\u6811\uff0c\u9700\u8981\u5c06\u7ed9\u5b9a\u7684\u4e8c\u7ef4\u6570\u7ec4\u8f6c\u6362\u4e3a\u4e00\u4e2a\u5c42\u6b21\u7ed3\u6784\u3002\u4ee5\u4e0b\u7b97\u6cd5\u53ef\u4ee5\u9ad8\u6548\u5730\u6267\u884c\u6b64\u64cd\u4f5c\uff1a,\u4ee5\u4e0b go \u4ee3\u7801\u5b9e\u73b0\u4e86\u6b64\u7b97\u6cd5\uff1a,\u6587\u4e2d\u5173\u4e8e\u7684\u77e5\u8bc6\u4ecb\u7ecd\uff0c\u5e0c\u671b\u5bf9\u4f60\u7684\u5b66\u4e60\u6709\u6240\u5e2e\u52a9\uff01\u82e5\u662f\u53d7\u76ca\u532a\u6d45\uff0c\u90a3\u5c31\u52a8\u52a8\u9f20\u6807\u6536\u85cf\u8fd9\u7bc7\u300a\u4e8c\u7ef4\u6570\u7ec4\u5982\u4f55\u8f6c\u5316\u4e3a\u76ee\u5f55\u6811\u7ed3\u6784\uff1f\u300b\u6587\u7ae0\u5427\uff0c\u4e5f\u53ef\u5173\u6ce8GOLANG\u516c\u4f17\u53f7\u4e86\u89e3\u76f8\u5173\u6280\u672f\u6587\u7ae0\u3002,\u4e8c\u7ef4\u6570\u7ec4\u8f6c\u76ee\u5f55\u7ed3\u6784\u7b97\u6cd5,<br \/>\n<span style=\"font-size: 15px\">\u6709\u5fd7\u8005\uff0c\u4e8b\u7adf\u6210\uff01\u5982\u679c\u4f60\u5728\u5b66\u4e60<span style=\"color: #FF6600;, Helvetica, Arial, sans-serif;font-size: 14px;background-color: #FFFFFF\">GOLANG<\/span>\uff0c\u90a3\u4e48\u672c\u6587<span style=\"color: #FF6600;, Helvetica, Arial, sans-serif;font-size: 14px;background-color: #FFFFFF\">\u300a\u4e8c\u7ef4\u6570\u7ec4\u5982\u4f55\u8f6c\u5316\u4e3a\u76ee\u5f55\u6811\u7ed3\u6784\uff1f\u300b<\/span>\uff0c\u5c31\u5f88\u9002\u5408\u4f60\uff01\u6587\u7ae0\u8bb2\u89e3\u7684\u77e5\u8bc6\u70b9\u4e3b\u8981\u5305\u62ec<span style=\"color: #FF6600;, Helvetica, Arial, sans-serif;font-size: 14px;background-color: #FFFFFF\"><\/span>\uff0c\u82e5\u662f\u4f60\u5bf9\u672c\u6587\u611f\u5174\u8da3\uff0c\u6216\u8005\u662f\u60f3\u641e\u61c2\u5176\u4e2d\u67d0\u4e2a\u77e5\u8bc6\u70b9\uff0c\u5c31\u8bf7\u4f60\u7ee7\u7eed\u5f80\u4e0b\u770b\u5427~<\/span>,<br \/>\n<b><\/b> <\/p>\n<p>\u5f53\u524d\u4f4d\u7f6e\uff1a <span>&gt;<\/span>  <span>&gt;<\/span>  <span>&gt;<\/span>  <span>&gt;<\/span> <span>\u4e8c\u7ef4\u6570\u7ec4\u5982\u4f55\u8f6c\u5316\u4e3a\u76ee\u5f55\u6811\u7ed3\u6784\uff1f<\/span><\/p>\n<h1>\u4e8c\u7ef4\u6570\u7ec4\u5982\u4f55\u8f6c\u5316\u4e3a\u76ee\u5f55\u6811\u7ed3\u6784\uff1f<\/h1>\n<p><span>2024-11-07 09:57:49<\/span><br \/>\n<span><i><\/i>0\u6d4f\u89c8<\/span><br \/>\n<span style=\"cursor: pointer\"><i><\/i>\u6536\u85cf<\/span> <\/p>\n<p><span style=\"font-size: 15px\">\u6709\u5fd7\u8005\uff0c\u4e8b\u7adf\u6210\uff01\u5982\u679c\u4f60\u5728\u5b66\u4e60<span style=\"color: #FF6600;, Helvetica, Arial, sans-serif;font-size: 14px;background-color: #FFFFFF\">GOLANG<\/span>\uff0c\u90a3\u4e48\u672c\u6587<span style=\"color: #FF6600;, Helvetica, Arial, sans-serif;font-size: 14px;background-color: #FFFFFF\">\u300a\u4e8c\u7ef4\u6570\u7ec4\u5982\u4f55\u8f6c\u5316\u4e3a\u76ee\u5f55\u6811\u7ed3\u6784\uff1f\u300b<\/span>\uff0c\u5c31\u5f88\u9002\u5408\u4f60\uff01\u6587\u7ae0\u8bb2\u89e3\u7684\u77e5\u8bc6\u70b9\u4e3b\u8981\u5305\u62ec<span style=\"color: #FF6600;, Helvetica, Arial, sans-serif;font-size: 14px;background-color: #FFFFFF\"><\/span>\uff0c\u82e5\u662f\u4f60\u5bf9\u672c\u6587\u611f\u5174\u8da3\uff0c\u6216\u8005\u662f\u60f3\u641e\u61c2\u5176\u4e2d\u67d0\u4e2a\u77e5\u8bc6\u70b9\uff0c\u5c31\u8bf7\u4f60\u7ee7\u7eed\u5f80\u4e0b\u770b\u5427~<\/span><\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.17golang.com\/uploads\/20241107\/1730944653672c1e8db6477.jpg\" class=\"aligncenter\"><\/p>\n<p><strong>\u4e8c\u7ef4\u6570\u7ec4\u8f6c\u76ee\u5f55\u7ed3\u6784\u7b97\u6cd5<\/strong><\/p>\n<p>\u8981\u521b\u5efa\u4e00\u4e2a\u7c7b\u4f3c rdm \u7684\u76ee\u5f55\u6811\uff0c\u9700\u8981\u5c06\u7ed9\u5b9a\u7684\u4e8c\u7ef4\u6570\u7ec4\u8f6c\u6362\u4e3a\u4e00\u4e2a\u5c42\u6b21\u7ed3\u6784\u3002\u4ee5\u4e0b\u7b97\u6cd5\u53ef\u4ee5\u9ad8\u6548\u5730\u6267\u884c\u6b64\u64cd\u4f5c\uff1a<\/p>\n<ol>\n<li>\u521b\u5efa\u4e00\u4e2a\u7a7a\u6620\u5c04\uff0c\u8fd9\u5c06\u662f\u6811\u7684\u6839\u8282\u70b9\u3002<\/li>\n<li>\n<p>\u5bf9\u4e8e\u6570\u7ec4\u4e2d\u7684\u6bcf\u4e2a\u503c\uff1a<\/p>\n<ul>\n<li>\u5c06\u8be5\u503c\u62c6\u5206\u4e3a\u5e26\u6709\u5192\u53f7 &#8220;:&#8221; \u5206\u9694\u7b26\u7684\u5bc6\u94a5\u3002<\/li>\n<li>\u4ece\u6839\u8282\u70b9\u5f00\u59cb\uff0c\u8ddf\u968f\u5bc6\u94a5\u904d\u5386\u6811\u3002<\/li>\n<li>\n<p>\u5bf9\u4e8e\u9047\u5230\u7684\u6bcf\u4e2a\u5bc6\u94a5\uff08\u9664\u6700\u540e\u4e00\u4e2a\uff09\uff1a<\/p>\n<ul>\n<li>\u5982\u679c\u5b58\u5728\u5b50\u8282\u70b9\uff0c\u5219\u5c06\u5b50\u8282\u70b9\u6620\u5c04\u4e3a\u5f53\u524d\u8282\u70b9\u3002<\/li>\n<li>\u5982\u679c\u5b50\u8282\u70b9\u4e0d\u5b58\u5728\uff0c\u5219\u521b\u5efa\u4e00\u4e2a\u5e26\u6709\u7a7a\u5b50\u8282\u70b9\u6620\u5c04\u7684\u65b0\u8282\u70b9\u3002<\/li>\n<\/ul>\n<\/li>\n<li>\u5c06\u6700\u540e\u4e00\u4e2a\u952e\u4f5c\u4e3a\u53f6\u5b50\u8282\u70b9\u6dfb\u52a0\u5230\u5f53\u524d\u8282\u70b9\u7684\u5b50\u8282\u70b9\u6620\u5c04\u4e2d\u3002<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n<p>\u4ee5\u4e0b go \u4ee3\u7801\u5b9e\u73b0\u4e86\u6b64\u7b97\u6cd5\uff1a<\/p>\n<pre>package main\n\nimport (\n    \"encoding\/json\"\n    \"strings\"\n)\n\nvar values = []string{\n    \"answer:aa:bb\",\n    \"answer:aa:cc\",\n    \"question:book1\",\n    \"question:book1:answer\",\n    \"question:book1:answer:name1\",\n    \"question:book1:answer:name2\",\n    \"timeout_1\",\n    \"timeout_2\",\n}\n\ntype Node struct {\n    Name  string\n    Value string\n    Child map[string]Node\n}\n\nfunc main() {\n    root := make(map[string]Node)\n\n    for _, value := range values {\n        t := root\n        \/\/ \u6839\u636e : \u62c6\u5206\u5b57\u7b26\u4e32\n        keys := strings.Split(value, \":\")\n        l := len(keys)\n        for i := 0; i &lt; l-1; i++ {\n            k := keys[i]\n            if tm, has := t[k]; has {\n                \/\/ \u590d\u7528\u5e76\u8fdb\u5165\u4e0b\u4e00\u5c42\u8282\u70b9\n                t = tm.Child\n            } else {\n                \/\/ \u65b0\u5efa\u5e76\u8fdb\u5165\u4e0b\u4e00\u5c42\u8282\u70b9\n                t[k] = Node{\n                    Name:  k,\n                    Child: map[string]Node{},\n                }\n                t = t[k].Child\n            }\n        }\n        \/\/ \u4e3a\u6700\u540e\u4e00\u4e2a key \u65f6 \u5355\u72ec\u5904\u7406\u6210\u53f6\u5b50\u8282\u70b9\n        t[value] = Node{\n            Name:  keys[l-1],\n            Value: value,\n            Child: nil,\n        }\n    }\n    r, _ := json.Marshal(root)\n    println(string(r))\n}<\/pre>\n<p>\u6587\u4e2d\u5173\u4e8e\u7684\u77e5\u8bc6\u4ecb\u7ecd\uff0c\u5e0c\u671b\u5bf9\u4f60\u7684\u5b66\u4e60\u6709\u6240\u5e2e\u52a9\uff01\u82e5\u662f\u53d7\u76ca\u532a\u6d45\uff0c\u90a3\u5c31\u52a8\u52a8\u9f20\u6807\u6536\u85cf\u8fd9\u7bc7\u300a\u4e8c\u7ef4\u6570\u7ec4\u5982\u4f55\u8f6c\u5316\u4e3a\u76ee\u5f55\u6811\u7ed3\u6784\uff1f\u300b\u6587\u7ae0\u5427\uff0c\u4e5f\u53ef\u5173\u6ce8GOLANG\u516c\u4f17\u53f7\u4e86\u89e3\u76f8\u5173\u6280\u672f\u6587\u7ae0\u3002<\/p>\n<dl>\n<dt>\n <\/dt>\n<dd>\n   \u4f7f\u7528 Gradio \u548c Hugging Face \u5728 Lines \u4e0b\u4f7f\u7528 Python \u4ee3\u7801\u6784\u5efa\u6587\u672c\u63d0\u53d6\u5668\u5e94\u7528\u7a0b\u5e8f\n <\/dd>\n<\/dl>\n<dl>\n<dt>\n <\/dt>\n<dd>\n   \u5728 Linux \u4e2d\u8fd0\u884c Java \u4ee3\u7801\u65f6\u9047\u5230\u201c\u627e\u4e0d\u5230\u4e3b\u7c7b\u201d\u95ee\u9898\uff0c\u5982\u4f55\u89e3\u51b3\uff1f\n <\/dd>\n<\/dl>\n","protected":false},"excerpt":{"rendered":"<p>\u6709\u5fd7\u8005\uff0c\u4e8b\u7adf\u6210\uff01\u5982\u679c\u4f60\u5728\u5b66\u4e60GO&#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-206241","post","type-post","status-publish","format-standard","hentry","category-4925"],"_links":{"self":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/206241","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=206241"}],"version-history":[{"count":0,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/206241\/revisions"}],"wp:attachment":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/media?parent=206241"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/categories?post=206241"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/tags?post=206241"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}