{"id":855,"date":"2024-11-07T08:48:53","date_gmt":"2024-11-07T00:48:53","guid":{"rendered":"https:\/\/fwq.ai\/blog\/855\/"},"modified":"2024-11-07T08:48:53","modified_gmt":"2024-11-07T00:48:53","slug":"go-%e5%a6%82%e4%bd%95%e5%ae%9e%e7%8e%b0%e4%b8%8e-java-%e5%ad%97%e7%ac%a6%e4%b8%b2%e5%8e%8b%e7%bc%a9%e4%b8%80%e8%87%b4%e7%9a%84%e7%bb%93%e6%9e%9c%ef%bc%9f","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/855\/","title":{"rendered":"Go \u5982\u4f55\u5b9e\u73b0\u4e0e Java \u5b57\u7b26\u4e32\u538b\u7f29\u4e00\u81f4\u7684\u7ed3\u679c\uff1f"},"content":{"rendered":"<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-1056\" src=\"https:\/\/fwq.ai\/blog\/wp-content\/uploads\/2024\/11\/173010060386682.jpg\" width=\"800\" height=\"320\" srcset=\"https:\/\/fwq.ai\/blog\/wp-content\/uploads\/2024\/11\/173010060386682.jpg 800w, https:\/\/fwq.ai\/blog\/wp-content\/uploads\/2024\/11\/173010060386682-300x120.jpg 300w, https:\/\/fwq.ai\/blog\/wp-content\/uploads\/2024\/11\/173010060386682-768x307.jpg 768w, https:\/\/fwq.ai\/blog\/wp-content\/uploads\/2024\/11\/173010060386682-670x268.jpg 670w\" sizes=\"auto, (max-width: 800px) 100vw, 800px\" title=\"Go \u5982\u4f55\u5b9e\u73b0\u4e0e Java \u5b57\u7b26\u4e32\u538b\u7f29\u4e00\u81f4\u7684\u7ed3\u679c\uff1f\u63d2\u56fe\" alt=\"Go \u5982\u4f55\u5b9e\u73b0\u4e0e Java \u5b57\u7b26\u4e32\u538b\u7f29\u4e00\u81f4\u7684\u7ed3\u679c\uff1f\u63d2\u56fe\" \/><\/p>\n<p><strong>go \u4e2d\u5b9e\u73b0 java \u5b57\u7b26\u4e32\u538b\u7f29<\/strong><\/p>\n<p>\u5728 java \u4e2d\uff0c\u53ef\u4ee5\u4f7f\u7528 java.util.zip.deflater \u7c7b\u6765\u538b\u7f29\u5b57\u7b26\u4e32\u3002\u800c\u5728 go \u4e2d\uff0c\u867d\u7136\u63d0\u4f9b\u4e86 compress\/gzip \u5e93\uff0c\u4f46\u5b83\u4e0d\u4f1a\u8f93\u51fa\u4e0e java \u4e00\u81f4\u7684\u538b\u7f29\u7ed3\u679c\u3002<\/p>\n<p>\u4e3a\u4e86\u5b9e\u73b0\u4e0e java \u76f8\u540c\u7684\u538b\u7f29\u884c\u4e3a\uff0c\u53ef\u4ee5\u4f7f\u7528\u7b2c\u4e09\u65b9\u5e93\uff0c\u4f8b\u5982\uff1a<\/p>\n<ul>\n<li> <strong>github.com\/ayancy\/sdc<\/strong>\uff1a\u8be5\u5e93\u63d0\u4f9b\u4e86 deflater \u548c inflater \u7684\u7eaf go \u5b9e\u73b0\uff0c\u53ef\u4ee5\u4e0e java \u4e2d\u7684\u5bf9\u5e94\u5b9e\u73b0\u4e00\u81f4\u3002<\/li>\n<\/ul>\n<p>\u5b89\u88c5 sdc \u5e93\uff1a<\/p>\n<p><span>\u7acb\u5373\u5b66\u4e60<\/span>\u201cJava\u514d\u8d39\u5b66\u4e60\u7b14\u8bb0\uff08\u6df1\u5165\uff09\u201d\uff1b<\/p>\n<p><span>\u70b9\u51fb\u4e0b\u8f7d<\/span>\u201c\u55e8\u683c\u5f0f\u538b\u7f29\u5927\u5e08\u201d\uff1b<\/p>\n<pre>go get github.com\/ayancy\/sdc<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u4f7f\u7528 sdc \u538b\u7f29\u5b57\u7b26\u4e32\uff1a<\/p>\n<pre>package main\n\nimport (\n    \"compress\/sdc\"\n    \"fmt\"\n    \"strings\"\n)\n\nfunc main() {\n    str := \"this is a test string\"\n\n    \/\/ \u521b\u5efa Deflater \u5bf9\u8c61\n    deflater, err := sdc.NewDeflater(sdc.DefaultCompression)\n    if err != nil {\n        fmt.Println(err)\n        return\n    }\n    defer deflater.Close()\n\n    \/\/ \u538b\u7f29\u5b57\u7b26\u4e32\n    compressed, err := deflater.DeflateString(str)\n    if err != nil {\n        fmt.Println(err)\n        return\n    }\n\n    \/\/ \u8f93\u51fa\u538b\u7f29\u540e\u7684\u5b57\u7b26\u4e32\n    fmt.Println(strings.Join(compressed, \" \"))\n}<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u4ee5\u4e0a\u5c31\u662fGo \u5982\u4f55\u5b9e\u73b0\u4e0e Java \u5b57\u7b26\u4e32\u538b\u7f29\u4e00\u81f4\u7684\u7ed3\u679c\uff1f\u7684\u8be6\u7ec6\u5185\u5bb9\uff0c\u66f4\u591a\u8bf7\u5173\u6ce8\u7c73\u4e91\u5176\u5b83\u76f8\u5173\u6587\u7ae0\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>go \u4e2d\u5b9e\u73b0 java \u5b57\u7b26\u4e32\u538b\u7f29 \u5728 java \u4e2d\uff0c\u53ef\u4ee5\u4f7f\u7528 java.util.zip.deflater \u7c7b\u6765\u538b\u7f29\u5b57\u7b26\u4e32\u3002\u800c\u5728 go \u4e2d\uff0c\u867d\u7136\u63d0\u4f9b\u4e86 compress\/gzip \u5e93\uff0c\u4f46\u5b83\u4e0d\u4f1a\u8f93\u51fa\u4e0e java \u4e00\u81f4\u7684\u538b\u7f29\u7ed3\u679c\u3002 \u4e3a\u4e86\u5b9e\u73b0\u4e0e java \u76f8\u540c\u7684\u538b\u7f29\u884c\u4e3a\uff0c\u53ef\u4ee5\u4f7f\u7528\u7b2c\u4e09\u65b9\u5e93\uff0c\u4f8b\u5982\uff1a github.com\/ayancy\/sdc\uff1a\u8be5\u5e93\u63d0\u4f9b\u4e86 deflater \u548c inflater \u7684\u7eaf go \u5b9e\u73b0\uff0c\u53ef\u4ee5\u4e0e java \u4e2d\u7684\u5bf9\u5e94\u5b9e\u73b0\u4e00\u81f4\u3002 \u5b89\u88c5 sdc \u5e93\uff1a \u7acb\u5373\u5b66\u4e60\u201cJava\u514d\u8d39\u5b66\u4e60\u7b14\u8bb0\uff08\u6df1\u5165\uff09\u201d\uff1b \u70b9\u51fb\u4e0b\u8f7d\u201c\u55e8\u683c\u5f0f\u538b\u7f29\u5927\u5e08\u201d\uff1b go get github.com\/ayancy\/sdc \u767b\u5f55\u540e\u590d\u5236 \u4f7f\u7528 sdc \u538b\u7f29\u5b57\u7b26\u4e32\uff1a package main import ( &#8220;compress\/sdc&#8221; &#8220;fmt&#8221; &#8220;strings&#8221; ) func main() { str := &#8220;this is a [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[16],"tags":[],"class_list":["post-855","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/855","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/comments?post=855"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/855\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=855"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=855"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=855"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}