{"id":207438,"date":"2025-07-08T12:41:23","date_gmt":"2025-07-08T04:41:23","guid":{"rendered":"https:\/\/server.hk\/cnblog\/207438\/"},"modified":"2025-07-08T12:41:23","modified_gmt":"2025-07-08T04:41:23","slug":"%e4%bd%bf%e7%94%a8-envoy-%e4%bb%a3%e7%90%86%e9%aa%8c%e8%af%81%e5%99%a8%e5%92%8c-gogo-protobuf-%e8%bf%9b%e8%a1%8c%e9%aa%8c%e8%af%81","status":"publish","type":"post","link":"https:\/\/server.hk\/cnblog\/207438\/","title":{"rendered":"\u4f7f\u7528 envoy \u4ee3\u7406\u9a8c\u8bc1\u5668\u548c gogo protobuf \u8fdb\u884c\u9a8c\u8bc1"},"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>\u4f7f\u7528 envoy \u4ee3\u7406\u9a8c\u8bc1\u5668\u548c gogo protobuf \u8fdb\u884c\u9a8c\u8bc1<\/span><\/p>\n<p><span>\u6765\u6e90\uff1astackoverflow<\/span><br \/>\n<span>2024-04-22 16:51: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>\u4e00\u5206\u8015\u8018\uff0c\u4e00\u5206\u6536\u83b7\uff01\u65e2\u7136\u90fd\u6253\u5f00\u8fd9\u7bc7<span style=\"color: #FF6600;, Helvetica, Arial, sans-serif;font-size: 14px;background-color: #FFFFFF\">\u300a\u4f7f\u7528 envoy \u4ee3\u7406\u9a8c\u8bc1\u5668\u548c gogo protobuf \u8fdb\u884c\u9a8c\u8bc1\u300b<\/span>\uff0c\u5c31\u575a\u6301\u770b\u4e0b\u53bb\uff0c\u5b66\u4e0b\u53bb\u5427\uff01\u672c\u6587\u4e3b\u8981\u4f1a\u7ed9\u5927\u5bb6\u8bb2\u5230<span style=\"color: #FF6600;, Helvetica, Arial, sans-serif;font-size: 14px;background-color: #FFFFFF\"><\/span>\u7b49\u7b49\u77e5\u8bc6\u70b9\uff0c\u5982\u679c\u5927\u5bb6\u5bf9\u672c\u6587\u6709\u597d\u7684\u5efa\u8bae\u6216\u8005\u770b\u5230\u6709\u4e0d\u8db3\u4e4b\u5904\uff0c\u975e\u5e38\u6b22\u8fce\u5927\u5bb6\u79ef\u6781\u63d0\u51fa\uff01\u5728\u540e\u7eed\u6587\u7ae0\u6211\u4f1a\u7ee7\u7eed\u66f4\u65b0<span style=\"color: #FF6600;, Helvetica, Arial, sans-serif;font-size: 14px;background-color: #FFFFFF\">Golang<\/span>\u76f8\u5173\u7684\u5185\u5bb9\uff0c\u5e0c\u671b\u5bf9\u5927\u5bb6\u90fd\u6709\u6240\u5e2e\u52a9\uff01<\/p>\n<p> \u95ee\u9898\u5185\u5bb9<br \/>\n <\/p>\n<p>\u6211\u6b63\u5728\u5c1d\u8bd5\u7f16\u5199\u63d2\u4ef6\u6765\u751f\u6210\u9a8c\u8bc1 go \u6587\u4ef6\u3002\u5b83\u4f7f\u7528 https:\/\/github.com\/mwitkow\/go-proto-validators \u548c envoy \u4ee3\u7406\u9a8c\u8bc1\u5668 https:\/\/github.com\/envoyproxy\/protoc-gen-validate\u3002\u4e0b\u9762\u662f\u6211\u7684\u547d\u4ee4<\/p>\n<pre>protoc  \\\n--proto_path=${gopath}\/src \\\n--proto_path=${gopath}\/pkg\/mod\/github.com\/gogo\/[email&nbsp;protected] \\\n--proto_path=${gopath}\/pkg\/mod\/github.com\/envoyproxy\/[email&nbsp;protected]\n--proto_path=. \\\n--gogo_out=. \\\n\u2014-validate_out=\u201clang=go:.\\\u201d\n--govalidators_out=gogoimport=true:. \\\nproto\/*.proto<\/pre>\n<p>\u5f53\u6211\u8fd0\u884c\u4e0a\u9762\u7684\u547d\u4ee4\u65f6\uff0c\u6211\u6536\u5230\u4ee5\u4e0b\u9519\u8bef\uff1f\u6709\u5173\u5982\u4f55\u89e3\u51b3\u6b64\u95ee\u9898\u7684\u4efb\u4f55\u5efa\u8bae\u4e13\u5bb6\u3002\u611f\u8c22\u60a8\u7684\u5e2e\u52a9\u3002<\/p>\n<pre>zsh: command not found: --proto_path=.\nzsh: command not found: --govalidators_out=gogoimport=true:.<\/pre>\n<p>\u6dfb\u52a0\u7f3a\u5c11\u7684\u201c\/\u201d\u540e<\/p>\n<pre>protoc  \\\n--proto_path=${GOPATH}\/src \\\n--proto_path=${GOPATH}\/pkg\/mod\/github.com\/gogo\/[email&nbsp;protected] \\\n--proto_path=${GOPATH}\/pkg\/mod\/github.com\/envoyproxy\/[email&nbsp;protected] \\\n--proto_path=. \\\n--gogo_out=. \\\n-\u2014go_out=\":.\/generated\" \\\n\u2014-validate_out=\"lang=go:.\/generated\" \\\n--govalidators_out=gogoimport=true:. \\\nproto\/test.proto<\/pre>\n<p>\u6211\u6536\u5230<strong>\u672a\u77e5\u6807\u5fd7\uff1a-\uff1f<\/strong><\/p>\n<p> <\/p>\n<h2>\u6b63\u786e\u7b54\u6848<\/h2>\n<p> <\/p>\n<p>\u60a8\u5728 get-validate \u4e4b\u540e\u9519\u8fc7\u4e86 <code>\\<\/code>&#8230;<\/p>\n<pre>protoc  \\\n--proto_path=${GOPATH}\/src \\\n--proto_path=${GOPATH}\/pkg\/mod\/github.com\/gogo\/ \\\n--proto_path=${GOPATH}\/pkg\/mod\/github.com\/envoyproxy\/ \\\n--proto_path=. \\\n--gogo_out=. \\\n\u2014-validate_out=\"lang=go:.\" \\\n--govalidators_out=gogoimport=true:. \\\nproto\/*.proto\n<\/pre>\n<p>\u597d\u4e86\uff0c\u672c\u6587\u5230\u6b64\u7ed3\u675f\uff0c\u5e26\u5927\u5bb6\u4e86\u89e3\u4e86\u300a\u4f7f\u7528 envoy \u4ee3\u7406\u9a8c\u8bc1\u5668\u548c gogo protobuf \u8fdb\u884c\u9a8c\u8bc1\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-207438","post","type-post","status-publish","format-standard","hentry","category-4925"],"_links":{"self":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/207438","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=207438"}],"version-history":[{"count":0,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/207438\/revisions"}],"wp:attachment":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/media?parent=207438"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/categories?post=207438"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/tags?post=207438"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}