2022-08-04 06:59:33 +00:00
<!DOCTYPE HTML>
< html lang = "zh" class = "sidebar-visible no-js light" >
< head >
2024-08-13 00:15:53 +00:00
<!-- Book generated using https://github.com/wa - lang/wabook -->
2022-08-04 06:59:33 +00:00
< meta charset = "UTF-8" >
< title > 前言 - Go语言圣经< / title >
<!-- Custom HTML head -->
< meta content = "text/html; charset=utf-8" http-equiv = "Content-Type" >
2024-08-08 07:47:03 +00:00
< meta name = "description" content = "" >
2022-08-04 06:59:33 +00:00
< meta name = "viewport" content = "width=device-width, initial-scale=1" >
< meta name = "theme-color" content = "#ffffff" / >
2024-08-08 07:47:03 +00:00
< link rel = "icon" href = "./favicon.svg" >
< link rel = "shortcut icon" href = "./favicon.png" >
2024-08-13 00:15:53 +00:00
< link rel = "stylesheet" href = "./static/wabook/css/variables.css" >
< link rel = "stylesheet" href = "./static/wabook/css/general.css" >
< link rel = "stylesheet" href = "./static/wabook/css/chrome.css" >
< link rel = "stylesheet" href = "./static/wabook/css/print.css" media = "print" >
2022-08-04 06:59:33 +00:00
<!-- Fonts -->
2024-08-13 00:15:53 +00:00
< link rel = "stylesheet" href = "./static/wabook/FontAwesome/css/font-awesome.css" >
< link rel = "stylesheet" href = "./static/wabook/fonts/fonts.css" >
2022-08-04 06:59:33 +00:00
<!-- Highlight.js Stylesheets -->
2024-08-13 00:15:53 +00:00
< link rel = "stylesheet" href = "./static/wabook/highlight.css" >
< link rel = "stylesheet" href = "./static/wabook/tomorrow-night.css" >
< link rel = "stylesheet" href = "./static/wabook/ayu-highlight.css" >
2022-08-04 06:59:33 +00:00
<!-- Custom theme stylesheets -->
< / head >
< body >
<!-- Provide site root to javascript -->
< script type = "text/javascript" >
2024-08-08 07:47:03 +00:00
var path_to_root = "./";
2022-08-04 06:59:33 +00:00
var default_theme = window.matchMedia("(prefers-color-scheme: dark)").matches ? "navy" : "light";
< / script >
<!-- Work around some values being stored in localStorage wrapped in quotes -->
< script type = "text/javascript" >
try {
2024-08-13 00:15:53 +00:00
var theme = localStorage.getItem('wabook-theme');
var sidebar = localStorage.getItem('wabook-sidebar');
2022-08-04 06:59:33 +00:00
if (theme.startsWith('"') & & theme.endsWith('"')) {
2024-08-13 00:15:53 +00:00
localStorage.setItem('wabook-theme', theme.slice(1, theme.length - 1));
2022-08-04 06:59:33 +00:00
}
if (sidebar.startsWith('"') & & sidebar.endsWith('"')) {
2024-08-13 00:15:53 +00:00
localStorage.setItem('wabook-sidebar', sidebar.slice(1, sidebar.length - 1));
2022-08-04 06:59:33 +00:00
}
} catch (e) { }
< / script >
<!-- Set the theme before any content is loaded, prevents flash -->
< script type = "text/javascript" >
var theme;
2024-08-13 00:15:53 +00:00
try { theme = localStorage.getItem('wabook-theme'); } catch(e) { }
2022-08-04 06:59:33 +00:00
if (theme === null || theme === undefined) { theme = default_theme; }
var html = document.querySelector('html');
html.classList.remove('no-js')
html.classList.remove('light')
html.classList.add(theme);
html.classList.add('js');
< / script >
<!-- Hide / unhide sidebar before it is displayed -->
< script type = "text/javascript" >
var html = document.querySelector('html');
var sidebar = 'hidden';
if (document.body.clientWidth >= 1080) {
2024-08-13 00:15:53 +00:00
try { sidebar = localStorage.getItem('wabook-sidebar'); } catch(e) { }
2022-08-04 06:59:33 +00:00
sidebar = sidebar || 'visible';
}
html.classList.remove('sidebar-visible');
html.classList.add("sidebar-" + sidebar);
< / script >
< nav id = "sidebar" class = "sidebar" aria-label = "Table of contents" >
< div class = "sidebar-scrollbox" >
2024-08-08 07:47:03 +00:00
< ol class = "chapter" >
< li class = "chapter-item expanded " >
< a href = "./index.html" > Go语言圣经< / a >
< / li >
< li class = "chapter-item expanded " >
< a href = "./preface-zh.html" > 译者序< / a >
< / li >
< li class = "chapter-item expanded " >
< a href = "./preface.html" class = "active" > 前言< / a >
< / li >
< li class = "chapter-item expanded " >
< a href = "./ch1/ch1.html" > < strong aria-hidden = "true" > 1.< / strong > 入门< / a >
< / li >
< ol class = "section" >
< li class = "chapter-item expanded " >
< a href = "./ch1/ch1-01.html" > < strong aria-hidden = "true" > 1.1.< / strong > Hello, World< / a >
< / li >
< li class = "chapter-item expanded " >
< a href = "./ch1/ch1-02.html" > < strong aria-hidden = "true" > 1.2.< / strong > 命令行参数< / a >
< / li >
< li class = "chapter-item expanded " >
< a href = "./ch1/ch1-03.html" > < strong aria-hidden = "true" > 1.3.< / strong > 查找重复的行< / a >
< / li >
< li class = "chapter-item expanded " >
< a href = "./ch1/ch1-04.html" > < strong aria-hidden = "true" > 1.4.< / strong > GIF动画< / a >
< / li >
< li class = "chapter-item expanded " >
< a href = "./ch1/ch1-05.html" > < strong aria-hidden = "true" > 1.5.< / strong > 获取URL< / a >
< / li >
< li class = "chapter-item expanded " >
< a href = "./ch1/ch1-06.html" > < strong aria-hidden = "true" > 1.6.< / strong > 并发获取多个URL< / a >
< / li >
< li class = "chapter-item expanded " >
< a href = "./ch1/ch1-07.html" > < strong aria-hidden = "true" > 1.7.< / strong > Web服务< / a >
< / li >
< li class = "chapter-item expanded " >
< a href = "./ch1/ch1-08.html" > < strong aria-hidden = "true" > 1.8.< / strong > 本章要点< / a >
< / li >
< / ol >
< li class = "chapter-item expanded " >
< a href = "./ch2/ch2.html" > < strong aria-hidden = "true" > 2.< / strong > 程序结构< / a >
< / li >
< ol class = "section" >
< li class = "chapter-item expanded " >
< a href = "./ch2/ch2-01.html" > < strong aria-hidden = "true" > 2.1.< / strong > 命名< / a >
< / li >
< li class = "chapter-item expanded " >
< a href = "./ch2/ch2-02.html" > < strong aria-hidden = "true" > 2.2.< / strong > 声明< / a >
< / li >
< li class = "chapter-item expanded " >
< a href = "./ch2/ch2-03.html" > < strong aria-hidden = "true" > 2.3.< / strong > 变量< / a >
< / li >
< li class = "chapter-item expanded " >
< a href = "./ch2/ch2-04.html" > < strong aria-hidden = "true" > 2.4.< / strong > 赋值< / a >
< / li >
< li class = "chapter-item expanded " >
< a href = "./ch2/ch2-05.html" > < strong aria-hidden = "true" > 2.5.< / strong > 类型< / a >
< / li >
< li class = "chapter-item expanded " >
< a href = "./ch2/ch2-06.html" > < strong aria-hidden = "true" > 2.6.< / strong > 包和文件< / a >
< / li >
< li class = "chapter-item expanded " >
< a href = "./ch2/ch2-07.html" > < strong aria-hidden = "true" > 2.7.< / strong > 作用域< / a >
< / li >
< / ol >
< li class = "chapter-item expanded " >
< a href = "./ch3/ch3.html" > < strong aria-hidden = "true" > 3.< / strong > 基础数据类型< / a >
< / li >
< ol class = "section" >
< li class = "chapter-item expanded " >
< a href = "./ch3/ch3-01.html" > < strong aria-hidden = "true" > 3.1.< / strong > 整型< / a >
< / li >
< li class = "chapter-item expanded " >
< a href = "./ch3/ch3-02.html" > < strong aria-hidden = "true" > 3.2.< / strong > 浮点数< / a >
< / li >
< li class = "chapter-item expanded " >
< a href = "./ch3/ch3-03.html" > < strong aria-hidden = "true" > 3.3.< / strong > 复数< / a >
< / li >
< li class = "chapter-item expanded " >
< a href = "./ch3/ch3-04.html" > < strong aria-hidden = "true" > 3.4.< / strong > 布尔型< / a >
< / li >
< li class = "chapter-item expanded " >
< a href = "./ch3/ch3-05.html" > < strong aria-hidden = "true" > 3.5.< / strong > 字符串< / a >
< / li >
< li class = "chapter-item expanded " >
< a href = "./ch3/ch3-06.html" > < strong aria-hidden = "true" > 3.6.< / strong > 常量< / a >
< / li >
< / ol >
< li class = "chapter-item expanded " >
< a href = "./ch4/ch4.html" > < strong aria-hidden = "true" > 4.< / strong > 复合数据类型< / a >
< / li >
< ol class = "section" >
< li class = "chapter-item expanded " >
< a href = "./ch4/ch4-01.html" > < strong aria-hidden = "true" > 4.1.< / strong > 数组< / a >
< / li >
< li class = "chapter-item expanded " >
< a href = "./ch4/ch4-02.html" > < strong aria-hidden = "true" > 4.2.< / strong > Slice< / a >
< / li >
< li class = "chapter-item expanded " >
< a href = "./ch4/ch4-03.html" > < strong aria-hidden = "true" > 4.3.< / strong > Map< / a >
< / li >
< li class = "chapter-item expanded " >
< a href = "./ch4/ch4-04.html" > < strong aria-hidden = "true" > 4.4.< / strong > 结构体< / a >
< / li >
< li class = "chapter-item expanded " >
< a href = "./ch4/ch4-05.html" > < strong aria-hidden = "true" > 4.5.< / strong > JSON< / a >
< / li >
< li class = "chapter-item expanded " >
< a href = "./ch4/ch4-06.html" > < strong aria-hidden = "true" > 4.6.< / strong > 文本和HTML模板< / a >
< / li >
< / ol >
< li class = "chapter-item expanded " >
< a href = "./ch5/ch5.html" > < strong aria-hidden = "true" > 5.< / strong > 函数< / a >
< / li >
< ol class = "section" >
< li class = "chapter-item expanded " >
< a href = "./ch5/ch5-01.html" > < strong aria-hidden = "true" > 5.1.< / strong > 函数声明< / a >
< / li >
< li class = "chapter-item expanded " >
< a href = "./ch5/ch5-02.html" > < strong aria-hidden = "true" > 5.2.< / strong > 递归< / a >
< / li >
< li class = "chapter-item expanded " >
< a href = "./ch5/ch5-03.html" > < strong aria-hidden = "true" > 5.3.< / strong > 多返回值< / a >
< / li >
< li class = "chapter-item expanded " >
< a href = "./ch5/ch5-04.html" > < strong aria-hidden = "true" > 5.4.< / strong > 错误< / a >
< / li >
< li class = "chapter-item expanded " >
< a href = "./ch5/ch5-05.html" > < strong aria-hidden = "true" > 5.5.< / strong > 函数值< / a >
< / li >
< li class = "chapter-item expanded " >
< a href = "./ch5/ch5-06.html" > < strong aria-hidden = "true" > 5.6.< / strong > 匿名函数< / a >
< / li >
< li class = "chapter-item expanded " >
< a href = "./ch5/ch5-07.html" > < strong aria-hidden = "true" > 5.7.< / strong > 可变参数< / a >
< / li >
< li class = "chapter-item expanded " >
< a href = "./ch5/ch5-08.html" > < strong aria-hidden = "true" > 5.8.< / strong > Deferred函数< / a >
< / li >
< li class = "chapter-item expanded " >
< a href = "./ch5/ch5-09.html" > < strong aria-hidden = "true" > 5.9.< / strong > Panic异常< / a >
< / li >
< li class = "chapter-item expanded " >
< a href = "./ch5/ch5-10.html" > < strong aria-hidden = "true" > 5.10.< / strong > Recover捕获异常< / a >
< / li >
< / ol >
< li class = "chapter-item expanded " >
< a href = "./ch6/ch6.html" > < strong aria-hidden = "true" > 6.< / strong > 方法< / a >
< / li >
< ol class = "section" >
< li class = "chapter-item expanded " >
< a href = "./ch6/ch6-01.html" > < strong aria-hidden = "true" > 6.1.< / strong > 方法声明< / a >
< / li >
< li class = "chapter-item expanded " >
< a href = "./ch6/ch6-02.html" > < strong aria-hidden = "true" > 6.2.< / strong > 基于指针对象的方法< / a >
< / li >
< li class = "chapter-item expanded " >
< a href = "./ch6/ch6-03.html" > < strong aria-hidden = "true" > 6.3.< / strong > 通过嵌入结构体来扩展类型< / a >
< / li >
< li class = "chapter-item expanded " >
< a href = "./ch6/ch6-04.html" > < strong aria-hidden = "true" > 6.4.< / strong > 方法值和方法表达式< / a >
< / li >
< li class = "chapter-item expanded " >
< a href = "./ch6/ch6-05.html" > < strong aria-hidden = "true" > 6.5.< / strong > 示例: Bit数组< / a >
< / li >
< li class = "chapter-item expanded " >
< a href = "./ch6/ch6-06.html" > < strong aria-hidden = "true" > 6.6.< / strong > 封装< / a >
< / li >
< / ol >
< li class = "chapter-item expanded " >
< a href = "./ch7/ch7.html" > < strong aria-hidden = "true" > 7.< / strong > 接口< / a >
< / li >
< ol class = "section" >
< li class = "chapter-item expanded " >
< a href = "./ch7/ch7-01.html" > < strong aria-hidden = "true" > 7.1.< / strong > 接口是合约< / a >
< / li >
< li class = "chapter-item expanded " >
< a href = "./ch7/ch7-02.html" > < strong aria-hidden = "true" > 7.2.< / strong > 接口类型< / a >
< / li >
< li class = "chapter-item expanded " >
< a href = "./ch7/ch7-03.html" > < strong aria-hidden = "true" > 7.3.< / strong > 实现接口的条件< / a >
< / li >
< li class = "chapter-item expanded " >
< a href = "./ch7/ch7-04.html" > < strong aria-hidden = "true" > 7.4.< / strong > flag.Value接口< / a >
< / li >
< li class = "chapter-item expanded " >
< a href = "./ch7/ch7-05.html" > < strong aria-hidden = "true" > 7.5.< / strong > 接口值< / a >
< / li >
< li class = "chapter-item expanded " >
< a href = "./ch7/ch7-06.html" > < strong aria-hidden = "true" > 7.6.< / strong > sort.Interface接口< / a >
< / li >
< li class = "chapter-item expanded " >
< a href = "./ch7/ch7-07.html" > < strong aria-hidden = "true" > 7.7.< / strong > http.Handler接口< / a >
< / li >
< li class = "chapter-item expanded " >
< a href = "./ch7/ch7-08.html" > < strong aria-hidden = "true" > 7.8.< / strong > error接口< / a >
< / li >
< li class = "chapter-item expanded " >
< a href = "./ch7/ch7-09.html" > < strong aria-hidden = "true" > 7.9.< / strong > 示例: 表达式求值< / a >
< / li >
< li class = "chapter-item expanded " >
< a href = "./ch7/ch7-10.html" > < strong aria-hidden = "true" > 7.10.< / strong > 类型断言< / a >
< / li >
< li class = "chapter-item expanded " >
< a href = "./ch7/ch7-11.html" > < strong aria-hidden = "true" > 7.11.< / strong > 基于类型断言识别错误类型< / a >
< / li >
< li class = "chapter-item expanded " >
< a href = "./ch7/ch7-12.html" > < strong aria-hidden = "true" > 7.12.< / strong > 通过类型断言查询接口< / a >
< / li >
< li class = "chapter-item expanded " >
< a href = "./ch7/ch7-13.html" > < strong aria-hidden = "true" > 7.13.< / strong > 类型分支< / a >
< / li >
< li class = "chapter-item expanded " >
< a href = "./ch7/ch7-14.html" > < strong aria-hidden = "true" > 7.14.< / strong > 示例: 基于标记的XML解码< / a >
< / li >
< li class = "chapter-item expanded " >
< a href = "./ch7/ch7-15.html" > < strong aria-hidden = "true" > 7.15.< / strong > 补充几点< / a >
< / li >
< / ol >
< li class = "chapter-item expanded " >
< a href = "./ch8/ch8.html" > < strong aria-hidden = "true" > 8.< / strong > Goroutines和Channels< / a >
< / li >
< ol class = "section" >
< li class = "chapter-item expanded " >
< a href = "./ch8/ch8-01.html" > < strong aria-hidden = "true" > 8.1.< / strong > Goroutines< / a >
< / li >
< li class = "chapter-item expanded " >
< a href = "./ch8/ch8-02.html" > < strong aria-hidden = "true" > 8.2.< / strong > 示例: 并发的Clock服务< / a >
< / li >
< li class = "chapter-item expanded " >
< a href = "./ch8/ch8-03.html" > < strong aria-hidden = "true" > 8.3.< / strong > 示例: 并发的Echo服务< / a >
< / li >
< li class = "chapter-item expanded " >
< a href = "./ch8/ch8-04.html" > < strong aria-hidden = "true" > 8.4.< / strong > Channels< / a >
< / li >
< li class = "chapter-item expanded " >
< a href = "./ch8/ch8-05.html" > < strong aria-hidden = "true" > 8.5.< / strong > 并发的循环< / a >
< / li >
< li class = "chapter-item expanded " >
< a href = "./ch8/ch8-06.html" > < strong aria-hidden = "true" > 8.6.< / strong > 示例: 并发的Web爬虫< / a >
< / li >
< li class = "chapter-item expanded " >
< a href = "./ch8/ch8-07.html" > < strong aria-hidden = "true" > 8.7.< / strong > 基于select的多路复用< / a >
< / li >
< li class = "chapter-item expanded " >
< a href = "./ch8/ch8-08.html" > < strong aria-hidden = "true" > 8.8.< / strong > 示例: 并发的目录遍历< / a >
< / li >
< li class = "chapter-item expanded " >
< a href = "./ch8/ch8-09.html" > < strong aria-hidden = "true" > 8.9.< / strong > 并发的退出< / a >
< / li >
< li class = "chapter-item expanded " >
< a href = "./ch8/ch8-10.html" > < strong aria-hidden = "true" > 8.10.< / strong > 示例: 聊天服务< / a >
< / li >
< / ol >
< li class = "chapter-item expanded " >
< a href = "./ch9/ch9.html" > < strong aria-hidden = "true" > 9.< / strong > 基于共享变量的并发< / a >
< / li >
< ol class = "section" >
< li class = "chapter-item expanded " >
< a href = "./ch9/ch9-01.html" > < strong aria-hidden = "true" > 9.1.< / strong > 竞争条件< / a >
< / li >
< li class = "chapter-item expanded " >
< a href = "./ch9/ch9-02.html" > < strong aria-hidden = "true" > 9.2.< / strong > sync.Mutex互斥锁< / a >
< / li >
< li class = "chapter-item expanded " >
< a href = "./ch9/ch9-03.html" > < strong aria-hidden = "true" > 9.3.< / strong > sync.RWMutex读写锁< / a >
< / li >
< li class = "chapter-item expanded " >
< a href = "./ch9/ch9-04.html" > < strong aria-hidden = "true" > 9.4.< / strong > 内存同步< / a >
< / li >
< li class = "chapter-item expanded " >
< a href = "./ch9/ch9-05.html" > < strong aria-hidden = "true" > 9.5.< / strong > sync.Once惰性初始化< / a >
< / li >
< li class = "chapter-item expanded " >
< a href = "./ch9/ch9-06.html" > < strong aria-hidden = "true" > 9.6.< / strong > 竞争条件检测< / a >
< / li >
< li class = "chapter-item expanded " >
< a href = "./ch9/ch9-07.html" > < strong aria-hidden = "true" > 9.7.< / strong > 示例: 并发的非阻塞缓存< / a >
< / li >
< li class = "chapter-item expanded " >
< a href = "./ch9/ch9-08.html" > < strong aria-hidden = "true" > 9.8.< / strong > Goroutines和线程< / a >
< / li >
< / ol >
< li class = "chapter-item expanded " >
< a href = "./ch10/ch10.html" > < strong aria-hidden = "true" > 10.< / strong > 包和工具< / a >
< / li >
< ol class = "section" >
< li class = "chapter-item expanded " >
< a href = "./ch10/ch10-01.html" > < strong aria-hidden = "true" > 10.1.< / strong > 包简介< / a >
< / li >
< li class = "chapter-item expanded " >
< a href = "./ch10/ch10-02.html" > < strong aria-hidden = "true" > 10.2.< / strong > 导入路径< / a >
< / li >
< li class = "chapter-item expanded " >
< a href = "./ch10/ch10-03.html" > < strong aria-hidden = "true" > 10.3.< / strong > 包声明< / a >
< / li >
< li class = "chapter-item expanded " >
< a href = "./ch10/ch10-04.html" > < strong aria-hidden = "true" > 10.4.< / strong > 导入声明< / a >
< / li >
< li class = "chapter-item expanded " >
< a href = "./ch10/ch10-05.html" > < strong aria-hidden = "true" > 10.5.< / strong > 包的匿名导入< / a >
< / li >
< li class = "chapter-item expanded " >
< a href = "./ch10/ch10-06.html" > < strong aria-hidden = "true" > 10.6.< / strong > 包和命名< / a >
< / li >
< li class = "chapter-item expanded " >
< a href = "./ch10/ch10-07.html" > < strong aria-hidden = "true" > 10.7.< / strong > 工具< / a >
< / li >
< / ol >
< li class = "chapter-item expanded " >
< a href = "./ch11/ch11.html" > < strong aria-hidden = "true" > 11.< / strong > 测试< / a >
< / li >
< ol class = "section" >
< li class = "chapter-item expanded " >
< a href = "./ch11/ch11-01.html" > < strong aria-hidden = "true" > 11.1.< / strong > go test< / a >
< / li >
< li class = "chapter-item expanded " >
< a href = "./ch11/ch11-02.html" > < strong aria-hidden = "true" > 11.2.< / strong > 测试函数< / a >
< / li >
< li class = "chapter-item expanded " >
< a href = "./ch11/ch11-03.html" > < strong aria-hidden = "true" > 11.3.< / strong > 测试覆盖率< / a >
< / li >
< li class = "chapter-item expanded " >
< a href = "./ch11/ch11-04.html" > < strong aria-hidden = "true" > 11.4.< / strong > 基准测试< / a >
< / li >
< li class = "chapter-item expanded " >
< a href = "./ch11/ch11-05.html" > < strong aria-hidden = "true" > 11.5.< / strong > 剖析< / a >
< / li >
< li class = "chapter-item expanded " >
< a href = "./ch11/ch11-06.html" > < strong aria-hidden = "true" > 11.6.< / strong > 示例函数< / a >
< / li >
< / ol >
< li class = "chapter-item expanded " >
< a href = "./ch12/ch12.html" > < strong aria-hidden = "true" > 12.< / strong > 反射< / a >
< / li >
< ol class = "section" >
< li class = "chapter-item expanded " >
< a href = "./ch12/ch12-01.html" > < strong aria-hidden = "true" > 12.1.< / strong > 为何需要反射?< / a >
< / li >
< li class = "chapter-item expanded " >
< a href = "./ch12/ch12-02.html" > < strong aria-hidden = "true" > 12.2.< / strong > reflect.Type和reflect.Value< / a >
< / li >
< li class = "chapter-item expanded " >
< a href = "./ch12/ch12-03.html" > < strong aria-hidden = "true" > 12.3.< / strong > Display递归打印< / a >
< / li >
< li class = "chapter-item expanded " >
< a href = "./ch12/ch12-04.html" > < strong aria-hidden = "true" > 12.4.< / strong > 示例: 编码S表达式< / a >
< / li >
< li class = "chapter-item expanded " >
< a href = "./ch12/ch12-05.html" > < strong aria-hidden = "true" > 12.5.< / strong > 通过reflect.Value修改值< / a >
< / li >
< li class = "chapter-item expanded " >
< a href = "./ch12/ch12-06.html" > < strong aria-hidden = "true" > 12.6.< / strong > 示例: 解码S表达式< / a >
< / li >
< li class = "chapter-item expanded " >
< a href = "./ch12/ch12-07.html" > < strong aria-hidden = "true" > 12.7.< / strong > 获取结构体字段标签< / a >
< / li >
< li class = "chapter-item expanded " >
< a href = "./ch12/ch12-08.html" > < strong aria-hidden = "true" > 12.8.< / strong > 显示一个类型的方法集< / a >
< / li >
< li class = "chapter-item expanded " >
< a href = "./ch12/ch12-09.html" > < strong aria-hidden = "true" > 12.9.< / strong > 几点忠告< / a >
< / li >
< / ol >
< li class = "chapter-item expanded " >
< a href = "./ch13/ch13.html" > < strong aria-hidden = "true" > 13.< / strong > 底层编程< / a >
< / li >
< ol class = "section" >
< li class = "chapter-item expanded " >
< a href = "./ch13/ch13-01.html" > < strong aria-hidden = "true" > 13.1.< / strong > unsafe.Sizeof, Alignof 和 Offsetof< / a >
< / li >
< li class = "chapter-item expanded " >
< a href = "./ch13/ch13-02.html" > < strong aria-hidden = "true" > 13.2.< / strong > unsafe.Pointer< / a >
< / li >
< li class = "chapter-item expanded " >
< a href = "./ch13/ch13-03.html" > < strong aria-hidden = "true" > 13.3.< / strong > 示例: 深度相等判断< / a >
< / li >
< li class = "chapter-item expanded " >
< a href = "./ch13/ch13-04.html" > < strong aria-hidden = "true" > 13.4.< / strong > 通过cgo调用C代码< / a >
< / li >
< li class = "chapter-item expanded " >
< a href = "./ch13/ch13-05.html" > < strong aria-hidden = "true" > 13.5.< / strong > 几点忠告< / a >
< / li >
< / ol >
< li class = "chapter-item expanded " >
< a href = "./appendix/appendix.html" > < strong aria-hidden = "true" > 14.< / strong > 附录< / a >
< / li >
< ol class = "section" >
< li class = "chapter-item expanded " >
< a href = "./appendix/appendix-a-errata.html" > < strong aria-hidden = "true" > 14.1.< / strong > 附录A: 原文勘误< / a >
< / li >
< li class = "chapter-item expanded " >
< a href = "./appendix/appendix-b-author.html" > < strong aria-hidden = "true" > 14.2.< / strong > 附录B: 作者译者< / a >
< / li >
< li class = "chapter-item expanded " >
< a href = "./appendix/appendix-c-cpoyright.html" > < strong aria-hidden = "true" > 14.3.< / strong > 附录C: 译文授权< / a >
< / li >
< li class = "chapter-item expanded " >
< a href = "./appendix/appendix-d-translations.html" > < strong aria-hidden = "true" > 14.4.< / strong > 附录D: 其它语言< / a >
< / li >
< / ol >
< / ol >
< / div >
2022-08-04 06:59:33 +00:00
< div id = "sidebar-resize-handle" class = "sidebar-resize-handle" > < / div >
< / nav >
< div id = "page-wrapper" class = "page-wrapper" >
< div class = "page" >
< div id = "menu-bar-hover-placeholder" > < / div >
< div id = "menu-bar" class = "menu-bar sticky bordered" >
< div class = "left-buttons" >
< button id = "sidebar-toggle" class = "icon-button" type = "button" title = "Toggle Table of Contents" aria-label = "Toggle Table of Contents" aria-controls = "sidebar" >
< i class = "fa fa-bars" > < / i >
< / button >
< button id = "theme-toggle" class = "icon-button" type = "button" title = "Change theme" aria-label = "Change theme" aria-haspopup = "true" aria-expanded = "false" aria-controls = "theme-list" >
< i class = "fa fa-paint-brush" > < / i >
< / button >
< ul id = "theme-list" class = "theme-popup" aria-label = "Themes" role = "menu" >
< li role = "none" > < button role = "menuitem" class = "theme" id = "light" > Light (default)< / button > < / li >
< li role = "none" > < button role = "menuitem" class = "theme" id = "coal" > Coal< / button > < / li >
< li role = "none" > < button role = "menuitem" class = "theme" id = "navy" > Navy< / button > < / li >
< li role = "none" > < button role = "menuitem" class = "theme" id = "ayu" > Ayu< / button > < / li >
< / ul >
2024-08-08 07:47:03 +00:00
< / div >
2022-08-04 06:59:33 +00:00
2024-08-08 07:47:03 +00:00
< h1 class = "menu-title" > < a href = "./index.html" > Go语言圣经< / a > < / h1 >
2022-08-04 06:59:33 +00:00
< div class = "right-buttons" >
2024-08-08 07:47:03 +00:00
< a href = "https://github.com/gopl-zh/gopl-zh.github.com" title = "Git repository" aria-label = "Git repository" >
2022-08-04 06:59:33 +00:00
< i id = "git-repository-button" class = "fa fa-github" > < / i >
< / a >
2024-08-08 07:47:03 +00:00
< a href = "https://github.com/gopl-zh/gopl-zh.github.com/edit/master/preface.md" title = "Suggest an edit" aria-label = "Suggest an edit" >
2022-08-04 06:59:33 +00:00
< i id = "git-edit-button" class = "fa fa-edit" > < / i >
< / a >
< / div >
< / div >
<!-- Apply ARIA attributes after the sidebar and the sidebar toggle button are added to the DOM -->
< script type = "text/javascript" >
document.getElementById('sidebar-toggle').setAttribute('aria-expanded', sidebar === 'visible');
document.getElementById('sidebar').setAttribute('aria-hidden', sidebar !== 'visible');
Array.from(document.querySelectorAll('#sidebar a')).forEach(function(link) {
link.setAttribute('tabIndex', sidebar === 'visible' ? 0 : -1);
});
< / script >
< div id = "content" class = "content" >
<!-- Page table of contents -->
< div class = "sidetoc" > < nav class = "pagetoc" > < / nav > < / div >
2024-08-08 07:47:03 +00:00
2022-08-04 06:59:33 +00:00
< main >
2024-08-13 00:15:53 +00:00
< ul dir = "auto" > < li > < em > 凹语言(Go实现, 面向WASM设计): < a href = "https://github.com/wa-lang/wa" > https://github.com/wa-lang/wa< / a > < / em > < / li > < li > < em > WaBook(Go语言实现的MD电子书构建工具): < a href = "https://github.com/wa-lang/wabook" > https://github.com/wa-lang/wabook< / a > < / em > < / li > < / ul > < hr >
2022-08-04 06:59:33 +00:00
2024-08-08 07:47:03 +00:00
< h1 > 前言< / h1 >
< h2 > Go语言起源< / h2 >
2022-08-04 06:59:33 +00:00
< p > 编程语言的演化跟生物物种的演化类似,一个成功的编程语言的后代一般都会继承它们祖先的优点;当然有时多种语言杂合也可能会产生令人惊讶的特性;还有一些激进的新特性可能并没有先例。通过观察这些影响,我们可以学到为什么一门语言是这样子的,它已经适应了怎样的环境。< / p >
< p > 下图展示了有哪些早期的编程语言对Go语言的设计产生了重要影响。< / p >
2024-08-08 07:47:03 +00:00
< p > < img src = "../images/ch0-01.png" alt = "" > < / p >
2022-08-24 12:59:33 +00:00
< p > Go语言有时候被描述为“类C语言”, 或者是“21世纪的C语言”。Go从C语言继承了相似的表达式语法、控制流结构、基础数据类型、调用参数传值、指针等很多思想, 还有C语言一直所看中的编译后机器码的运行效率以及和现有操作系统的无缝适配。< / p >
< p > 但是在Go语言的家族树中还有其它的祖先。其中一个有影响力的分支来自< a href = "https://en.wikipedia.org/wiki/Niklaus_Wirth" > Niklaus Wirth< / a > 所设计的< code > Pascal< / code > 语言。然后< code > Modula-2< / code > 语言激发了包的概念。然后< code > Oberon< / code > 语言摒弃了模块接口文件和模块实现文件之间的区别。第二代的< code > Oberon-2< / code > 语言直接影响了包的导入和声明的语法,还有< code > Oberon< / code > 语言的面向对象特性所提供的方法的声明语法等。< / p >
< p > Go语言的另一支祖先, 带来了Go语言区别其他语言的重要特性, 灵感来自于贝尔实验室的< a href = "https://en.wikipedia.org/wiki/Tony_Hoare" > Tony Hoare< / a > 于1978年发表的鲜为外界所知的关于并发研究的基础文献 < em > 顺序通信进程< / em > ( < em > communicating sequential processes< / em > ,缩写为< code > CSP< / code > 。在< code > CSP< / code > 中,程序是一组中间没有共享状态的平行运行的处理过程,它们之间使用管道进行通信和控制同步。不过< a href = "https://en.wikipedia.org/wiki/Tony_Hoare" > Tony Hoare< / a > 的< code > CSP< / code > 只是一个用于描述并发性基本概念的描述语言,并不是一个可以编写可执行程序的通用编程语言。< / p >
< p > 接下来, Rob Pike和其他人开始不断尝试将< a href = "https://en.wikipedia.org/wiki/Communicating_sequential_processes" > CSP< / a > 引入实际的编程语言中。他们第一次尝试引入< a href = "https://en.wikipedia.org/wiki/Communicating_sequential_processes" > CSP< / a > 特性的编程语言叫< a href = "http://doc.cat-v.org/bell_labs/squeak/" > Squeak< / a > (老鼠间交流的语言),是一个提供鼠标和键盘事件处理的编程语言,它的管道是静态创建的。然后是改进版的< a href = "http://doc.cat-v.org/bell_labs/squeak/" > Newsqueak< / a > 语言,提供了类似< code > C< / code > 语言语句和表达式的语法和类似< code > Pascal< / code > 语言的推导语法。< code > Newsqueak< / code > 是一个带垃圾回收的纯函数式语言,它再次针对键盘、鼠标和窗口事件管理。但是在< code > Newsqueak< / code > 语言中管道是动态创建的,属于第一类值,可以保存到变量中。< / p >
< p > 在< code > Plan9< / code > 操作系统中,这些优秀的想法被吸收到了一个叫< code > Alef< / code > 的编程语言中。< code > Alef< / code > 试图将< code > Newsqueak< / code > 语言改造为系统编程语言,但是因为缺少垃圾回收机制而导致并发编程很痛苦。(译注:在< code > Alef< / code > 之后还有一个叫< code > Limbo< / code > 的编程语言, Go语言从其中借鉴了很多特性。 具体请参考Pike的讲稿: http://talks.golang.org/2012/concurrency.slide#9 ) < / p >
< p > Go语言的其他的一些特性零散地来自于其他一些编程语言; 比如< code > iota< / code > 语法是从< code > APL< / code > 语言借鉴,词法作用域与嵌套函数来自于< code > Scheme< / code > 语言( 和其他很多语言) 。当然, 我们也可以从Go中发现很多创新的设计。比如Go语言的切片为动态数组提供了有效的随机存取的性能, 这可能会让人联想到链表的底层的共享机制。还有Go语言新发明的< code > defer< / code > 语句。< / p >
2024-08-08 07:47:03 +00:00
< h2 > Go语言项目< / h2 >
2022-08-04 06:59:33 +00:00
< p > 所有的编程语言都反映了语言设计者对编程哲学的反思, 通常包括之前的语言所暴露的一些不足地方的改进。Go项目是在Google公司维护超级复杂的几个软件系统遇到的一些问题的反思( 但是这类问题绝不是Google公司所特有的) 。< / p >
< p > 正如< a href = "http://genius.cat-v.org/rob-pike/" > Rob Pike< / a > 所说,“软件的复杂性是乘法级相关的”,通过增加一个部分的复杂性来修复问题通常将慢慢地增加其他部分的复杂性。通过增加功能、选项和配置是修复问题的最快的途径,但是这很容易让人忘记简洁的内涵,即从长远来看,简洁依然是好软件的关键因素。< / p >
2024-08-08 07:47:03 +00:00
< p > 简洁的设计需要在工作开始的时候舍弃不必要的想法,并且在软件的生命周期内严格区别好的改变和坏的改变。通过足够的努力,一个好的改变可以在不破坏原有完整概念的前提下保持自适应,正如< a href = "http://www.cs.unc.edu/~brooks/" > Fred Brooks< / a > 所说的“概念完整性”;而一个坏的改变则不能达到这个效果,它们仅仅是通过肤浅的和简单的妥协来破坏原有设计的一致性。只有通过简洁的设计,才能让一个系统保持稳定、安全和持续的进化。< / p >
2022-08-04 06:59:33 +00:00
< p > Go项目包括编程语言本身, 附带了相关的工具和标准库, 最后但并非代表不重要的是, 关于简洁编程哲学的宣言。就事后诸葛的角度来看, Go语言的这些地方都做的还不错: 拥有自动垃圾回收、一个包系统、函数作为一等公民、词法作用域、系统调用接口、只读的UTF8字符串等。但是Go语言本身只有很少的特性, 也不太可能添加太多的特性。例如, 它没有隐式的数值转换, 没有构造函数和析构函数, 没有运算符重载, 没有默认参数, 也没有继承, 没有泛型, 没有异常, 没有宏, 没有函数修饰, 更没有线程局部存储。但是, 语言本身是成熟和稳定的, 而且承诺保证向后兼容: 用之前的Go语言编写程序可以用新版本的Go语言编译器和标准库直接构建而不需要修改代码。< / p >
2022-08-24 12:59:33 +00:00
< p > Go语言有足够的类型系统以避免动态语言中那些粗心的类型错误, 但是, Go语言的类型系统相比传统的强类型语言又要简洁很多。虽然, 有时候这会导致一个“无类型”的抽象类型概念, 但是Go语言程序员并不需要像< code > C++< / code > 或< code > Haskell< / code > 程序员那样纠结于具体类型的安全属性。在实践中, Go语言简洁的类型系统给程序员带来了更多的安全性和更好的运行时性能。< / p >
< p > Go语言鼓励当代计算机系统设计的原则, 特别是局部的重要性。它的内置数据类型和大多数的准库数据结构都经过精心设计而避免显式的初始化或隐式的构造函数, 因为很少的内存分配和内存初始化代码被隐藏在库代码中了。Go语言的聚合类型( 结构体和数组) 可以直接操作它们的元素, 只需要更少的存储空间、更少的内存写操作, 而且指针操作比其他间接操作的语言也更有效率。由于现代计算机是一个并行的机器, Go语言提供了基于< code > CSP< / code > 的并发特性支持。Go语言的动态栈使得轻量级线程< code > goroutine< / code > 的初始栈可以很小,因此,创建一个< code > goroutine< / code > 的代价很小,创建百万级的< code > goroutine< / code > 完全是可行的。< / p >
2022-08-04 06:59:33 +00:00
< p > Go语言的标准库( 通常被称为语言自带的电池) , 提供了清晰的构建模块和公共接口, 包含I/O操作、文本处理、图像、密码学、网络和分布式应用程序等, 并支持许多标准化的文件格式和编解码协议。库和工具使用了大量的约定来减少额外的配置和解释, 从而最终简化程序的逻辑, 而且, 每个Go程序结构都是如此的相似, 因此, Go程序也很容易学习。使用Go语言自带工具构建Go语言项目只需要使用文件名和标识符名称, 一个偶尔的特殊注释来确定所有的库、可执行文件、测试、基准测试、例子、以及特定于平台的变量、项目的文档等; Go语言源代码本身就包含了构建规范。< / p >
2024-08-08 07:47:03 +00:00
< h2 > 本书的组织< / h2 >
2022-08-04 06:59:33 +00:00
< p > 我们假设你已经有一种或多种其他编程语言的使用经历, 不管是类似C、C++或Java的编译型语言, 还是类似Python、Ruby、JavaScript的脚本语言, 因此我们不会像对完全的编程语言初学者那样解释所有的细节。因为, Go语言的变量、常量、表达式、控制流和函数等基本语法也是类似的。< / p >
< p > 第一章包含了本教程的基本结构, 通过十几个程序介绍了用Go语言如何实现类似读写文件、文本格式化、创建图像、网络客户端和服务器通讯等日常工作。< / p >
< p > 第二章描述了Go语言程序的基本元素结构、变量、新类型定义、包和文件、以及作用域等概念。第三章讨论了数字、布尔值、字符串和常量, 并演示了如何显示和处理Unicode字符。第四章描述了复合类型, 从简单的数组、字典、切片到动态列表。第五章涵盖了函数, 并讨论了错误处理、panic和recover, 还有defer语句。< / p >
< p > 第一章到第五章是基础部分, 主流命令式编程语言这部分都类似。个别之处, Go语言有自己特色的语法和风格, 但是大多数程序员能很快适应。其余章节是Go语言特有的: 方法、接口、并发、包、测试和反射等语言特性。< / p >
< p > Go语言的面向对象机制与一般语言不同。它没有类层次结构, 甚至可以说没有类; 仅仅通过组合( 而不是继承) 简单的对象来构建复杂的对象。方法不仅可以定义在结构体上, 而且, 可以定义在任何用户自定义的类型上; 并且, 具体类型和抽象类型( 接口) 之间的关系是隐式的, 所以很多类型的设计者可能并不知道该类型到底实现了哪些接口。方法在第六章讨论, 接口在第七章讨论。< / p >
< p > 第八章讨论了基于顺序通信进程( CSP) 概念的并发编程, 使用goroutines和channels处理并发编程。第九章则讨论了传统的基于共享变量的并发编程。< / p >
< p > 第十章描述了包机制和包的组织结构。这一章还展示了如何有效地利用Go自带的工具, 使用单个命令完成编译、测试、基准测试、代码格式化、文档以及其他诸多任务。< / p >
< p > 第十一章讨论了单元测试, Go语言的工具和标准库中集成了轻量级的测试功能, 避免了强大但复杂的测试框架。测试库提供了一些基本构件, 必要时可以用来构建复杂的测试构件。< / p >
< p > 第十二章讨论了反射, 一种程序在运行期间审视自己的能力。反射是一个强大的编程工具, 不过要谨慎地使用; 这一章利用反射机制实现一些重要的Go语言库函数, 展示了反射的强大用法。第十三章解释了底层编程的细节, 在必要时, 可以使用unsafe包绕过Go语言安全的类型系统。< / p >
< p > 每一章都有一些练习题, 你可以用来测试你对Go的理解, 你也可以探讨书中这些例子的扩展和替代。< / p >
2024-08-08 07:47:03 +00:00
< p > 书中所有的代码都可以从 < a href = "http://gopl.io" > http://gopl.io< / a > 上的Git仓库下载。go get命令根据每个例子的导入路径智能地获取、构建并安装。只需要选择一个目录作为工作空间, 然后将GOPATH环境变量设置为该路径。< / p >
2022-08-04 06:59:33 +00:00
< p > 必要时, Go语言工具会创建目录。例如: < / p >
2024-08-08 07:47:03 +00:00
< pre > < code > $ export GOPATH=$HOME/gobook # 选择工作目录
$ go get gopl.io/ch1/helloworld # 获取/编译/安装
$ $GOPATH/bin/helloworld # 运行程序
Hello, 世界 # 这是中文
2022-08-04 06:59:33 +00:00
< / code > < / pre >
< p > 运行这些例子需要安装Go1.5以上的版本。< / p >
2024-08-08 07:47:03 +00:00
< pre > < code > $ go version
go version go1.5 linux/amd64
2022-08-04 06:59:33 +00:00
< / code > < / pre >
2024-08-08 07:47:03 +00:00
< p > 如果使用其他的操作系统,请参考 < a href = "https://golang.org/doc/install" > https://golang.org/doc/install< / a > 提供的说明安装。< / p >
< h2 > 更多的信息< / h2 >
< p > 最佳的帮助信息来自Go语言的官方网站, https://golang.org , 它提供了完善的参考文档, 包括编程语言规范和标准库等诸多权威的帮助信息。同时也包含了如何编写更地道的Go程序的基本教程, 还有各种各样的在线文本资源和视频资源, 它们是本书最有价值的补充。Go语言的官方博客 < a href = "https://blog.golang.org" > https://blog.golang.org< / a > 会不定期发布一些Go语言最好的实践文章, 包括当前语言的发展状态、未来的计划、会议报告和Go语言相关的各种会议的主题等信息( 译注: < a href = "http://talks.golang.org/" > http://talks.golang.org/< / a > 包含了官方收录的各种报告的讲稿)。< / p >
< p > 在线访问的一个有价值的地方是可以从web页面运行Go语言的程序( 而纸质书则没有这么便利了) 。这个功能由来自 < a href = "https://play.golang.org" > https://play.golang.org< / a > 的 Go Playground 提供,并且可以方便地嵌入到其他页面中,例如 < a href = "https://golang.org" > https://golang.org< / a > 的主页,或 godoc 提供的文档页面中。< / p >
2022-08-04 06:59:33 +00:00
< p > Playground可以简单的通过执行一个小程序来测试对语法、语义和对程序库的理解, 类似其他很多语言提供的REPL即时运行的工具。同时它可以生成对应的url, 非常适合共享Go语言代码片段, 汇报bug或提供反馈意见等。< / p >
< p > 基于 Playground 构建的 Go Tour, https://tour.golang.org , 是一个系列的Go语言入门教程, 它包含了诸多基本概念和结构相关的并可在线运行的互动小程序。< / p >
2024-08-08 07:47:03 +00:00
< p > 当然, Playground 和 Tour 也有一些限制, 它们只能导入标准库, 而且因为安全的原因对一些网络库做了限制。如果要在编译和运行时需要访问互联网, 对于一些更复杂的实验, 你可能需要在自己的电脑上构建并运行程序。幸运的是下载Go语言的过程很简单, 从 < a href = "https://golang.org" > https://golang.org< / a > 下载安装包应该不超过几分钟( 译注: 感谢伟大的长城, 让大陆的Gopher们都学会了自己打洞的基本生活技能, 下载时间可能会因为洞的大小等因素从几分钟到几天或更久) , 然后就可以在自己电脑上编写和运行Go程序了。< / p >
< p > Go语言是一个开源项目, 你可以在 < a href = "https://golang.org/pkg" > https://golang.org/pkg< / a > 阅读标准库中任意函数和类型的实现代码,和下载安装包的代码完全一致。这样,你可以知道很多函数是如何工作的, 通过挖掘找出一些答案的细节, 或者仅仅是出于欣赏专业级Go代码。< / p >
< h2 > 致谢< / h2 >
2022-08-04 06:59:33 +00:00
< p > < a href = "http://genius.cat-v.org/rob-pike/" > Rob Pike< / a > 和< a href = "http://research.swtch.com/" > Russ Cox< / a > , 以及很多其他Go团队的核心成员多次仔细阅读了本书的手稿, 他们对本书的组织结构和表述用词等给出了很多宝贵的建议。在准备日文版翻译的时候, Yoshiki Shibata更是仔细地审阅了本书的每个部分, 及时发现了诸多英文和代码的错误。我们非常感谢本书的每一位审阅者, 并感谢对本书给出了重要的建议的Brian Goetz、Corey Kosak、Arnold Robbins、Josh Bleecher Snyder和Peter Weinberger等人。< / p >
< p > 我们还感谢Sameer Ajmani、Ittai Balaban、David Crawshaw、Billy Donohue、Jonathan Feinberg、Andrew Gerrand、Robert Griesemer、John Linderman、Minux Ma( 译注: 中国人, Go团队成员。) 、Bryan Mills、Bala Natarajan、Cosmos Nicolaou、Paul Staniforth、Nigel Tao( 译注: 好像是陶哲轩的兄弟) 以及Howard Trickey给出的许多有价值的建议。我们还要感谢David Brailsford和Raph Levien关于类型设置的建议。< / p >
< p > 我们从来自Addison-Wesley的编辑Greg Doench收到了很多帮助, 从最开始就得到了越来越多的帮助。来自AW生产团队的John Fuller、Dayna Isley、Julie Nahil、Chuti Prasertsith到Barbara Wood, 感谢你们的热心帮助。< / p >
< p > < a href = "https://github.com/adonovan" > Alan Donovan< / a > 特别感谢: Sameer Ajmani、Chris Demetriou、Walt Drummond和Google公司的Reid Tatge允许他有充裕的时间去写本书; 感谢Stephen Donovan的建议和始终如一的鼓励, 以及他的妻子Leila Kazemi并没有让他为了家庭琐事而分心, 并热情坚定地支持这个项目。< / p >
2024-08-08 07:47:03 +00:00
< p > < a href = "http://www.cs.princeton.edu/~bwk/" > Brian Kernighan< / a > 特别感谢: 朋友和同事对他的耐心和宽容, 让他慢慢地梳理本书的写作思路。同时感谢他的妻子Meg和其他很多朋友对他写作事业的支持。< / p >
2022-08-04 06:59:33 +00:00
< p > 2015年 10月 于 纽约< / p >
2024-08-08 07:47:03 +00:00
< hr > < table > < tr > < td > < img width = "222px" src = "https://chai2010.cn/advanced-go-programming-book/css.png" > < / td > < td > < img width = "222px" src = "https://chai2010.cn/advanced-go-programming-book/cch.png" > < / td > < / tr > < / table >
2022-08-04 06:59:33 +00:00
2024-08-08 07:47:03 +00:00
< div id = "giscus-container" > < / div >
< footer class = "page-footer" >
< span > © 2015-2016 | < a href = "https://github.com/gopl-zh" > Go语言圣经中文版< / a > , 仅学习交流使用< / span >
< / footer >
2022-08-04 06:59:33 +00:00
< / main >
< nav class = "nav-wrapper" aria-label = "Page navigation" >
<!-- Mobile navigation buttons -->
2024-08-08 07:47:03 +00:00
< a rel = "prev" href = "./preface-zh.html" class = "mobile-nav-chapters previous" title = "Previous chapter" aria-label = "Previous chapter" aria-keyshortcuts = "Left" >
2022-08-04 06:59:33 +00:00
< i class = "fa fa-angle-left" > < / i >
< / a >
2024-08-08 07:47:03 +00:00
<!-- ./ch1/ch1.html -->
< a rel = "next" href = "./ch1/ch1.html" class = "mobile-nav-chapters next" title = "Next chapter" aria-label = "Next chapter" aria-keyshortcuts = "Right" >
2022-08-04 06:59:33 +00:00
< i class = "fa fa-angle-right" > < / i >
< / a >
< div style = "clear: both" > < / div >
< / nav >
< / div >
< / div >
< nav class = "nav-wide-wrapper" aria-label = "Page navigation" >
2024-08-08 07:47:03 +00:00
< a rel = "prev" href = "./preface-zh.html" class = "nav-chapters previous" title = "Previous chapter" aria-label = "Previous chapter" aria-keyshortcuts = "Left" >
2022-08-04 06:59:33 +00:00
< i class = "fa fa-angle-left" > < / i >
< / a >
2024-08-08 07:47:03 +00:00
< a rel = "next" href = "./ch1/ch1.html" class = "nav-chapters next" title = "Next chapter" aria-label = "Next chapter" aria-keyshortcuts = "Right" >
2022-08-04 06:59:33 +00:00
< i class = "fa fa-angle-right" > < / i >
< / a >
2024-08-08 07:47:03 +00:00
< / nav >
2022-08-04 06:59:33 +00:00
< / div >
2024-08-08 07:47:03 +00:00
< script type = "text/javascript" >
2022-08-04 06:59:33 +00:00
window.playground_copyable = true;
< / script >
2024-08-13 00:15:53 +00:00
< script src = "./static/wabook/mark.min.js" type = "text/javascript" charset = "utf-8" > < / script >
< script src = "./static/wabook/clipboard.min.js" type = "text/javascript" charset = "utf-8" > < / script >
< script src = "./static/wabook/highlight.js" type = "text/javascript" charset = "utf-8" > < / script >
< script src = "./static/wabook/book.js" type = "text/javascript" charset = "utf-8" > < / script >
2022-08-04 06:59:33 +00:00
< script type = "text/javascript" charset = "utf-8" >
2024-08-08 07:47:03 +00:00
var pagePath = "preface.md"
2022-08-04 06:59:33 +00:00
< / script >
<!-- Custom JS scripts -->
2024-08-13 00:15:53 +00:00
< script src = "./static/wabook/giscus.js" type = "text/javascript" charset = "utf-8" > < / script >
2022-08-04 06:59:33 +00:00
2024-08-08 07:47:03 +00:00
2022-08-04 06:59:33 +00:00
< / body >
< / html >