{"id":1516,"date":"2020-09-19T06:30:46","date_gmt":"2020-09-18T22:30:46","guid":{"rendered":"https:\/\/www.develop-note.com\/blog\/?p=1516"},"modified":"2022-02-16T21:59:32","modified_gmt":"2022-02-16T13:59:32","slug":"go-variable-2021ironman","status":"publish","type":"post","link":"https:\/\/www.develop-note.com\/blog\/2020\/09\/19\/go-variable-2021ironman\/","title":{"rendered":"Iris \u9019\u500b\u5728 go \u8a9e\u8a00\u4e0a\u5730\u8868\u6700\u5feb\u7684\u7db2\u9801\u6846\u67b6- go \u7684\u8b8a\u6578"},"content":{"rendered":"<h1>go \u7684\u8b8a\u6578<\/h1>\n<p>\u5728\u4ecb\u7d39\u5b8c go \u7684\u57fa\u672c\u5167\u5bb9\u5f8c\u9019\u4e00\u7bc7\u8981\u958b\u59cb\u9032\u5165\u5e38\u5e38\u6703\u7528\u5230\u7684\u8a9e\u6cd5\uff0cgo \u8b8a\u6578\u7684\u985e\u5225\u3001\u5ba3\u544a\u3001\u521d\u59cb\u5316\u4ee5\u53ca\u8ce6\u503c\uff0c\u9084\u6709\u8207\u8b8a\u6578\u76f8\u95dc\u7684\u8a9e\u6cd5\u4f8b\u5982\u8f49\u578b\u3001\u5e38\u6578\u8b8a\u6578\u3002<\/p>\n<p><!--more--><\/p>\n<h2>\u8b8a\u6578\u7684\u985e\u5225<\/h2>\n<p>\u5728\u4ecb\u7d39\u8b8a\u6578\u7684\u8a9e\u6cd5\u4e4b\u524d\u8981\u5148\u8ddf\u5927\u5bb6\u5206\u4eab\u4e00\u4e0b\u8b8a\u6578\u985e\u578b\uff0c\u63a5\u4e0b\u4f86\u7b46\u8005\u4f9d\u64da\u8b8a\u6578\u7684\u5927\u985e\u4f86\u8ddf\u5927\u5bb6\u5206\u4eab\u8b8a\u6578\u7684\u985e\u578b<\/p>\n<h3>\u6574\u6578<\/h3>\n<p>\u9019\u90e8\u5206\u5148\u8ddf\u5927\u5bb6\u5206\u4eab\u6574\u6578\u7684\u985e\u578b<\/p>\n<pre><code class=\"language-go\">int  int8  int16  int32  int64\nuint uint8 uint16 uint32 uint64 uintptr\n\nbyte \/\/ alias for uint8\n\nrune \/\/ alias for int32\n     \/\/ represents a Unicode code point\n<\/code><\/pre>\n<p>\u4e0a\u9762\u7f85\u5217\u4e00\u4e9b\u6574\u6578\u578b\u614b\uff0c\u5e38\u7528\u7684\u61c9\u8a72\u662f<code><code>int<\/code>`<code>\u3001<\/code>`<code>uint<\/code>`<code>\u3001<\/code>`<code>byte<\/code>`<code>\u4e4b\u985e\u7684\u4e0d\u904e [Go tour] \u5efa\u8b70\u5982\u679c\u6c92\u6709\u7279\u6b8a\u7528\u9014\u4e0d\u8981\u4f7f\u7528\u975e<\/code>`<code>int<\/code><\/code><\/p>\n<h3>\u6d6e\u9ede\u6578<\/h3>\n<p>\u9019\u90e8\u5206\u6cdb\u6307\u6709\u5c0f\u6578\u9ede\u7684\u985e\u5225\uff0c\u5167\u5bb9\u5982\u4e0b<\/p>\n<pre><code class=\"language-go\">float32 float64\n\ncomplex64 complex128<\/code><\/pre>\n<p>\u5176\u4e2d\u5169\u500b\u5dee\u5225\u662f<code><code>complex64<\/code>`<code>\u7684\u7cbe\u5ea6\u6bd4<\/code>`<code>float32<\/code><\/code>\u9ad8<\/p>\n<h3>\u5ba3\u544a\u8207\u521d\u59cb\u5316<\/h3>\n<p>\u5728\u8a8d\u8b58\u8b8a\u6578\u7684\u985e\u578b\u5f8c\u63a5\u4e0b\u4f86\u8ddf\u5927\u5bb6\u5206\u4eab\u4e00\u4e0b\u5982\u4f55\u5ba3\u544a\u8b8a\u6578\uff0c\u8acb\u770b\u4e0b\u5217\u4f8b\u5b50\u3002<\/p>\n<pre><code class=\"language-go\">package main\n\nimport &quot;fmt&quot;\n\nvar i, j int = 1, 2\n\nfunc main() {\n    var c, python, java = true, false, &quot;no!&quot;\n    fmt.Println(i, j, c, python, java)\n}<\/code><\/pre>\n<p>\u5728\u9019\u908a\u7684\u8b8a\u6578<code><code>i<\/code>`<code>\u53ca<\/code>`<code>j<\/code><\/code>\u662f\u5b9a\u7fa9\u5728\u5168\u57df\u7684\u6307\u5b9a\u70ba\u6574\u6578\u7684\u8b8a\u6578\uff0c\u4e26\u4e14\u5206\u5225\u8ce6\u4e881\u82072\u7684\u503c\u3002<br \/>\n\u800c<code><code>c<\/code>`<code>\u8207<\/code>`<code>python<\/code>`<code>\u8ddf<\/code>`<code>java<\/code><\/code>\u5247\u662f\u5340\u57df\u8b8a\u6578\u6703\u7d93\u904e\u8ce6\u4e88true\u4ee5\u53cafalse\u7684\u5e03\u6797\u503c\u8ddfno!\u7684\u5b57\u4e32<\/p>\n<h3>\u8b8a\u6578\u8f49\u578b<\/h3>\n<p>\u4ecb\u7d39\u5b8c\u8b8a\u6578\u5ba3\u544a\u8207\u8ce6\u503c\u5f8c\u8981\u4ecb\u7d39\u7d66\u5927\u5bb6\u662f\u5982\u4f55\u5c07\u4e0d\u540c\u578b\u5225\u7684\u8cc7\u6599\u653e\u5230\u8b8a\u6578\u4e4b\u4e2d\uff0c\u56e0\u70ba go \u662f\u5f37\u578b\u5225\u7684\u8a9e\u8a00\u6240\u4ee5\u5f88\u6709\u6a5f\u6703\u9047\u5230\u9019\u554f\u984c\uff0c\u6240\u4ee5\u8acb\u5927\u5bb6\u770b\u770b\u4e0b\u9762\u4f8b\u5b50\u3002<\/p>\n<pre><code class=\"language-go\">package main\n\nimport (\n    &quot;fmt&quot;\n    &quot;math&quot;\n)\n\nfunc main() {\n    var x, y int = 3, 4\n    var f float64 = math.Sqrt(float64(x*x + y*y))\n    var z uint = uint(f)\n    fmt.Println(x, y, z)\n}<\/code><\/pre>\n<p>\u7c21\u55ae\u8aaa\u660e\u5c31\u662f\u628a\u578b\u5225\u7684\u540d\u7a31\u7576\u6210\u65b9\u6cd5\u4f86\u4f7f\u7528\u5c31\u53ef\u4ee5\u5c07\u8a72\u8b8a\u6578\u8f49\u63db\u6210\u53e6\u4e00\u7a2e\u578b\u5225\u3002<\/p>\n<h3>\u5e38\u6578\u8b8a\u6578<\/h3>\n<p>\u6700\u5f8c\u4ecb\u7d39\u4e00\u4e0b\u5e38\u6578\u8b8a\u6578\uff0c\u9019\u901a\u5e38\u7528\u5728\u4e0d\u60f3\u7559\u4e0b\u9b54\u8853\u6578\u5b57\u7684\u6642\u5019\u4f7f\u7528\uff0c\u8acb\u5927\u5bb6\u770b\u770b\u4e0b\u5217\u4f8b\u5b50\u3002<\/p>\n<pre><code class=\"language-go\">package main\n\nimport &quot;fmt&quot;\n\nconst Pi = 3.14\n\nfunc main() {\n    const World = &quot;\u4e16\u754c&quot;\n    fmt.Println(&quot;Hello&quot;, World)\n    fmt.Println(&quot;Happy&quot;, Pi, &quot;Day&quot;)\n\n    const Truth = true\n    fmt.Println(&quot;Go rules?&quot;, Truth)\n}<\/code><\/pre>\n<p>\u4e0a\u9762\u7684Pi\u662f\u5168\u57df\u7684\u5e38\u6578\u8b8a\u6578\u800cWorld\u4ee5\u53caTruth\u5247\u662f\u5340\u57df\u7684\u5e38\u6578\u8b8a\u6578<\/p>\n<h2>\u7d50\u8ad6<\/h2>\n<p>\u9019\u7bc7\u6587\u7ae0\u8ddf\u5927\u5bb6\u5206\u4eab\u4e00\u4e0b\u8b8a\u6578\u7684\u76f8\u95dc\u77e5\u8b58\uff0c\u4f8b\u5982\u8b8a\u6578\u7684\u578b\u614b\u3001\u5ba3\u544a\u53ca\u8ce6\u503c\u7b49\u7b49\u7684\u8a9e\u6cd5\uff0c\u63a5\u4e0b\u4f86\u6703\u66f4\u9032\u4e00\u6b65\u8ddf\u5927\u5bb6\u5206\u4eab\u4e00\u4e0b\u5bb9\u5668\u578b\u7684\u985e\u5225\uff0c\u5982<code><code>list<\/code>`<code>\u53ca<\/code>`<code>map<\/code><\/code>\u7b49\u7b49\u7684\u8b8a\u6578\u3002\u9084\u6709\u4e0a\u9762\u6709\u4e9b\u7bc4\u4f8b\u4f86\u81ea\u65bc <a href=\"https:\/\/tour.golang.org\/\" title=\"Go tour\" rel=\"nofollow noopener\" target=\"_blank\">Go tour<\/a> \u6709\u8208\u8da3\u7684\u8b80\u8005\u53ef\u4ee5\u4e0a\u53bb\u7df4\u7fd2\u4e00\u4e0b\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>go \u7684\u8b8a\u6578 \u5728\u4ecb\u7d39\u5b8c go \u7684\u57fa\u672c\u5167\u5bb9\u5f8c\u9019\u4e00\u7bc7\u8981\u958b\u59cb\u9032\u5165\u5e38\u5e38\u6703\u7528\u5230\u7684\u8a9e\u6cd5\uff0cgo \u8b8a\u6578\u7684\u985e\u5225\u3001\u5ba3\u544a\u3001\u521d\u59cb\u5316\u4ee5\u53ca &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/www.develop-note.com\/blog\/2020\/09\/19\/go-variable-2021ironman\/\" class=\"more-link\">\u95b1\u8b80\u5168\u6587<span class=\"screen-reader-text\">\u3008Iris \u9019\u500b\u5728 go \u8a9e\u8a00\u4e0a\u5730\u8868\u6700\u5feb\u7684\u7db2\u9801\u6846\u67b6- go \u7684\u8b8a\u6578\u3009<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"inline_featured_image":false,"_exactmetrics_skip_tracking":false,"_exactmetrics_sitenote_active":false,"_exactmetrics_sitenote_note":"","_exactmetrics_sitenote_category":0,"footnotes":""},"categories":[2],"tags":[158,81],"class_list":["post-1516","post","type-post","status-publish","format-standard","hentry","category-develop","tag-2020ironman","tag-go"],"_links":{"self":[{"href":"https:\/\/www.develop-note.com\/blog\/wp-json\/wp\/v2\/posts\/1516","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.develop-note.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.develop-note.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.develop-note.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.develop-note.com\/blog\/wp-json\/wp\/v2\/comments?post=1516"}],"version-history":[{"count":16,"href":"https:\/\/www.develop-note.com\/blog\/wp-json\/wp\/v2\/posts\/1516\/revisions"}],"predecessor-version":[{"id":2687,"href":"https:\/\/www.develop-note.com\/blog\/wp-json\/wp\/v2\/posts\/1516\/revisions\/2687"}],"wp:attachment":[{"href":"https:\/\/www.develop-note.com\/blog\/wp-json\/wp\/v2\/media?parent=1516"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.develop-note.com\/blog\/wp-json\/wp\/v2\/categories?post=1516"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.develop-note.com\/blog\/wp-json\/wp\/v2\/tags?post=1516"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}