[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"site-config":3,"primary-menu":6,"cat-golang":85,"catposts-golang":97,"post-detail-post-golang-goto-4acea4b8":795},{"config":4,"socialLinks":5},null,[],{"metadata":7,"spec":10,"menuItems":20},{"name":8,"creationTimestamp":9},"primary","2026-09-12T06:13:55.024154Z",{"displayName":11,"menuItems":12},"主菜单",[13,14,15,16,17,18,19],"88c3f10b-321c-4092-86a8-70db00251b74","menu-item-izrtmxer","c4c814d1-0c2c-456b-8c96-4864965fee94","menu-item-column","menu-item-tools","menu-item-zsxq","menu-item-ocrxlczu",[21,30,40,49,58,67,76],{"displayName":22,"metadata":23,"spec":25,"status":28,"children":29},"首页",{"name":13,"creationTimestamp":24},"2026-09-12T06:13:54.422830Z",{"displayName":22,"href":26,"priority":27,"menuName":8},"\u002F",0,{"displayName":22,"href":26},[],{"displayName":31,"metadata":32,"spec":34,"status":38,"children":39},"Java面试八股",{"name":14,"creationTimestamp":33},"2026-09-13T09:42:02.854891Z",{"displayName":31,"href":35,"target":36,"priority":37,"menuName":8},"\u002Fjava-interview","_self",1,{"displayName":31,"href":35},[],{"displayName":41,"metadata":42,"spec":44,"status":47,"children":48},"文章",{"name":15,"creationTimestamp":43},"2026-09-12T06:13:54.457307Z",{"displayName":41,"href":45,"priority":46,"menuName":8},"\u002Farchives",2,{"displayName":41,"href":45},[],{"displayName":50,"metadata":51,"spec":53,"status":56,"children":57},"项目实战",{"name":16,"creationTimestamp":52},"2026-09-14T00:35:08.138170Z",{"displayName":50,"href":54,"target":36,"priority":55,"menuName":8},"\u002Fcolumn",3,{"displayName":50,"href":54},[],{"displayName":59,"metadata":60,"spec":62,"status":65,"children":66},"在线工具",{"name":17,"creationTimestamp":61},"2026-09-14T00:35:08.171474Z",{"displayName":59,"href":63,"target":36,"priority":64,"menuName":8},"\u002Ftools",4,{"displayName":59,"href":63},[],{"displayName":68,"metadata":69,"spec":71,"status":74,"children":75},"知识星球",{"name":18,"creationTimestamp":70},"2026-09-14T00:35:08.199145Z",{"displayName":68,"href":72,"target":36,"priority":73,"menuName":8},"\u002Fzsxq",5,{"displayName":68,"href":72},[],{"displayName":77,"metadata":78,"spec":80,"status":83,"children":84},"特价云服务器",{"name":19,"creationTimestamp":79},"2026-09-25T15:30:59.201614Z",{"displayName":77,"href":81,"target":36,"priority":82,"menuName":8},"\u002Fserver",6,{"displayName":77,"href":81},[],{"metadata":86,"spec":89,"status":94,"postCount":96},{"name":87,"creationTimestamp":88},"golang","2026-09-12T08:21:58.713526Z",{"displayName":90,"slug":87,"cover":91,"description":92,"priority":27,"hideFromList":93,"preventParentPostCascadeQuery":93},"Go 语言教程","\u002Fupload\u002Ftutorial-cover-golang.png","Go 语言零基础到进阶教程：基础语法、接口与错误处理、GMP 并发模型与工程实践。",false,{"permalink":95,"postCount":96,"visiblePostCount":96},"\u002Fcategories\u002Fgolang",33,[98,122,143,164,185,206,227,248,269,290,311,332,353,374,395,416,437,458,479,500,521,542,563,584,605,626,647,668,689,710,731,752,773],{"metadata":99,"spec":102,"status":113,"categories":117},{"name":100,"creationTimestamp":101},"post-windows-install-golang-a21d2168","2026-09-12T08:29:06.344429Z",{"title":103,"slug":104,"cover":105,"excerpt":106,"publishTime":108,"categories":109,"tags":110,"priority":27,"pinned":93,"deleted":93,"visible":111,"allowComment":112},"Windows系统安装Go语言环境（图文教程）","windows-install-golang","\u002Fupload\u002Fcover-49509db4b9ba.png",{"raw":107,"autoGenerate":93},"本小节，我将演示如何在 Windows 系统上安装 Go 语言环境。一、下载 Windows 系统 Go 安装包，首先到官网下载 Windows 系统 Go 安装包，详细请参考前面小节内容Go下载，下载完成后，双击安装包开始安装，最后检查 Windows 系统 Go 环境是否安装成功。","2026-09-12T08:29:06.414277Z",[87],[],"PUBLIC",true,{"permalink":114,"excerpt":107,"lastModifyTime":115,"phase":116},"\u002Farchives\u002Fwindows-install-golang","2026-09-14T00:21:01.224634Z","PUBLISHED",[118],{"metadata":119,"spec":120,"status":121,"postCount":96},{"name":87,"creationTimestamp":88},{"displayName":90,"slug":87,"cover":91,"description":92,"priority":27,"hideFromList":93,"preventParentPostCascadeQuery":93},{"permalink":95,"postCount":96,"visiblePostCount":96},{"metadata":123,"spec":126,"status":135,"categories":138},{"name":124,"creationTimestamp":125},"post-macos-install-golang-7efe4d18","2026-09-12T08:29:05.611780Z",{"title":127,"slug":128,"cover":129,"excerpt":130,"publishTime":132,"categories":133,"tags":134,"priority":27,"pinned":93,"deleted":93,"visible":111,"allowComment":112},"Mac系统安装Go语言环境（图文教程）","macos-install-golang","\u002Fupload\u002F164870453722926.png",{"raw":131,"autoGenerate":93},"这一小节，我将手摸手教大家如何在 Mac 系统上安装 Go 语言环境。Mac 系统有下面两种安装方式。一、通过 brew 安装 二、官网下载 Go 语言 pkg 包来安装，两种方式均通过图文来给大家讲解，良心教程。\r\n","2026-09-12T08:29:05.685842Z",[87],[],{"permalink":136,"excerpt":131,"lastModifyTime":137,"phase":116},"\u002Farchives\u002Fmacos-install-golang","2026-09-14T00:21:01.518464Z",[139],{"metadata":140,"spec":141,"status":142,"postCount":96},{"name":87,"creationTimestamp":88},{"displayName":90,"slug":87,"cover":91,"description":92,"priority":27,"hideFromList":93,"preventParentPostCascadeQuery":93},{"permalink":95,"postCount":96,"visiblePostCount":96},{"metadata":144,"spec":147,"status":156,"categories":159},{"name":145,"creationTimestamp":146},"post-linux-install-golang-ff2cabb0","2026-09-12T08:29:04.983033Z",{"title":148,"slug":149,"cover":150,"excerpt":151,"publishTime":153,"categories":154,"tags":155,"priority":27,"pinned":93,"deleted":93,"visible":111,"allowComment":112},"Linux系统安装Go语言环境（图文教程）","linux-install-golang","\u002Fupload\u002Fcover-cd7d36020297.png",{"raw":152,"autoGenerate":93},"本小节，我将演示如何在 Linux 系统上安装 Go 语言环境。这里，我以自己购买的云服务器 CentOS 7 做演示。首先到官网下载 Linux 系统 Go 安装包，下载完成后，将压缩包上传到指定目录下，执行如下命令，将压缩包解压到 \u002Fusr\u002Flocal\u002Fgo 下...","2026-09-12T08:29:05.039772Z",[87],[],{"permalink":157,"excerpt":152,"lastModifyTime":158,"phase":116},"\u002Farchives\u002Flinux-install-golang","2026-09-14T00:21:02.058274Z",[160],{"metadata":161,"spec":162,"status":163,"postCount":96},{"name":87,"creationTimestamp":88},{"displayName":90,"slug":87,"cover":91,"description":92,"priority":27,"hideFromList":93,"preventParentPostCascadeQuery":93},{"permalink":95,"postCount":96,"visiblePostCount":96},{"metadata":165,"spec":168,"status":177,"categories":180},{"name":166,"creationTimestamp":167},"post-install-jetbrains-golang-4b354194","2026-09-12T08:29:04.389267Z",{"title":169,"slug":170,"cover":171,"excerpt":172,"publishTime":174,"categories":175,"tags":176,"priority":27,"pinned":93,"deleted":93,"visible":111,"allowComment":112},"Jetbrains GoLang 安装&amp;开发环境搭建","install-jetbrains-golang","\u002Fupload\u002F164870486582118.png",{"raw":173,"autoGenerate":93},"Jetbrains GoLang 是一款面向 Go 语言，旨在为 Go 开发提供符合人体工程学的开发工具。它提供 Go 语言的编辑、调试、编译、管理、重构等丰富的功能。本小节，我们将学习安装搭建集成开发环境Jetbrains GoLang, 并通过它来开发一个简单的 HelloWorld 程序！","2026-09-12T08:29:04.440937Z",[87],[],{"permalink":178,"excerpt":173,"lastModifyTime":179,"phase":116},"\u002Farchives\u002Finstall-jetbrains-golang","2026-09-13T05:17:54.053255Z",[181],{"metadata":182,"spec":183,"status":184,"postCount":96},{"name":87,"creationTimestamp":88},{"displayName":90,"slug":87,"cover":91,"description":92,"priority":27,"hideFromList":93,"preventParentPostCascadeQuery":93},{"permalink":95,"postCount":96,"visiblePostCount":96},{"metadata":186,"spec":189,"status":198,"categories":201},{"name":187,"creationTimestamp":188},"post-golang-variables-55d7b2af","2026-09-12T08:29:03.751627Z",{"title":190,"slug":191,"cover":192,"excerpt":193,"publishTime":195,"categories":196,"tags":197,"priority":27,"pinned":93,"deleted":93,"visible":111,"allowComment":112},"Go 语言变量声明_定义_赋值（图文讲解）","golang-variables","\u002Fupload\u002F164870897498294.png",{"raw":194,"autoGenerate":93},"编程中可以说最常见的就是变量了，主要被用来存储各种类型数据。关于变量的类型，主要有: 整型浮、点型、布尔型、结构体等。Go 语言中不同类型的变量，需要先声明，才能够被使用。","2026-09-12T08:29:03.813668Z",[87],[],{"permalink":199,"excerpt":194,"lastModifyTime":200,"phase":116},"\u002Farchives\u002Fgolang-variables","2026-09-13T05:17:54.598729Z",[202],{"metadata":203,"spec":204,"status":205,"postCount":96},{"name":87,"creationTimestamp":88},{"displayName":90,"slug":87,"cover":91,"description":92,"priority":27,"hideFromList":93,"preventParentPostCascadeQuery":93},{"permalink":95,"postCount":96,"visiblePostCount":96},{"metadata":207,"spec":210,"status":219,"categories":222},{"name":208,"creationTimestamp":209},"post-golang-switch-a10b005c","2026-09-12T08:29:03.106098Z",{"title":211,"slug":212,"cover":213,"excerpt":214,"publishTime":216,"categories":217,"tags":218,"priority":27,"pinned":93,"deleted":93,"visible":111,"allowComment":112},"Go 语言 switch 语句（分支判断）","golang-switch","\u002Fupload\u002F164871010411752.png",{"raw":215,"autoGenerate":93},"分支判断可以理解成批量的 if 语句，使用 switch 语句可以非常方便地对大量值进行条件判断。Go 语言改进了其他语言中 switch 语句的设计弊端。Go 语言中 switch 中的每一个 case 都是独立代码块，无需通过 break 语句跳出代码块，以避免执行到下一个 case 代码块 ...\r\n\r\n\r\n","2026-09-12T08:29:03.172911Z",[87],[],{"permalink":220,"excerpt":215,"lastModifyTime":221,"phase":116},"\u002Farchives\u002Fgolang-switch","2026-09-13T05:17:55.423312Z",[223],{"metadata":224,"spec":225,"status":226,"postCount":96},{"name":87,"creationTimestamp":88},{"displayName":90,"slug":87,"cover":91,"description":92,"priority":27,"hideFromList":93,"preventParentPostCascadeQuery":93},{"permalink":95,"postCount":96,"visiblePostCount":96},{"metadata":228,"spec":231,"status":240,"categories":243},{"name":229,"creationTimestamp":230},"post-golang-slice-f8bb13e6","2026-09-12T08:29:02.530409Z",{"title":232,"slug":233,"cover":234,"excerpt":235,"publishTime":237,"categories":238,"tags":239,"priority":27,"pinned":93,"deleted":93,"visible":111,"allowComment":112},"Go 语言切片（Slice）初始化_删除元素_遍历","golang-slice","\u002Fupload\u002F164870974706279.png",{"raw":236,"autoGenerate":93},"切片和数组类似，是数据集合。和数组不同的是，切片是一块动态分配大小的连续空间。它和 Java 语言中的 List 集合类似。切片的声明格式如下:var name []T name 表示切片变量名，T 表示切片类型，下面是示例代码 ...","2026-09-12T08:29:02.594243Z",[87],[],{"permalink":241,"excerpt":236,"lastModifyTime":242,"phase":116},"\u002Farchives\u002Fgolang-slice","2026-09-13T05:17:56.609115Z",[244],{"metadata":245,"spec":246,"status":247,"postCount":96},{"name":87,"creationTimestamp":88},{"displayName":90,"slug":87,"cover":91,"description":92,"priority":27,"hideFromList":93,"preventParentPostCascadeQuery":93},{"permalink":95,"postCount":96,"visiblePostCount":96},{"metadata":249,"spec":252,"status":261,"categories":264},{"name":250,"creationTimestamp":251},"post-golang-pointer-157d7d47","2026-09-12T08:29:01.780678Z",{"title":253,"slug":254,"cover":255,"excerpt":256,"publishTime":258,"categories":259,"tags":260,"priority":27,"pinned":93,"deleted":93,"visible":111,"allowComment":112},"Go 语言指针 (图文教程，超级详细)","golang-pointer","\u002Fupload\u002F164870962404380.png",{"raw":257,"autoGenerate":93},"大部分面向对象语言都很少有用到指针的场景了，但是在Go语言中有大量的指针应用场景，要想学好 Go 语言，指针是必须了解的。本小节中，就将学习 Go 语言指针相关知识点。每一个变量都会分配一块内存，数据保存在内存中，内存有一个地址，就像门牌号，通过这个地址就可以找到里面存储的数据。指针就是保存这个内存地址的变量。\r\n\r\n","2026-09-12T08:29:01.949985Z",[87],[],{"permalink":262,"excerpt":257,"lastModifyTime":263,"phase":116},"\u002Farchives\u002Fgolang-pointer","2026-09-13T05:17:58.376696Z",[265],{"metadata":266,"spec":267,"status":268,"postCount":96},{"name":87,"creationTimestamp":88},{"displayName":90,"slug":87,"cover":91,"description":92,"priority":27,"hideFromList":93,"preventParentPostCascadeQuery":93},{"permalink":95,"postCount":96,"visiblePostCount":96},{"metadata":270,"spec":273,"status":282,"categories":285},{"name":271,"creationTimestamp":272},"post-golang-map-4643324e","2026-09-12T08:29:01.129328Z",{"title":274,"slug":275,"cover":276,"excerpt":277,"publishTime":279,"categories":280,"tags":281,"priority":27,"pinned":93,"deleted":93,"visible":111,"allowComment":112},"Go 语言字典 (Map)","golang-map","\u002Fupload\u002F164870982152632.png",{"raw":278,"autoGenerate":93},"很多场景下都需要字典容器，它描述的是一种映射关系，如字典中的页码对应相关页内容一样。在 Go 语言中提供的字典容器为 map。 map 使用散列表（hash）实现。Go 语言中定义字典 map 格式如下: map [keyType]valueType ,键和键对应的值总是以一对一的形式存在 ...\r\n","2026-09-12T08:29:01.199026Z",[87],[],{"permalink":283,"excerpt":278,"lastModifyTime":284,"phase":116},"\u002Farchives\u002Fgolang-map","2026-09-13T05:17:59.383462Z",[286],{"metadata":287,"spec":288,"status":289,"postCount":96},{"name":87,"creationTimestamp":88},{"displayName":90,"slug":87,"cover":91,"description":92,"priority":27,"hideFromList":93,"preventParentPostCascadeQuery":93},{"permalink":95,"postCount":96,"visiblePostCount":96},{"metadata":291,"spec":294,"status":303,"categories":306},{"name":292,"creationTimestamp":293},"post-golang-list-bfb63978","2026-09-12T08:29:00.459682Z",{"title":295,"slug":296,"cover":297,"excerpt":298,"publishTime":300,"categories":301,"tags":302,"priority":27,"pinned":93,"deleted":93,"visible":111,"allowComment":112},"Go 语言 list (列表)_初始化_遍历_删除","golang-list","\u002Fupload\u002F164870987319337.png",{"raw":299,"autoGenerate":93},"列表 (list) 是一种非连续存储的容器，又多个节点组成，节点通过一些变量将彼此串联起来。列表（list）底层常见的数据结构有: 单链表、双链表等。在 Go 语言中，列表的实现都在 container\u002Flist 包中，内部实现原理是双链表。列表（list）能够方便高效地进行元素的删除、插入操作。\r\n","2026-09-12T08:29:00.524219Z",[87],[],{"permalink":304,"excerpt":299,"lastModifyTime":305,"phase":116},"\u002Farchives\u002Fgolang-list","2026-09-13T05:18:00.756584Z",[307],{"metadata":308,"spec":309,"status":310,"postCount":96},{"name":87,"creationTimestamp":88},{"displayName":90,"slug":87,"cover":91,"description":92,"priority":27,"hideFromList":93,"preventParentPostCascadeQuery":93},{"permalink":95,"postCount":96,"visiblePostCount":96},{"metadata":312,"spec":315,"status":324,"categories":327},{"name":313,"creationTimestamp":314},"post-golang-if-else-c59fa420","2026-09-12T08:28:59.871285Z",{"title":316,"slug":317,"cover":318,"excerpt":319,"publishTime":321,"categories":322,"tags":323,"priority":27,"pinned":93,"deleted":93,"visible":111,"allowComment":112},"Go 语言 if else (条件判断)","golang-if-else","\u002Fupload\u002F164870991767712.png",{"raw":320,"autoGenerate":93},"Go 语言中，if else 条件判断格式如下：if 表达式1 { 分支1 } else if 表达式2 { 分支2 } else { 分支3 } ，当表达式1的结果为 true 时，会执行分支1的代码；当表达式1的结果为 false 时，会执行表达式2，若结果为 true, 则会执行分支2的代码...","2026-09-12T08:28:59.929025Z",[87],[],{"permalink":325,"excerpt":320,"lastModifyTime":326,"phase":116},"\u002Farchives\u002Fgolang-if-else","2026-09-13T05:18:01.594113Z",[328],{"metadata":329,"spec":330,"status":331,"postCount":96},{"name":87,"creationTimestamp":88},{"displayName":90,"slug":87,"cover":91,"description":92,"priority":27,"hideFromList":93,"preventParentPostCascadeQuery":93},{"permalink":95,"postCount":96,"visiblePostCount":96},{"metadata":333,"spec":336,"status":345,"categories":348},{"name":334,"creationTimestamp":335},"post-golang-hello-world-cf894aff","2026-09-12T08:28:59.215647Z",{"title":337,"slug":338,"cover":339,"excerpt":340,"publishTime":342,"categories":343,"tags":344,"priority":27,"pinned":93,"deleted":93,"visible":111,"allowComment":112},"编写 Go 语言第一个程序: Hello World ！","golang-hello-world","\u002Fupload\u002F164870471270526.png",{"raw":341,"autoGenerate":93},"通常来说，入门任何一门语言，编写的第一个程序都是用该语言向世界打声招呼： Hello World ! 接下来，我们来编写第一个 Go 语言程序，新建一个 helloworld.go 文件，代码如下 ...","2026-09-12T08:28:59.273231Z",[87],[],{"permalink":346,"excerpt":341,"lastModifyTime":347,"phase":116},"\u002Farchives\u002Fgolang-hello-world","2026-09-13T05:18:02.048325Z",[349],{"metadata":350,"spec":351,"status":352,"postCount":96},{"name":87,"creationTimestamp":88},{"displayName":90,"slug":87,"cover":91,"description":92,"priority":27,"hideFromList":93,"preventParentPostCascadeQuery":93},{"permalink":95,"postCount":96,"visiblePostCount":96},{"metadata":354,"spec":357,"status":366,"categories":369},{"name":355,"creationTimestamp":356},"post-golang-goto-4acea4b8","2026-09-12T08:28:58.582637Z",{"title":358,"slug":359,"cover":360,"excerpt":361,"publishTime":363,"categories":364,"tags":365,"priority":27,"pinned":93,"deleted":93,"visible":111,"allowComment":112},"Go 语言 goto 语句（代码跳转）","golang-goto","\u002Fupload\u002F164871014638160.png",{"raw":362,"autoGenerate":93},"在 Go 语言中，goto 语句通过标签实现代码间的跳转。它通常会被使用在快速跳出循环、避免定义重复代码等 ...","2026-09-12T08:28:58.638534Z",[87],[],{"permalink":367,"excerpt":362,"lastModifyTime":368,"phase":116},"\u002Farchives\u002Fgolang-goto","2026-09-13T05:18:03.032618Z",[370],{"metadata":371,"spec":372,"status":373,"postCount":96},{"name":87,"creationTimestamp":88},{"displayName":90,"slug":87,"cover":91,"description":92,"priority":27,"hideFromList":93,"preventParentPostCascadeQuery":93},{"permalink":95,"postCount":96,"visiblePostCount":96},{"metadata":375,"spec":378,"status":387,"categories":390},{"name":376,"creationTimestamp":377},"post-golang-function-ef90cbc7","2026-09-12T08:28:57.735525Z",{"title":379,"slug":380,"cover":381,"excerpt":382,"publishTime":384,"categories":385,"tags":386,"priority":27,"pinned":93,"deleted":93,"visible":111,"allowComment":112},"Go 语言函数","golang-function","\u002Fupload\u002F164871026284043.jpg",{"raw":383,"autoGenerate":93},"在编程中，函数是指一段可以直接被另一段程序或代码引用的、可重复使用的、用来实现单一或相关联功能的代码段。目的是为了提高应用的模块性和代码的重复利用率。相比较其他语言，Go 语言在设计上对函数进行了优化和改进，使其使用起来更加便利 ...","2026-09-12T08:28:57.796658Z",[87],[],{"permalink":388,"excerpt":383,"lastModifyTime":389,"phase":116},"\u002Farchives\u002Fgolang-function","2026-09-13T05:18:03.578539Z",[391],{"metadata":392,"spec":393,"status":394,"postCount":96},{"name":87,"creationTimestamp":88},{"displayName":90,"slug":87,"cover":91,"description":92,"priority":27,"hideFromList":93,"preventParentPostCascadeQuery":93},{"permalink":95,"postCount":96,"visiblePostCount":96},{"metadata":396,"spec":399,"status":408,"categories":411},{"name":397,"creationTimestamp":398},"post-golang-function-variable-94ff5e53","2026-09-12T08:28:57.125546Z",{"title":400,"slug":401,"cover":402,"excerpt":403,"publishTime":405,"categories":406,"tags":407,"priority":27,"pinned":93,"deleted":93,"visible":111,"allowComment":112},"Go 语言函数变量（将函数保存到变量中）","golang-function-variable","\u002Fupload\u002F164871038499644.png",{"raw":404,"autoGenerate":93},"在 Go 语言中，函数也是一种类型，同样可以和其他类型（如 int 、float、string 等）一样被保存到变量中。示例代码如下 ...","2026-09-12T08:28:57.195876Z",[87],[],{"permalink":409,"excerpt":404,"lastModifyTime":410,"phase":116},"\u002Farchives\u002Fgolang-function-variable","2026-09-13T05:18:04.468273Z",[412],{"metadata":413,"spec":414,"status":415,"postCount":96},{"name":87,"creationTimestamp":88},{"displayName":90,"slug":87,"cover":91,"description":92,"priority":27,"hideFromList":93,"preventParentPostCascadeQuery":93},{"permalink":95,"postCount":96,"visiblePostCount":96},{"metadata":417,"spec":420,"status":429,"categories":432},{"name":418,"creationTimestamp":419},"post-golang-function-interface-058ccba7","2026-09-12T08:28:56.555615Z",{"title":421,"slug":422,"cover":423,"excerpt":424,"publishTime":426,"categories":427,"tags":428,"priority":27,"pinned":93,"deleted":93,"visible":111,"allowComment":112},"Go 语言函数实现接口（将函数当做接口来调用）","golang-function-interface","\u002Fupload\u002F164871047596556.png",{"raw":425,"autoGenerate":93},"在 Go 语言中，其他基本类型能够实现接口，函数同样可以实现接口。下面我们定义一个名为狗 Dog 的接口，上面这个接口需要实现 Say() 方法，调用时需传入一个 interface{} 类型的变量。这是个啥类型呢？这种类型表示你可以传入任意类型的值...","2026-09-12T08:28:56.614447Z",[87],[],{"permalink":430,"excerpt":425,"lastModifyTime":431,"phase":116},"\u002Farchives\u002Fgolang-function-interface","2026-09-13T05:18:05.479619Z",[433],{"metadata":434,"spec":435,"status":436,"postCount":96},{"name":87,"creationTimestamp":88},{"displayName":90,"slug":87,"cover":91,"description":92,"priority":27,"hideFromList":93,"preventParentPostCascadeQuery":93},{"permalink":95,"postCount":96,"visiblePostCount":96},{"metadata":438,"spec":441,"status":450,"categories":453},{"name":439,"creationTimestamp":440},"post-golang-function-define-bc188aff","2026-09-12T08:28:55.987596Z",{"title":442,"slug":443,"cover":444,"excerpt":445,"publishTime":447,"categories":448,"tags":449,"priority":27,"pinned":93,"deleted":93,"visible":111,"allowComment":112},"Go 语言函数定义_声明_调用（超详细）","golang-function-define","\u002Fupload\u002F164871033125097.png",{"raw":446,"autoGenerate":93},"在 Go 语言中，定义一个函数需要声明参数和函数名等。定义函数需要以 func 标识开头，后面紧接着函数名、参数列表、返回参数列表以及函数体，函数名的命名有以下约束：函数名由字母、数字、下划线组成; 函数名不能以数字开头; 同一包内，函数名不能重名...\r\n","2026-09-12T08:28:56.047485Z",[87],[],{"permalink":451,"excerpt":446,"lastModifyTime":452,"phase":116},"\u002Farchives\u002Fgolang-function-define","2026-09-13T05:18:06.326689Z",[454],{"metadata":455,"spec":456,"status":457,"postCount":96},{"name":87,"creationTimestamp":88},{"displayName":90,"slug":87,"cover":91,"description":92,"priority":27,"hideFromList":93,"preventParentPostCascadeQuery":93},{"permalink":95,"postCount":96,"visiblePostCount":96},{"metadata":459,"spec":462,"status":471,"categories":474},{"name":460,"creationTimestamp":461},"post-golang-for-0e1bdb22","2026-09-12T08:28:55.353775Z",{"title":463,"slug":464,"cover":465,"excerpt":466,"publishTime":468,"categories":469,"tags":470,"priority":27,"pinned":93,"deleted":93,"visible":111,"allowComment":112},"Go 语言 for（循环）","golang-for","\u002Fupload\u002F164870996521899.png",{"raw":467,"autoGenerate":93},"在 Go 语言中，循环需要使用关键字 for 来完成，格式如下:for 初始语句;条件表达式;结束语句 { 循环体代码}，for 循环会不停地进行循环，直到条件表达式返回 false 才推出循环，即执行 for 循环 &quot;}&quot; 后面的代码...","2026-09-12T08:28:55.435382Z",[87],[],{"permalink":472,"excerpt":467,"lastModifyTime":473,"phase":116},"\u002Farchives\u002Fgolang-for","2026-09-13T05:18:07.480855Z",[475],{"metadata":476,"spec":477,"status":478,"postCount":96},{"name":87,"creationTimestamp":88},{"displayName":90,"slug":87,"cover":91,"description":92,"priority":27,"hideFromList":93,"preventParentPostCascadeQuery":93},{"permalink":95,"postCount":96,"visiblePostCount":96},{"metadata":480,"spec":483,"status":492,"categories":495},{"name":481,"creationTimestamp":482},"post-golang-for-range-b66ec19c","2026-09-12T08:28:54.498447Z",{"title":484,"slug":485,"cover":486,"excerpt":487,"publishTime":489,"categories":490,"tags":491,"priority":27,"pinned":93,"deleted":93,"visible":111,"allowComment":112},"Go 语言 for range (键值循环)","golang-for-range","\u002Fupload\u002F164871003843896.png",{"raw":488,"autoGenerate":93},"Go 语言中，我们还可以通过 for range 来遍历数组、切片、字符串、map 以及通道（channel）。通过 for range 遍历数组、切片、字符串的返回值都有一个规律：下标索引 index；下标对应的值 value；下面代码演示了如何遍历切片，数组格式类似 ...","2026-09-12T08:28:54.562781Z",[87],[],{"permalink":493,"excerpt":488,"lastModifyTime":494,"phase":116},"\u002Farchives\u002Fgolang-for-range","2026-09-13T05:18:08.345742Z",[496],{"metadata":497,"spec":498,"status":499,"postCount":96},{"name":87,"creationTimestamp":88},{"displayName":90,"slug":87,"cover":91,"description":92,"priority":27,"hideFromList":93,"preventParentPostCascadeQuery":93},{"permalink":95,"postCount":96,"visiblePostCount":96},{"metadata":501,"spec":504,"status":513,"categories":516},{"name":502,"creationTimestamp":503},"post-golang-enum-iota-677c3ce9","2026-09-12T08:28:53.832167Z",{"title":505,"slug":506,"cover":507,"excerpt":508,"publishTime":510,"categories":511,"tags":512,"priority":27,"pinned":93,"deleted":93,"visible":111,"allowComment":112},"Go 语言枚举类型（iota自增）","golang-enum-iota","\u002Fupload\u002F164870953934678.png",{"raw":509,"autoGenerate":93},"Go 语言中其实是没有枚举类型的，但是，可以使用常量 iota 来模拟枚举。const 声明内的每一行常量声明，将会自动套用前面 iota 格式，并自动增加。有点类似于 Excel 表格自动填充功能。也就是说，第一行 Woman 枚举值定义了 0， 那么 Man 的值会自动加一，值变成了1。\r\n","2026-09-12T08:28:53.892261Z",[87],[],{"permalink":514,"excerpt":509,"lastModifyTime":515,"phase":116},"\u002Farchives\u002Fgolang-enum-iota","2026-09-13T05:18:10.763173Z",[517],{"metadata":518,"spec":519,"status":520,"postCount":96},{"name":87,"creationTimestamp":88},{"displayName":90,"slug":87,"cover":91,"description":92,"priority":27,"hideFromList":93,"preventParentPostCascadeQuery":93},{"permalink":95,"postCount":96,"visiblePostCount":96},{"metadata":522,"spec":525,"status":534,"categories":537},{"name":523,"creationTimestamp":524},"post-golang-data-type-string-76c51396","2026-09-12T08:28:53.208004Z",{"title":526,"slug":527,"cover":528,"excerpt":529,"publishTime":531,"categories":532,"tags":533,"priority":27,"pinned":93,"deleted":93,"visible":111,"allowComment":112},"Go 语言字符串 (超级详细)","golang-data-type-string","\u002Fupload\u002F164870932098953.png",{"raw":530,"autoGenerate":93},"在 Go 语言中，字符串是一个不可改变的字节序列，类型为原生数据类型，同 int 、bool、float32、float64 是一样的。字符串的值通过双引号来包裹，Go 语言中，我们可以直接添加非 ASCII 码字符, 代码如下 ...","2026-09-12T08:28:53.273143Z",[87],[],{"permalink":535,"excerpt":530,"lastModifyTime":536,"phase":116},"\u002Farchives\u002Fgolang-data-type-string","2026-09-13T05:18:11.960075Z",[538],{"metadata":539,"spec":540,"status":541,"postCount":96},{"name":87,"creationTimestamp":88},{"displayName":90,"slug":87,"cover":91,"description":92,"priority":27,"hideFromList":93,"preventParentPostCascadeQuery":93},{"permalink":95,"postCount":96,"visiblePostCount":96},{"metadata":543,"spec":546,"status":555,"categories":558},{"name":544,"creationTimestamp":545},"post-golang-data-type-int-9ea8f7dc","2026-09-12T08:28:52.284554Z",{"title":547,"slug":548,"cover":549,"excerpt":550,"publishTime":552,"categories":553,"tags":554,"priority":27,"pinned":93,"deleted":93,"visible":111,"allowComment":112},"Go 语言整型（整数类型）","golang-data-type-int","\u002Fupload\u002F164870903299782.jpg",{"raw":551,"autoGenerate":93},"在 Go 语言中，整型分为以下两个大类，按长度分为: int8 、int16、int32、int64，对应无符号类型: uint8、uint16、uint32、uint64 ，这里 unit8 就是最小单位 byte型，int16 对应 C 语言中的 short型，int64对应 C 语言中的 long 类型。","2026-09-12T08:28:52.339266Z",[87],[],{"permalink":556,"excerpt":551,"lastModifyTime":557,"phase":116},"\u002Farchives\u002Fgolang-data-type-int","2026-09-13T05:18:13.047546Z",[559],{"metadata":560,"spec":561,"status":562,"postCount":96},{"name":87,"creationTimestamp":88},{"displayName":90,"slug":87,"cover":91,"description":92,"priority":27,"hideFromList":93,"preventParentPostCascadeQuery":93},{"permalink":95,"postCount":96,"visiblePostCount":96},{"metadata":564,"spec":567,"status":576,"categories":579},{"name":565,"creationTimestamp":566},"post-golang-data-type-float-cd45b294","2026-09-12T08:28:51.670525Z",{"title":568,"slug":569,"cover":570,"excerpt":571,"publishTime":573,"categories":574,"tags":575,"priority":27,"pinned":93,"deleted":93,"visible":111,"allowComment":112},"Go 语言浮点型 (小数类型)","golang-data-type-float","\u002Fupload\u002F164870916250133.png",{"raw":572,"autoGenerate":93},"Go 语言中提供了两种精度浮点型 float32 和 float64。这两种浮点型数据格式遵循 IEEE754 浮点数国际标准，该浮点数规范被所有现代的CPU支持。float32，即我们常说的单精度，存储占用4个字节，也即4*8=32位，其中1位用来符号，8位用来指数，剩下的23位表示尾数...","2026-09-12T08:28:51.731493Z",[87],[],{"permalink":577,"excerpt":572,"lastModifyTime":578,"phase":116},"\u002Farchives\u002Fgolang-data-type-float","2026-09-14T00:21:02.366342Z",[580],{"metadata":581,"spec":582,"status":583,"postCount":96},{"name":87,"creationTimestamp":88},{"displayName":90,"slug":87,"cover":91,"description":92,"priority":27,"hideFromList":93,"preventParentPostCascadeQuery":93},{"permalink":95,"postCount":96,"visiblePostCount":96},{"metadata":585,"spec":588,"status":597,"categories":600},{"name":586,"creationTimestamp":587},"post-golang-data-type-byte-rune-f5b3c021","2026-09-12T08:28:51.045198Z",{"title":589,"slug":590,"cover":591,"excerpt":592,"publishTime":594,"categories":595,"tags":596,"priority":27,"pinned":93,"deleted":93,"visible":111,"allowComment":112},"Go 语言字符（byte与rune）","golang-data-type-byte-rune","\u002Fupload\u002F164870938414785.png",{"raw":593,"autoGenerate":93},"Go 语言中，字符串的每一个元素叫做字符，主要分为以下两种：1、uint8 类型，或者叫 byte 型，代表了 ASCII 码的一个字符。2、rune 类型，代表了一个 UTF-8 字符。通常情况下，当需要处理中文、日文、韩文等复合字符时，需要用到 rune 类型...","2026-09-12T08:28:51.104406Z",[87],[],{"permalink":598,"excerpt":593,"lastModifyTime":599,"phase":116},"\u002Farchives\u002Fgolang-data-type-byte-rune","2026-09-13T05:18:16.888108Z",[601],{"metadata":602,"spec":603,"status":604,"postCount":96},{"name":87,"creationTimestamp":88},{"displayName":90,"slug":87,"cover":91,"description":92,"priority":27,"hideFromList":93,"preventParentPostCascadeQuery":93},{"permalink":95,"postCount":96,"visiblePostCount":96},{"metadata":606,"spec":609,"status":618,"categories":621},{"name":607,"creationTimestamp":608},"post-golang-data-type-bool-6ff0a48b","2026-09-12T08:28:50.417951Z",{"title":610,"slug":611,"cover":612,"excerpt":613,"publishTime":615,"categories":616,"tags":617,"priority":27,"pinned":93,"deleted":93,"visible":111,"allowComment":112},"Go 语言布尔型 (bool)","golang-data-type-bool","\u002Fupload\u002F164870922253998.png",{"raw":614,"autoGenerate":93},"在 Go 语言中，以 `bool` 来声明布尔类型， 同时，布尔类型只有 `true` 和 `false` 两种值。if 和 for 语句的条件部分都是布尔类型的值，并且 == 和 &lt; 等比较操作也会产生布尔型的值。一元操作符`!`对应逻辑非操作，因此`!true`的值为`false` ...","2026-09-12T08:28:50.467971Z",[87],[],{"permalink":619,"excerpt":614,"lastModifyTime":620,"phase":116},"\u002Farchives\u002Fgolang-data-type-bool","2026-09-13T05:18:17.535720Z",[622],{"metadata":623,"spec":624,"status":625,"postCount":96},{"name":87,"creationTimestamp":88},{"displayName":90,"slug":87,"cover":91,"description":92,"priority":27,"hideFromList":93,"preventParentPostCascadeQuery":93},{"permalink":95,"postCount":96,"visiblePostCount":96},{"metadata":627,"spec":630,"status":639,"categories":642},{"name":628,"creationTimestamp":629},"post-golang-continue-f0fa1a6c","2026-09-12T08:28:49.801364Z",{"title":631,"slug":632,"cover":633,"excerpt":634,"publishTime":636,"categories":637,"tags":638,"priority":27,"pinned":93,"deleted":93,"visible":111,"allowComment":112},"Go 语言 continue 语句（继续下次循环）","golang-continue","\u002Fupload\u002F164871022786336.png",{"raw":635,"autoGenerate":93},"在 Go 语言中，continue 语句可以结束当前 for 循环，进入下一次 for 循环, 代码如下 ...","2026-09-12T08:28:49.859649Z",[87],[],{"permalink":640,"excerpt":635,"lastModifyTime":641,"phase":116},"\u002Farchives\u002Fgolang-continue","2026-09-13T05:18:18.463890Z",[643],{"metadata":644,"spec":645,"status":646,"postCount":96},{"name":87,"creationTimestamp":88},{"displayName":90,"slug":87,"cover":91,"description":92,"priority":27,"hideFromList":93,"preventParentPostCascadeQuery":93},{"permalink":95,"postCount":96,"visiblePostCount":96},{"metadata":648,"spec":651,"status":660,"categories":663},{"name":649,"creationTimestamp":650},"post-golang-const-fe7071c3","2026-09-12T08:28:49.202451Z",{"title":652,"slug":653,"cover":654,"excerpt":655,"publishTime":657,"categories":658,"tags":659,"priority":27,"pinned":93,"deleted":93,"visible":111,"allowComment":112},"Go 语言常量定义与声明 (const)","golang-const","\u002Fupload\u002F164870944501553.png",{"raw":656,"autoGenerate":93},"相对于 Go 语言变量，常量是一个不可改变的值，如圆周率 π 等。常量在代码的编译期就已经确定了，而不是运行时。定义一个 Go 语言常量非常简单，它和变量的声明方式类似，将 var 关键字替换成 const 即可，代码如下...\r\n","2026-09-12T08:28:49.266405Z",[87],[],{"permalink":661,"excerpt":656,"lastModifyTime":662,"phase":116},"\u002Farchives\u002Fgolang-const","2026-09-13T05:18:19.894037Z",[664],{"metadata":665,"spec":666,"status":667,"postCount":96},{"name":87,"creationTimestamp":88},{"displayName":90,"slug":87,"cover":91,"description":92,"priority":27,"hideFromList":93,"preventParentPostCascadeQuery":93},{"permalink":95,"postCount":96,"visiblePostCount":96},{"metadata":669,"spec":672,"status":681,"categories":684},{"name":670,"creationTimestamp":671},"post-golang-closure-function-66448c59","2026-09-12T08:28:48.580216Z",{"title":673,"slug":674,"cover":675,"excerpt":676,"publishTime":678,"categories":679,"tags":680,"priority":27,"pinned":93,"deleted":93,"visible":111,"allowComment":112},"Go 语言闭包函数_作用_应用场景讲解","golang-closure-function","\u002Fupload\u002F164871051986441.png",{"raw":677,"autoGenerate":93},"在 Go 语言中，闭包是个啥概念呢？一句话来讲：引用了外部变量的匿名函数。公式如下: 函数 + 引用外部变量 = 闭包。一、定义闭包，下面代码演示了如何在 Go 语言中定义闭包 ...\r\n","2026-09-12T08:28:48.641469Z",[87],[],{"permalink":682,"excerpt":677,"lastModifyTime":683,"phase":116},"\u002Farchives\u002Fgolang-closure-function","2026-09-13T05:18:20.909737Z",[685],{"metadata":686,"spec":687,"status":688,"postCount":96},{"name":87,"creationTimestamp":88},{"displayName":90,"slug":87,"cover":91,"description":92,"priority":27,"hideFromList":93,"preventParentPostCascadeQuery":93},{"permalink":95,"postCount":96,"visiblePostCount":96},{"metadata":690,"spec":693,"status":702,"categories":705},{"name":691,"creationTimestamp":692},"post-golang-break-f71be769","2026-09-12T08:28:47.631962Z",{"title":694,"slug":695,"cover":696,"excerpt":697,"publishTime":699,"categories":700,"tags":701,"priority":27,"pinned":93,"deleted":93,"visible":111,"allowComment":112},"Go 语言 break 语句（跳出循环）","golang-break","\u002Fupload\u002F164871018843750.png",{"raw":698,"autoGenerate":93},"在 Go 语言中，break 语句可以结束 for、switch 和 select 代码块。通过 break 语句搭配标签可以跳出代码块，如跳出 for 、switch 和 select 代码块。下面的代码演示了如何通过 break 跳出多层循环，代码如下 ...\r\n","2026-09-12T08:28:47.687071Z",[87],[],{"permalink":703,"excerpt":698,"lastModifyTime":704,"phase":116},"\u002Farchives\u002Fgolang-break","2026-09-13T05:18:21.755986Z",[706],{"metadata":707,"spec":708,"status":709,"postCount":96},{"name":87,"creationTimestamp":88},{"displayName":90,"slug":87,"cover":91,"description":92,"priority":27,"hideFromList":93,"preventParentPostCascadeQuery":93},{"permalink":95,"postCount":96,"visiblePostCount":96},{"metadata":711,"spec":714,"status":723,"categories":726},{"name":712,"creationTimestamp":713},"post-golang-array-5f3b0020","2026-09-12T08:28:47.022107Z",{"title":715,"slug":716,"cover":717,"excerpt":718,"publishTime":720,"categories":721,"tags":722,"priority":27,"pinned":93,"deleted":93,"visible":111,"allowComment":112},"Go 语言数组_定义_初始化_遍历（超详细）","golang-array","\u002Fupload\u002F164870968761852.png",{"raw":719,"autoGenerate":93},"数组是一段固定长度的连续内存区域。在 Go 语言中，数组一旦声明，那么大小就确定了。我们可以修改数组成员，但是不能改变大小。定义数组的格式如下： var 数组变量名 [元素数量]T，下面这段代码中，定义一个变量为 arr, 成员类型为字符串, 大小为 3 的数组 ...\r\n","2026-09-12T08:28:47.076276Z",[87],[],{"permalink":724,"excerpt":719,"lastModifyTime":725,"phase":116},"\u002Farchives\u002Fgolang-array","2026-09-13T05:18:22.626736Z",[727],{"metadata":728,"spec":729,"status":730,"postCount":96},{"name":87,"creationTimestamp":88},{"displayName":90,"slug":87,"cover":91,"description":92,"priority":27,"hideFromList":93,"preventParentPostCascadeQuery":93},{"permalink":95,"postCount":96,"visiblePostCount":96},{"metadata":732,"spec":735,"status":744,"categories":747},{"name":733,"creationTimestamp":734},"post-golang-anonymous-function-cd5ab702","2026-09-12T08:28:46.418365Z",{"title":736,"slug":737,"cover":738,"excerpt":739,"publishTime":741,"categories":742,"tags":743,"priority":27,"pinned":93,"deleted":93,"visible":111,"allowComment":112},"Go 语言匿名函数_回调函数","golang-anonymous-function","\u002Fupload\u002F164871043722612.png",{"raw":740,"autoGenerate":93},"在 Go 语言中，匿名函数是没有名字的函数，只有函数体。匿名函数经常以变量的形式被传递。大部分场景下，匿名函数经常被使用于实现函数回调、闭包等。匿名函数的定义格式如下 ...\r\n","2026-09-12T08:28:46.479749Z",[87],[],{"permalink":745,"excerpt":740,"lastModifyTime":746,"phase":116},"\u002Farchives\u002Fgolang-anonymous-function","2026-09-13T05:18:23.547060Z",[748],{"metadata":749,"spec":750,"status":751,"postCount":96},{"name":87,"creationTimestamp":88},{"displayName":90,"slug":87,"cover":91,"description":92,"priority":27,"hideFromList":93,"preventParentPostCascadeQuery":93},{"permalink":95,"postCount":96,"visiblePostCount":96},{"metadata":753,"spec":756,"status":765,"categories":768},{"name":754,"creationTimestamp":755},"post-goland-download-1ba6aa8a","2026-09-12T08:28:45.798800Z",{"title":757,"slug":758,"cover":759,"excerpt":760,"publishTime":762,"categories":763,"tags":764,"priority":27,"pinned":93,"deleted":93,"visible":111,"allowComment":112},"Go 语言下载","goland-download","\u002Fupload\u002Fcover-72b74cdd302d.png",{"raw":761,"autoGenerate":93},"想要学习 Go 语言, 首先得下载 Go 语言安装包, 可以前往如下两个网站下载, Golang 中国和Go 语言官网，根据自己的系统，选择对应的 Go 语言安装包，点击下载。","2026-09-12T08:28:45.856679Z",[87],[],{"permalink":766,"excerpt":761,"lastModifyTime":767,"phase":116},"\u002Farchives\u002Fgoland-download","2026-09-14T00:21:02.748134Z",[769],{"metadata":770,"spec":771,"status":772,"postCount":96},{"name":87,"creationTimestamp":88},{"displayName":90,"slug":87,"cover":91,"description":92,"priority":27,"hideFromList":93,"preventParentPostCascadeQuery":93},{"permalink":95,"postCount":96,"visiblePostCount":96},{"metadata":774,"spec":777,"status":786,"categories":790},{"name":775,"creationTimestamp":776},"post-go-get-no-response-f76e24e3","2026-09-12T08:28:45.175847Z",{"title":778,"slug":779,"cover":780,"excerpt":781,"publishTime":783,"categories":784,"tags":785,"priority":27,"pinned":93,"deleted":93,"visible":111,"allowComment":112},"go get 没有反应，下载不了（设置代理一秒解决）","go-get-no-response","\u002Fupload\u002F164871056889028.png",{"raw":782,"autoGenerate":93},"我在安装好 Go 语言 1.15 环境后，想下载 Gin 框架的依赖包，但是发现长时间没有反应，仿佛卡住了一样，下载不下来。可以通过添加国内代理来解决，方法有两种，任选一种即可 ...","2026-09-12T08:28:45.225479Z",[87],[],{"permalink":787,"excerpt":788,"lastModifyTime":789,"phase":116},"\u002Farchives\u002Fgo-get-no-response","安装好 Go 语言 1.15 环境后，想下载 Gin 框架的依赖包，但是发现长时间没有反应，仿佛卡住了一样，下载不下来。可以通过添加国内代理来解决，方法有两种，任选一种即可 ...","2026-09-27T14:43:19.937379Z",[791],{"metadata":792,"spec":793,"status":794,"postCount":96},{"name":87,"creationTimestamp":88},{"displayName":90,"slug":87,"cover":91,"description":92,"priority":27,"hideFromList":93,"preventParentPostCascadeQuery":93},{"permalink":95,"postCount":96,"visiblePostCount":96},{"metadata":796,"spec":797,"status":801,"categories":802,"content":807},{"name":355,"creationTimestamp":356},{"title":358,"slug":359,"cover":360,"excerpt":798,"publishTime":363,"categories":799,"tags":800,"priority":27,"pinned":93,"deleted":93,"visible":111,"allowComment":112},{"raw":362,"autoGenerate":93},[87],[],{"permalink":367,"excerpt":362,"lastModifyTime":368,"phase":116},[803],{"metadata":804,"spec":805,"status":806,"postCount":96},{"name":87,"creationTimestamp":88},{"displayName":90,"slug":87,"cover":91,"description":92,"priority":27,"hideFromList":93,"preventParentPostCascadeQuery":93},{"permalink":95,"postCount":96,"visiblePostCount":96},{"content":808,"raw":808},"\u003Cp>在 Go 语言\u003Cspan>\u003Csvg xmlns=\"http:\u002F\u002Fwww.w3.org\u002F2000\u002Fsvg\" style=\"color: #aaa; margin-left: 3px;\" aria-hidden=\"true\" focusable=\"false\" x=\"0px\" y=\"0px\" viewBox=\"0 0 100 100\" width=\"15\" height=\"15\" class=\"icon outbound\">\u003Cpath fill=\"currentColor\" d=\"M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z\">\u003C\u002Fpath> \u003Cpolygon fill=\"currentColor\" points=\"45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9\">\u003C\u002Fpolygon>\u003C\u002Fsvg> \u003Cspan class=\"sr-only\">\u003C\u002Fspan>\u003C\u002Fspan>中，goto 语句\u003Cstrong>通过标签实现代码间的跳转\u003C\u002Fstrong>。它通常会被使用在快速跳出循环\u003Cspan>\u003Csvg xmlns=\"http:\u002F\u002Fwww.w3.org\u002F2000\u002Fsvg\" style=\"color: #aaa; margin-left: 3px;\" aria-hidden=\"true\" focusable=\"false\" x=\"0px\" y=\"0px\" viewBox=\"0 0 100 100\" width=\"15\" height=\"15\" class=\"icon outbound\">\u003Cpath fill=\"currentColor\" d=\"M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z\">\u003C\u002Fpath> \u003Cpolygon fill=\"currentColor\" points=\"45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9\">\u003C\u002Fpolygon>\u003C\u002Fsvg> \u003Cspan class=\"sr-only\">\u003C\u002Fspan>\u003C\u002Fspan>、避免定义重复代码等。\u003C\u002Fp>\n\u003Ch2>一、使用 goto 跳出循环\u003C\u002Fh2>\n\u003Cpre>\u003Ccode class=\"language-go\">package main\n\nimport &quot;fmt&quot;\n\nfunc main()  {\n\t\u002F\u002F 外循环\n\tfor i := 0; i &lt; 10; i++ {\n\t\t\u002F\u002F 内循环\n\t\tfor j := 0; j &lt; 10; j++ {\n\t\t\t\u002F\u002F 当 j 等于 2 时，跳转到标签 breakHere 那里\n\t\t\tif j == 2 {\n\t\t\t\t\u002F\u002F 跳转标签\n\t\t\t\tgoto breakHere\n\t\t\t}\n\t\t}\n\t}\n\n\t\u002F\u002F 手动返回，防止执行后面的标签\n\treturn\n\n\t\u002F\u002F 定义一个标签\n\tbreakHere:\n\t\tfmt.Println(&quot;跳到这里 ...&quot;)\n}\n\u003C\u002Fcode>\u003C\u002Fpre>\n\u003Cp>代码输出:\u003C\u002Fp>\n\u003Cpre>\u003Ccode class=\"language-go\">跳到这里 ...\n\u003C\u002Fcode>\u003C\u002Fpre>\n\u003Cp>图示：\u003C\u002Fp>\n\u003Cp>\n\u003Cimg src=\"\u002Fupload\u002F164871014638160.png\" loading=\"lazy\" title=\"go语言goto语句跳转代码示例\" alt=\"go语言goto语句跳转代码示例\">\u003Cspan class=\"image-caption\">go语言goto语句跳转代码示例\u003C\u002Fspan>\n\u003C\u002Fp>\n\u003Ch2>二、避免定义重复代码\u003C\u002Fh2>\n\u003Cp>在实际的编码中，经常会定义一些重复性的代码，如下：\u003C\u002Fp>\n\u003Cpre>\u003Ccode class=\"language-go\">err := firstCheckError()\nif err != nil {\n  \u002F\u002F 打印错误，并退出\n  fmt.Println(err)\n  exit()\n  return\n}\n\nerr := secondCheckError()\nif err != nil {\n  \u002F\u002F 打印错误，并退出\n  fmt.Println(err)\n  exit()\n  return\n}\n\u003C\u002Fcode>\u003C\u002Fpre>\n\u003Cp>上面的这段明显有重复代码，我们可以 \u003Ccode>goto\u003C\u002Fcode> 定义标签来使代码变的更加优雅一点:\u003C\u002Fp>\n\u003Cpre>\u003Ccode class=\"language-go\">err := firstCheckError()\nif err != nil {\n  goto onExit\n  return\n}\n\nerr := secondCheckError()\nif err != nil {\n  goto onExit\n  return\n}\n\nreturn\n\nonExit:\n  fmt.Println(err)\n  exit()\n\u003C\u002Fcode>\u003C\u002Fpre>\n13:T157c,\u003Cp>在 Go 语言\u003Cspan>\u003Csvg xmlns=\"http:\u002F\u002Fwww.w3.org\u002F2000\u002Fsvg\" style=\"color: #aaa; margin-left: 3px;\" aria-hidden=\"true\" focusable=\"false\" x=\"0px\" y=\"0px\" viewBox=\"0 0 100 100\" width=\"15\" height=\"15\" class=\"icon outbound\">\u003Cpath fill=\"currentColor\" d=\"M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z\">\u003C\u002Fpath> \u003Cpolygon fill=\"currentColor\" points=\"45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9\">\u003C\u002Fpolygon>\u003C\u002Fsvg> \u003Cspan class=\"sr-only\">\u003C\u002Fspan>\u003C\u002Fspan>中，goto 语句\u003Cstrong>通过标签实现代码间的跳转\u003C\u002Fstrong>。它通常会被使用在快速跳出循环\u003Cspan>\u003Csvg xmlns=\"http:\u002F\u002Fwww.w3.org\u002F2000\u002Fsvg\" style=\"color: #aaa; margin-left: 3px;\" aria-hidden=\"true\" focusable=\"false\" x=\"0px\" y=\"0px\" viewBox=\"0 0 100 100\" width=\"15\" height=\"15\" class=\"icon outbound\">\u003Cpath fill=\"currentColor\" d=\"M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z\">\u003C\u002Fpath> \u003Cpolygon fill=\"currentColor\" points=\"45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9\">\u003C\u002Fpolygon>\u003C\u002Fsvg> \u003Cspan class=\"sr-only\">\u003C\u002Fspan>\u003C\u002Fspan>、避免定义重复代码等。\u003C\u002Fp>\n\u003Ch2 id=\"toc-0\">一、使用 goto 跳出循环\u003C\u002Fh2>\n\u003Cdiv class=\"language-go\" data-ext=\"go\" data-code=\"package%20main%0A%0Aimport%20%22fmt%22%0A%0Afunc%20main()%20%20%7B%0A%09%2F%2F%20%E5%A4%96%E5%BE%AA%E7%8E%AF%0A%09for%20i%20%3A%3D%200%3B%20i%20%3C%2010%3B%20i%2B%2B%20%7B%0A%09%09%2F%2F%20%E5%86%85%E5%BE%AA%E7%8E%AF%0A%09%09for%20j%20%3A%3D%200%3B%20j%20%3C%2010%3B%20j%2B%2B%20%7B%0A%09%09%09%2F%2F%20%E5%BD%93%20j%20%E7%AD%89%E4%BA%8E%202%20%E6%97%B6%EF%BC%8C%E8%B7%B3%E8%BD%AC%E5%88%B0%E6%A0%87%E7%AD%BE%20breakHere%20%E9%82%A3%E9%87%8C%0A%09%09%09if%20j%20%3D%3D%202%20%7B%0A%09%09%09%09%2F%2F%20%E8%B7%B3%E8%BD%AC%E6%A0%87%E7%AD%BE%0A%09%09%09%09goto%20breakHere%0A%09%09%09%7D%0A%09%09%7D%0A%09%7D%0A%0A%09%2F%2F%20%E6%89%8B%E5%8A%A8%E8%BF%94%E5%9B%9E%EF%BC%8C%E9%98%B2%E6%AD%A2%E6%89%A7%E8%A1%8C%E5%90%8E%E9%9D%A2%E7%9A%84%E6%A0%87%E7%AD%BE%0A%09return%0A%0A%09%2F%2F%20%E5%AE%9A%E4%B9%89%E4%B8%80%E4%B8%AA%E6%A0%87%E7%AD%BE%0A%09breakHere%3A%0A%09%09fmt.Println(%22%E8%B7%B3%E5%88%B0%E8%BF%99%E9%87%8C%20...%22)%0A%7D%0A\">\n        \u003Cbutton class=\"vp-copy-code-button\" data-copy data-copied=\"已复制\" aria-label=\"复制代码\">\u003C\u002Fbutton>\n        \u003Cpre>\u003Ccode class=\"language-go\">package main\n\nimport &quot;fmt&quot;\n\nfunc main()  {\n\t\u002F\u002F 外循环\n\tfor i := 0; i &lt; 10; i++ {\n\t\t\u002F\u002F 内循环\n\t\tfor j := 0; j &lt; 10; j++ {\n\t\t\t\u002F\u002F 当 j 等于 2 时，跳转到标签 breakHere 那里\n\t\t\tif j == 2 {\n\t\t\t\t\u002F\u002F 跳转标签\n\t\t\t\tgoto breakHere\n\t\t\t}\n\t\t}\n\t}\n\n\t\u002F\u002F 手动返回，防止执行后面的标签\n\treturn\n\n\t\u002F\u002F 定义一个标签\n\tbreakHere:\n\t\tfmt.Println(&quot;跳到这里 ...&quot;)\n}\n\u003C\u002Fcode>\u003C\u002Fpre>\n      \u003C\u002Fdiv>\n\u003Cp>代码输出:\u003C\u002Fp>\n\u003Cdiv class=\"language-go\" data-ext=\"go\" data-code=\"%E8%B7%B3%E5%88%B0%E8%BF%99%E9%87%8C%20...%0A\">\n        \u003Cbutton class=\"vp-copy-code-button\" data-copy data-copied=\"已复制\" aria-label=\"复制代码\">\u003C\u002Fbutton>\n        \u003Cpre>\u003Ccode class=\"language-go\">跳到这里 ...\n\u003C\u002Fcode>\u003C\u002Fpre>\n      \u003C\u002Fdiv>\n\u003Cp>图示：\u003C\u002Fp>\n\u003Cp>\n\u003Cdiv class=\"img-loading\">\u003Cimg src=\"\u002Fupload\u002F164871014638160.png\" loading=\"lazy\" title=\"go语言goto语句跳转代码示例\" alt=\"go语言goto语句跳转代码示例\">\u003C\u002Fdiv>\u003Cspan class=\"image-caption\">go语言goto语句跳转代码示例\u003C\u002Fspan>\n\u003C\u002Fp>\n\u003Ch2 id=\"toc-1\">二、避免定义重复代码\u003C\u002Fh2>\n\u003Cp>在实际的编码中，经常会定义一些重复性的代码，如下：\u003C\u002Fp>\n\u003Cdiv class=\"language-go\" data-ext=\"go\" data-code=\"err%20%3A%3D%20firstCheckError()%0Aif%20err%20!%3D%20nil%20%7B%0A%20%20%2F%2F%20%E6%89%93%E5%8D%B0%E9%94%99%E8%AF%AF%EF%BC%8C%E5%B9%B6%E9%80%80%E5%87%BA%0A%20%20fmt.Println(err)%0A%20%20exit()%0A%20%20return%0A%7D%0A%0Aerr%20%3A%3D%20secondCheckError()%0Aif%20err%20!%3D%20nil%20%7B%0A%20%20%2F%2F%20%E6%89%93%E5%8D%B0%E9%94%99%E8%AF%AF%EF%BC%8C%E5%B9%B6%E9%80%80%E5%87%BA%0A%20%20fmt.Println(err)%0A%20%20exit()%0A%20%20return%0A%7D%0A\">\n        \u003Cbutton class=\"vp-copy-code-button\" data-copy data-copied=\"已复制\" aria-label=\"复制代码\">\u003C\u002Fbutton>\n        \u003Cpre>\u003Ccode class=\"language-go\">err := firstCheckError()\nif err != nil {\n  \u002F\u002F 打印错误，并退出\n  fmt.Println(err)\n  exit()\n  return\n}\n\nerr := secondCheckError()\nif err != nil {\n  \u002F\u002F 打印错误，并退出\n  fmt.Println(err)\n  exit()\n  return\n}\n\u003C\u002Fcode>\u003C\u002Fpre>\n      \u003C\u002Fdiv>\n\u003Cp>上面的这段明显有重复代码，我们可以 \u003Ccode>goto\u003C\u002Fcode> 定义标签来使代码变的更加优雅一点:\u003C\u002Fp>"]