{"id":1255,"date":"2022-12-06T09:27:17","date_gmt":"2022-12-06T01:27:17","guid":{"rendered":"https:\/\/fdream.net\/blog\/?p=1255"},"modified":"2023-02-23T10:30:02","modified_gmt":"2023-02-23T02:30:02","slug":"%e7%94%a8chatgpt%e5%86%99%e4%ba%86%e6%ae%b5%e6%97%a0%e6%b3%95%e9%80%9a%e8%bf%87%e7%bc%96%e8%af%91%e7%9a%84go%e4%bb%a3%e7%a0%81","status":"publish","type":"post","link":"https:\/\/fdream.net\/blog\/article\/1255","title":{"rendered":"\u7528ChatGPT\u5199\u4e86\u6bb5\u65e0\u6cd5\u901a\u8fc7\u7f16\u8bd1\u7684Go\u4ee3\u7801"},"content":{"rendered":"\n<p>\u8fd9\u51e0\u5929<a rel=\"noreferrer noopener\" href=\"https:\/\/openai.com\/blog\/chatgpt\/\" target=\"_blank\">ChatGPT<\/a>\u7a81\u7136\u4e4b\u95f4\u706b\u5f97\u4e00\u584c\u7cca\u6d82\u3002\u8fd9\u4e2aAI\u80fd\u591f\u5199\u5c0f\u8bf4\u3001\u5267\u672c\u3001\u6563\u6587\uff0c\u56de\u7b54\u5404\u79cd\u95ee\u9898\uff0c\u5f53\u7136\u5b83\u80af\u5b9a\u4e5f\u80fd\u5199\u4ee3\u7801\uff0c\u8fd8\u80fd\u626e\u6f14Linux\u865a\u62df\u673a\u6765\u6267\u884c\u5404\u79cd\u547d\u4ee4\u3001\u7f16\u8bd1\u4ee3\u7801\u3002\u7531\u4e8e\u5b83\u8fc7\u4e8e\u5f3a\u5927\uff0c\u6709\u4eba\u7528\u5b83\u6765\u56de\u7b54stackoverflow\u4e0a\u7684\u5404\u79cd\u95ee\u9898\uff0c\u5bfc\u81f4\u5b98\u65b9\u91c7\u53d6<a rel=\"noreferrer noopener\" href=\"https:\/\/meta.stackoverflow.com\/questions\/421831\/temporary-policy-chatgpt-is-banned\" target=\"_blank\">\u4e34\u65f6\u63aa\u65bd<\/a>\uff0c\u628a\u8fd9\u4e2aAI\u7ed9\u7981\u6b62\u4e86\u3002\u4e0d\u5f97\u4e0d\u8bf4\uff0c\u5b83\u56de\u7b54\u8fd9\u4e9b\u95ee\u9898\u6bd4google\u8981\u597d\u7528\u591a\u4e86\u3002<\/p>\n\n\n\n<p>\u6211\u4e5f\u6298\u817e\u4e86\u4e00\u4e2a\u8d26\u53f7\uff0c\u4e0a\u53bb\u8bd5\u4e86\u8bd5\u3002\u4f5c\u4e3a\u7a0b\u5e8f\u5458\uff0c\u6211\u8ba9ChatGPT\u7528Go\u5199\u4e86\u6bb5\u5feb\u901f\u6392\u5e8f\u7684\u4ee3\u7801\uff0c\u603b\u4f53\u770b\u8d77\u6765\u8fd8\u662f\u5f88\u4e0d\u9519\u7684\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>func quickSort(arr &#91;]int) &#91;]int {\n  \/\/ base case: if the length of the array is 0 or 1, it is already sorted\n  if len(arr) &lt; 2 {\n    return arr\n  }\n\n  \/\/ choose the pivot element as the middle element of the array\n  pivot := arr&#91;len(arr) \/ 2]\n\n  \/\/ create two empty slices for the elements that are less than and greater than the pivot\n  less := &#91;]int{}\n  greater := &#91;]int{}\n\n  \/\/ partition the other elements into the two slices\n  for i := range arr {\n    if i != len(arr) \/ 2 {\n      if arr&#91;i] &lt; pivot {\n        less = append(less, arr&#91;i])\n      } else {\n        greater = append(greater, arr&#91;i])\n      }\n    }\n  }\n\n  \/\/ sort the two slices recursively and concatenate them with the pivot in between\n  return append(quickSort(less), pivot, quickSort(greater)...)\n}<\/code><\/pre>\n\n\n\n<p>\u7136\u800c\u9057\u61be\u7684\u662f\uff0c\u6700\u540e\u4e00\u884c\u4ee3\u7801\u5e76\u4e0d\u80fd\u901a\u8fc7\u7f16\u8bd1\u3002\u8fd9\u4e2a\u4e09\u4e2a\u70b9\u7684\u7701\u7565\u53f7\u7528\u6cd5\u4f3c\u4e4e\u5728\u7406\u89e3\u4e0a\u6709\u4e00\u4e9b\u95ee\u9898\uff0c\u6211\u4e5f\u770b\u5230\u6709\u4e00\u4e9b\u8bf4\u6cd5\u662f\u8fd9\u4e2a\u8bed\u6cd5\u7cd6\u662f\u628a\u6570\u7ec4\u6253\u6563\u6210\u5355\u4e2a\u5143\u7d20\u4f5c\u4e3a\u53c2\u6570\u4f20\u5165\uff0c\u5176\u5b9e\u8fd9\u4e2a\u7406\u89e3\u662f\u4e0d\u6b63\u786e\u7684\u3002\u5728G<a href=\"https:\/\/go.dev\/ref\/spec#Passing_arguments_to_..._parameters\" target=\"_blank\" rel=\"noreferrer noopener\">o\u5b98\u65b9\u6587\u6863<\/a>\u4e2d\u662f\u8fd9\u6837\u5199\u7684\uff1a<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p>If&nbsp;<code>f<\/code>&nbsp;is&nbsp;<a href=\"https:\/\/go.dev\/ref\/spec#Function_types\">variadic<\/a>&nbsp;with a final parameter&nbsp;<code>p<\/code>&nbsp;of type&nbsp;<code>...T<\/code>, then within&nbsp;<code>f<\/code>&nbsp;the type of&nbsp;<code>p<\/code>&nbsp;is equivalent to type&nbsp;<code>[]T<\/code>. If&nbsp;<code>f<\/code>&nbsp;is invoked with no actual arguments for&nbsp;<code>p<\/code>, the value passed to&nbsp;<code>p<\/code>&nbsp;is&nbsp;<code>nil<\/code>. Otherwise, the value passed is a new slice of type&nbsp;<code>[]T<\/code>&nbsp;with a new underlying array whose successive elements are the actual arguments, which all must be&nbsp;<a href=\"https:\/\/go.dev\/ref\/spec#Assignability\">assignable<\/a>&nbsp;to&nbsp;<code>T<\/code>. The length and capacity of the slice is therefore the number of arguments bound to&nbsp;<code>p<\/code>&nbsp;and may differ for each call site.<\/p>\n<\/blockquote>\n\n\n\n<p><code>...T<\/code>\u662f\u4f1a\u88ab\u5f53\u505a<code>[]T<\/code>\u6765\u5904\u7406\u7684\uff0c\u56e0\u6b64\u5728<code>append<\/code>\u8fd9\u4e2a\u51fd\u6570\u4e2d\uff0c\u8981\u4e48\u4f20\u5165\u591a\u4e2a<code>T<\/code>\uff0c\u8981\u4e48\u4f20\u5165\u4e00\u4e2a<code>[]T<\/code>\uff0c\u800c\u4e0d\u80fd\u4e24\u8005\u6df7\u7528\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u8fd9\u51e0\u5929ChatGPT\u7a81\u7136\u4e4b\u95f4\u706b\u5f97\u4e00\u584c\u7cca\u6d82\u3002\u8fd9\u4e2aAI\u80fd\u591f\u5199\u5c0f\u8bf4\u3001\u5267\u672c\u3001\u6563\u6587\uff0c\u56de\u7b54\u5404\u79cd\u95ee\u9898\uff0c\u5f53\u7136\u5b83\u80af\u5b9a\u4e5f\u80fd\u5199\u4ee3\u7801\uff0c\u8fd8\u80fd\u626e\u6f14Linux\u865a\u62df\u673a\u6765\u6267\u884c\u5404\u79cd\u547d\u4ee4\u3001\u7f16\u8bd1\u4ee3\u7801\u3002\u7531\u4e8e\u5b83\u8fc7\u4e8e\u5f3a\u5927\uff0c\u6709\u4eba\u7528\u5b83\u6765\u56de\u7b54stackoverflow\u4e0a\u7684\u5404\u79cd\u95ee\u9898\uff0c\u5bfc\u81f4\u5b98\u65b9\u91c7\u53d6\u4e34\u65f6\u63aa\u65bd\uff0c\u628a\u8fd9\u4e2aAI\u7ed9\u7981\u6b62\u4e86\u3002\u4e0d\u5f97\u4e0d\u8bf4\uff0c\u5b83\u56de\u7b54\u8fd9\u4e9b\u95ee\u9898\u6bd4google\u8981\u597d\u7528\u591a\u4e86\u3002 \u6211\u4e5f\u6298\u817e\u4e86\u4e00\u4e2a\u8d26\u53f7\uff0c\u4e0a\u53bb\u8bd5\u4e86\u8bd5\u3002\u4f5c\u4e3a\u7a0b\u5e8f\u5458\uff0c\u6211\u8ba9ChatGPT\u7528Go\u5199\u4e86\u6bb5\u5feb\u901f\u6392\u5e8f\u7684\u4ee3\u7801\uff0c\u603b\u4f53\u770b\u8d77\u6765\u8fd8\u662f\u5f88\u4e0d\u9519\u7684\uff1a \u7136\u800c\u9057\u61be\u7684\u662f\uff0c\u6700\u540e\u4e00\u884c\u4ee3\u7801\u5e76\u4e0d\u80fd\u901a\u8fc7\u7f16\u8bd1\u3002\u8fd9\u4e2a\u4e09\u4e2a\u70b9\u7684\u7701\u7565\u53f7\u7528\u6cd5\u4f3c\u4e4e\u5728\u7406\u89e3\u4e0a\u6709\u4e00\u4e9b\u95ee\u9898\uff0c\u6211\u4e5f\u770b\u5230\u6709\u4e00\u4e9b\u8bf4\u6cd5\u662f\u8fd9\u4e2a\u8bed\u6cd5\u7cd6\u662f\u628a\u6570\u7ec4\u6253\u6563\u6210\u5355\u4e2a\u5143\u7d20\u4f5c\u4e3a\u53c2\u6570\u4f20\u5165\uff0c\u5176\u5b9e\u8fd9\u4e2a\u7406\u89e3\u662f\u4e0d\u6b63\u786e\u7684\u3002\u5728Go\u5b98\u65b9\u6587\u6863\u4e2d\u662f\u8fd9\u6837\u5199\u7684\uff1a If&nbsp;f&nbsp;is&nbsp;variadic&nbsp;with a final parameter&nbsp;p&nbsp;of type&nbsp;&#8230;T, then within&nbsp;f&nbsp;the type of&nbsp;p&nbsp;is equivalent to type&nbsp;[]T. If&nbsp;f&nbsp;is invoked with no actual arguments for&nbsp;p, the value passed to&nbsp;p&nbsp;is&nbsp;nil. Otherwise, the value passed is a new slice of type&nbsp;[]T&nbsp;with a new underlying array whose successive elements are the actual arguments, which all must be&nbsp;assignable&nbsp;to&nbsp;T. The length and capacity &hellip; <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1,5],"tags":[375,380,374],"class_list":["post-1255","post","type-post","status-publish","format-standard","hentry","category-coding","category-tech","tag-ai","tag-chatgpt","tag-go"],"views":1088,"_links":{"self":[{"href":"https:\/\/fdream.net\/blog\/wp-json\/wp\/v2\/posts\/1255","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fdream.net\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fdream.net\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fdream.net\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fdream.net\/blog\/wp-json\/wp\/v2\/comments?post=1255"}],"version-history":[{"count":0,"href":"https:\/\/fdream.net\/blog\/wp-json\/wp\/v2\/posts\/1255\/revisions"}],"wp:attachment":[{"href":"https:\/\/fdream.net\/blog\/wp-json\/wp\/v2\/media?parent=1255"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fdream.net\/blog\/wp-json\/wp\/v2\/categories?post=1255"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fdream.net\/blog\/wp-json\/wp\/v2\/tags?post=1255"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}