{"id":206468,"date":"2025-06-12T10:54:22","date_gmt":"2025-06-12T02:54:22","guid":{"rendered":"https:\/\/server.hk\/cnblog\/206468\/"},"modified":"2025-06-12T10:54:22","modified_gmt":"2025-06-12T02:54:22","slug":"%e5%a6%82%e4%bd%95%e5%88%a9%e7%94%a8%e4%ba%8c%e7%bb%b4%e6%95%b0%e7%bb%84%e6%9e%84%e5%bb%ba%e7%b1%bb%e4%bc%bc-rdm-%e7%9a%84%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\/206468\/","title":{"rendered":"\u5982\u4f55\u5229\u7528\u4e8c\u7ef4\u6570\u7ec4\u6784\u5efa\u7c7b\u4f3c RDM \u7684\u76ee\u5f55\u6811\u7ed3\u6784\uff1f"},"content":{"rendered":"<p><span style=\"font-size: 15px\">\u5b66\u4e60\u77e5\u8bc6\u8981\u5584\u4e8e\u601d\u8003\uff0c\u601d\u8003\uff0c\u518d\u601d\u8003\uff01\u4eca\u5929GOLANG\u5c0f\u7f16\u5c31\u7ed9\u5927\u5bb6\u5e26\u6765<span style=\"color: #FF6600;, Helvetica, Arial, sans-serif;font-size: 14px;background-color: #FFFFFF\">\u300a\u5982\u4f55\u5229\u7528\u4e8c\u7ef4\u6570\u7ec4\u6784\u5efa\u7c7b\u4f3c RDM \u7684\u76ee\u5f55\u6811\u7ed3\u6784\uff1f\u300b<\/span>\uff0c\u4ee5\u4e0b\u5185\u5bb9\u4e3b\u8981\u5305\u542b<span style=\"color: #FF6600;, Helvetica, Arial, sans-serif;font-size: 14px;background-color: #FFFFFF\"><\/span>\u7b49\u77e5\u8bc6\u70b9\uff0c\u5982\u679c\u4f60\u6b63\u5728\u5b66\u4e60\u6216\u51c6\u5907\u5b66\u4e60<span style=\"color: #FF6600;, Helvetica, Arial, sans-serif;font-size: 14px;background-color: #FFFFFF\">GOLANG<\/span>\uff0c\u5c31\u90fd\u4e0d\u8981\u9519\u8fc7\u672c\u6587\u5566~\u8ba9\u6211\u4eec\u4e00\u8d77\u6765\u770b\u770b\u5427\uff0c\u80fd\u5e2e\u52a9\u5230\u4f60\u5c31\u66f4\u597d\u4e86\uff01<\/span>,<br \/>\n<img decoding=\"async\" src=\"https:\/\/www.17golang.com\/uploads\/20241112\/17314041886733219c0e86a.jpg\" class=\"aligncenter\">,<br \/>\n<strong>\u4e8c\u7ef4\u6570\u7ec4\u8f6c\u76ee\u5f55\u7ed3\u6784\u7b97\u6cd5<\/strong>,\u8981\u5b9e\u73b0\u7c7b\u4f3c rdm \u7684\u76ee\u5f55\u6811\u7ed3\u6784\uff0c\u4e00\u4e2a\u9ad8\u6548\u7684\u65b9\u6cd5\u662f\u904d\u5386\u8f93\u5165\u7684\u952e\u503c\u6570\u7ec4\uff0c\u5e76\u6839\u636e\u5192\u53f7\u5206\u9694\u7684\u952e\u6765\u6dfb\u52a0\u8282\u70b9\u3002\u7b97\u6cd5\u5982\u4e0b\uff1a,\u521b\u5efa\u4e00\u4e2a\u6839\u8282\u70b9\uff0c\u521d\u59cb\u5316\u4e3a\u7a7a\u6620\u5c04\u3002<br \/>\n<br \/>\u904d\u5386\u952e\u503c\u6570\u7ec4\u3002<br \/>\n<br \/>\u5bf9\u4e8e\u6bcf\u4e2a\u952e\u503c\u5bf9\uff1a,\u5c06\u7ed3\u679c\u6620\u5c04\u5e8f\u5217\u5316\u4e3a json \u5b57\u7b26\u4e32\u3002,\u4ee5\u4e0b\u662f\u8be5\u7b97\u6cd5\u7684 go \u8bed\u8a00\u5b9e\u73b0\uff1a,\u7ec8\u4e8e\u4ecb\u7ecd\u5b8c\u5566\uff01\u5c0f\u4f19\u4f34\u4eec\uff0c\u8fd9\u7bc7\u5173\u4e8e\u300a\u5982\u4f55\u5229\u7528\u4e8c\u7ef4\u6570\u7ec4\u6784\u5efa\u7c7b\u4f3c RDM \u7684\u76ee\u5f55\u6811\u7ed3\u6784\uff1f\u300b\u7684\u4ecb\u7ecd\u5e94\u8be5\u8ba9\u4f60\u6536\u83b7\u591a\u591a\u4e86\u5427\uff01\u6b22\u8fce\u5927\u5bb6\u6536\u85cf\u6216\u5206\u4eab\u7ed9\u66f4\u591a\u9700\u8981\u5b66\u4e60\u7684\u670b\u53cb\u5427~GOLANG\u516c\u4f17\u53f7\u4e5f\u4f1a\u53d1\u5e03GOLANG\u76f8\u5173\u77e5\u8bc6\uff0c\u5feb\u6765\u5173\u6ce8\u5427\uff01,\u4e8c\u7ef4\u6570\u7ec4\u8f6c\u76ee\u5f55\u7ed3\u6784\u7b97\u6cd5,<br \/>\n<span style=\"font-size: 15px\">\u5b66\u4e60\u77e5\u8bc6\u8981\u5584\u4e8e\u601d\u8003\uff0c\u601d\u8003\uff0c\u518d\u601d\u8003\uff01\u4eca\u5929GOLANG\u5c0f\u7f16\u5c31\u7ed9\u5927\u5bb6\u5e26\u6765<span style=\"color: #FF6600;, Helvetica, Arial, sans-serif;font-size: 14px;background-color: #FFFFFF\">\u300a\u5982\u4f55\u5229\u7528\u4e8c\u7ef4\u6570\u7ec4\u6784\u5efa\u7c7b\u4f3c RDM \u7684\u76ee\u5f55\u6811\u7ed3\u6784\uff1f\u300b<\/span>\uff0c\u4ee5\u4e0b\u5185\u5bb9\u4e3b\u8981\u5305\u542b<span style=\"color: #FF6600;, Helvetica, Arial, sans-serif;font-size: 14px;background-color: #FFFFFF\"><\/span>\u7b49\u77e5\u8bc6\u70b9\uff0c\u5982\u679c\u4f60\u6b63\u5728\u5b66\u4e60\u6216\u51c6\u5907\u5b66\u4e60<span style=\"color: #FF6600;, Helvetica, Arial, sans-serif;font-size: 14px;background-color: #FFFFFF\">GOLANG<\/span>\uff0c\u5c31\u90fd\u4e0d\u8981\u9519\u8fc7\u672c\u6587\u5566~\u8ba9\u6211\u4eec\u4e00\u8d77\u6765\u770b\u770b\u5427\uff0c\u80fd\u5e2e\u52a9\u5230\u4f60\u5c31\u66f4\u597d\u4e86\uff01<\/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>\u5982\u4f55\u5229\u7528\u4e8c\u7ef4\u6570\u7ec4\u6784\u5efa\u7c7b\u4f3c RDM \u7684\u76ee\u5f55\u6811\u7ed3\u6784\uff1f<\/span><\/p>\n<h1>\u5982\u4f55\u5229\u7528\u4e8c\u7ef4\u6570\u7ec4\u6784\u5efa\u7c7b\u4f3c RDM \u7684\u76ee\u5f55\u6811\u7ed3\u6784\uff1f<\/h1>\n<p><span>2024-11-12 17:36:43<\/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\">\u5b66\u4e60\u77e5\u8bc6\u8981\u5584\u4e8e\u601d\u8003\uff0c\u601d\u8003\uff0c\u518d\u601d\u8003\uff01\u4eca\u5929GOLANG\u5c0f\u7f16\u5c31\u7ed9\u5927\u5bb6\u5e26\u6765<span style=\"color: #FF6600;, Helvetica, Arial, sans-serif;font-size: 14px;background-color: #FFFFFF\">\u300a\u5982\u4f55\u5229\u7528\u4e8c\u7ef4\u6570\u7ec4\u6784\u5efa\u7c7b\u4f3c RDM \u7684\u76ee\u5f55\u6811\u7ed3\u6784\uff1f\u300b<\/span>\uff0c\u4ee5\u4e0b\u5185\u5bb9\u4e3b\u8981\u5305\u542b<span style=\"color: #FF6600;, Helvetica, Arial, sans-serif;font-size: 14px;background-color: #FFFFFF\"><\/span>\u7b49\u77e5\u8bc6\u70b9\uff0c\u5982\u679c\u4f60\u6b63\u5728\u5b66\u4e60\u6216\u51c6\u5907\u5b66\u4e60<span style=\"color: #FF6600;, Helvetica, Arial, sans-serif;font-size: 14px;background-color: #FFFFFF\">GOLANG<\/span>\uff0c\u5c31\u90fd\u4e0d\u8981\u9519\u8fc7\u672c\u6587\u5566~\u8ba9\u6211\u4eec\u4e00\u8d77\u6765\u770b\u770b\u5427\uff0c\u80fd\u5e2e\u52a9\u5230\u4f60\u5c31\u66f4\u597d\u4e86\uff01<\/span><\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.17golang.com\/uploads\/20241112\/17314041886733219c0e86a.jpg\" class=\"aligncenter\"><\/p>\n<p><strong>\u4e8c\u7ef4\u6570\u7ec4\u8f6c\u76ee\u5f55\u7ed3\u6784\u7b97\u6cd5<\/strong><\/p>\n<p>\u8981\u5b9e\u73b0\u7c7b\u4f3c rdm \u7684\u76ee\u5f55\u6811\u7ed3\u6784\uff0c\u4e00\u4e2a\u9ad8\u6548\u7684\u65b9\u6cd5\u662f\u904d\u5386\u8f93\u5165\u7684\u952e\u503c\u6570\u7ec4\uff0c\u5e76\u6839\u636e\u5192\u53f7\u5206\u9694\u7684\u952e\u6765\u6dfb\u52a0\u8282\u70b9\u3002\u7b97\u6cd5\u5982\u4e0b\uff1a<\/p>\n<p>\u521b\u5efa\u4e00\u4e2a\u6839\u8282\u70b9\uff0c\u521d\u59cb\u5316\u4e3a\u7a7a\u6620\u5c04\u3002<br \/>\u904d\u5386\u952e\u503c\u6570\u7ec4\u3002<br \/>\u5bf9\u4e8e\u6bcf\u4e2a\u952e\u503c\u5bf9\uff1a<\/p>\n<pre>\u4ece\u6839\u8282\u70b9\u5f00\u59cb\u6784\u5efa\u8def\u5f84\u3002\n\u5bf9\u4e8e\u8def\u5f84\u4e2d\u6bcf\u4e2a\u952e\uff1a\n    \u5982\u679c\u5b58\u5728\u5bf9\u5e94\u5b50\u8282\u70b9\uff0c\u5219\u8fdb\u5165\u8be5\u5b50\u8282\u70b9\u3002\n    \u5426\u5219\uff0c\u521b\u5efa\u8be5\u5b50\u8282\u70b9\u5e76\u5c06\u5176\u6dfb\u52a0\u5230\u5f53\u524d\u8282\u70b9\u3002\n\u5c06\u952e\u503c\u5bf9\u4f5c\u4e3a\u53f6\u5b50\u8282\u70b9\u6dfb\u52a0\u5230\u5f53\u524d\u8282\u70b9\u3002<\/pre>\n<p>\u5c06\u7ed3\u679c\u6620\u5c04\u5e8f\u5217\u5316\u4e3a json \u5b57\u7b26\u4e32\u3002<\/p>\n<p>\u4ee5\u4e0b\u662f\u8be5\u7b97\u6cd5\u7684 go \u8bed\u8a00\u5b9e\u73b0\uff1a<\/p>\n<pre>package main\n\nimport (\n    \"encoding\/json\"\n    \"strings\"\n)\n\n\/\/ \u8981\u8f6c\u6362\u7684\u952e\u503c\u6570\u7ec4\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\n\/\/ \u5b9a\u4e49\u4e00\u4e2a\u8282\u70b9\u7ed3\u6784\uff0c\u5305\u542b\u540d\u79f0\u3001\u503c\u548c\u5b50\u8282\u70b9\u3002\ntype Node struct {\n    Name  string\n    Value string\n    Child map[string]Node\n}\n\nfunc main() {\n    \/\/ \u521b\u5efa\u6839\u8282\u70b9\u3002\n    root := make(map[string]Node)\n\n    \/\/ \u904d\u5386\u952e\u503c\u6570\u7ec4\u3002\n    for _, value := range values {\n        \/\/ \u5c06\u5b57\u7b26\u4e32\u6309\u5192\u53f7\u5206\u9694\u3002\n        keys := strings.Split(value, \":\")\n        \/\/ \u83b7\u53d6\u6570\u7ec4\u957f\u5ea6\u3002\n        l := len(keys)\n        \/\/ \u4ece\u6839\u8282\u70b9\u5f00\u59cb\u6784\u5efa\u8def\u5f84\u3002\n        t := root\n        \/\/ \u904d\u5386\u9664\u6700\u540e\u4e00\u4e2a\u5916\u7684\u6240\u6709\u952e\u3002\n        for i := 0; i &lt; l-1; i++ {\n            k := keys[i]\n            \/\/ \u68c0\u67e5\u662f\u5426\u5b58\u5728\u5b50\u8282\u70b9\u3002\n            if tm, has := t[k]; has {\n                \/\/ \u590d\u7528\u5e76\u8fdb\u5165\u4e0b\u4e00\u5c42\u8282\u70b9\u3002\n                t = tm.Child\n            } else {\n                \/\/ \u65b0\u5efa\u5e76\u8fdb\u5165\u4e0b\u4e00\u5c42\u8282\u70b9\u3002\n                t[k] = Node{\n                    Name:  k,\n                    Child: map[string]Node{},\n                }\n                t = t[k].Child\n            }\n        }\n        \/\/ \u5c06\u6700\u540e\u4e00\u4e2a\u952e\u4f5c\u4e3a\u53f6\u5b50\u8282\u70b9\u6dfb\u52a0\u5230\u5f53\u524d\u8282\u70b9\u3002\n        t[value] = Node{\n            Name:  keys[l-1],\n            Value: value,\n            Child: nil,\n        }\n    }\n\n    \/\/ \u5c06\u7ed3\u679c\u6620\u5c04\u5e8f\u5217\u5316\u4e3a JSON \u5b57\u7b26\u4e32\u3002\n    r, _ := json.Marshal(root)\n    println(string(r))\n}<\/pre>\n<p>\u7ec8\u4e8e\u4ecb\u7ecd\u5b8c\u5566\uff01\u5c0f\u4f19\u4f34\u4eec\uff0c\u8fd9\u7bc7\u5173\u4e8e\u300a\u5982\u4f55\u5229\u7528\u4e8c\u7ef4\u6570\u7ec4\u6784\u5efa\u7c7b\u4f3c RDM \u7684\u76ee\u5f55\u6811\u7ed3\u6784\uff1f\u300b\u7684\u4ecb\u7ecd\u5e94\u8be5\u8ba9\u4f60\u6536\u83b7\u591a\u591a\u4e86\u5427\uff01\u6b22\u8fce\u5927\u5bb6\u6536\u85cf\u6216\u5206\u4eab\u7ed9\u66f4\u591a\u9700\u8981\u5b66\u4e60\u7684\u670b\u53cb\u5427~GOLANG\u516c\u4f17\u53f7\u4e5f\u4f1a\u53d1\u5e03GOLANG\u76f8\u5173\u77e5\u8bc6\uff0c\u5feb\u6765\u5173\u6ce8\u5427\uff01<\/p>\n<dl>\n<dt>\n <\/dt>\n<dd>\n   \u5982\u4f55\u5c06Jetty\u670d\u52a1\u5668\u96c6\u6210\u5230Eclipse\uff1f\n <\/dd>\n<\/dl>\n<dl>\n<dt>\n <\/dt>\n<dd>\n   \u5982\u4f55\u4ece HTML \u6807\u7b7e\u4e2d\u53bb\u9664\u6240\u6709\u5c5e\u6027\uff1f\n <\/dd>\n<\/dl>\n","protected":false},"excerpt":{"rendered":"<p>\u5b66\u4e60\u77e5\u8bc6\u8981\u5584\u4e8e\u601d\u8003\uff0c\u601d\u8003\uff0c\u518d\u601d\u8003&#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-206468","post","type-post","status-publish","format-standard","hentry","category-4925"],"_links":{"self":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/206468","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=206468"}],"version-history":[{"count":0,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/206468\/revisions"}],"wp:attachment":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/media?parent=206468"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/categories?post=206468"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/tags?post=206468"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}