-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
266 lines (236 loc) · 14.8 KB
/
index.html
File metadata and controls
266 lines (236 loc) · 14.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
<!DOCTYPE html>
<html lang="zh">
<head>
<meta charset="utf-8" />
<title>startover's blog</title>
<link rel="shortcut icon" type="image/png" href="http://startover.github.io/favicon.png">
<link rel="shortcut icon" type="image/x-icon" href="http://startover.github.io/favicon.ico">
<link href="http://startover.github.io/feeds/all.atom.xml" type="application/atom+xml" rel="alternate" title="startover's blog Full Atom Feed" />
<link rel="stylesheet" href="http://startover.github.io/theme/css/screen.css" type="text/css" />
<link rel="stylesheet" href="http://startover.github.io/theme/css/pygments.css" type="text/css" />
<link rel="stylesheet" href="http://startover.github.io/theme/css/print.css" type="text/css" media="print" />
<meta name="generator" content="Pelican" />
</head>
<body>
<!-- Fork me on github -->
<a target="_blank" href="https://github.com/startover">
<img width="149px" height="149px" style="position: absolute; top: 0px; right: 0; border: 0; margin: 0; box-shadow: initial" src="http://startover.github.io/theme/icons/forkme.png" alt="Fork me on GitHub" />
</a>
<header>
<nav>
<ul>
<li class="selected"><a href="http://startover.github.io/">Home</a></li>
<li><a href="http://startover.github.io/about">About</a></li>
<li><a href="http://startover.github.io/categories">Categories</a></li>
<li><a href="http://startover.github.io/tags">Tags</a></li>
<li><a href="http://startover.github.io/archives">Archives</a></li>
</ul>
</nav>
<div class="header_box">
<h1><a href="http://startover.github.io/">startover's blog</a></h1>
</div>
</header>
<div id="wrapper">
<div id="content"> <h4 class="date"> 9月 14, 2016</h4>
<article class="post">
<h2 class="title">
<a href="http://startover.github.io/articles/2016/09/14/golang-for-pythonistas-testing/" rel="bookmark" title="Permanent Link to "Python 程序员的 Golang 学习指南(V): 测试篇"">Python 程序员的 Golang 学习指南(V): 测试篇</a>
</h2>
<div class="entry-content"> <p>这篇文章我们介绍下 Go 语言中如何进行测试。</p>
<h2>单元测试</h2>
<ul>
<li>功能测试</li>
</ul>
<p>Go 语言内置测试框架,其通过 <code>testing</code> 包以及 <code>go test</code> 命令来提供测试功能。</p>
<p>编写测试代码需<strong>遵循以下原则</strong>:</p>
<blockquote>
<ol>
<li>文件名必须是 <code>_test.go</code> 结尾的,这样在执行 <code>go test</code> 的时候才会执行到相应的代码。</li>
<li>你必须 import <code>testing</code> 这个包。</li>
<li>所有的测试用例函数必须是 <code>Test</code> 开头。</li>
<li>测试用例会按照源代码中写的顺序依次执行。</li>
<li>测试函数 <code>TestXxx()</code> 的参数是 <code>testing.T</code>,我们可以使用该类型来记录错误或者是测试状态。</li>
<li>测试格式:<code>func TestXxx (t *testing.T)</code>, <code>Xxx</code> 部分可以为任意的字母数字的组合,但是首字母不能是小写字母 [a-z] ,例如 <code>Testintdiv</code> 是错误的函数名 ...</li></ol></blockquote> </div>
<div class="medium primary btn"><a href="http://startover.github.io/articles/2016/09/14/golang-for-pythonistas-testing/" rel="bookmark" title="Permalink to Python 程序员的 Golang 学习指南(V): 测试篇">Read more <i class="icon-arrow-right"></i></a></div>
<div class="clear"></div>
<div class="info">
<a href="http://startover.github.io/articles/2016/09/14/golang-for-pythonistas-testing/">posted at 21:10</a>
· <a href="http://startover.github.io/category/golang/" rel="tag">Golang</a>
·
<a href="http://startover.github.io/tag/golang/" class="tags">Golang</a>
<a href="http://startover.github.io/tag/python/" class="tags">Python</a>
</div>
</article> <h4 class="date"> 9月 07, 2016</h4>
<article class="post">
<h2 class="title">
<a href="http://startover.github.io/articles/2016/09/07/golang-for-pythonistas-package/" rel="bookmark" title="Permanent Link to "Python 程序员的 Golang 学习指南(IV): 包管理篇"">Python 程序员的 Golang 学习指南(IV): 包管理篇</a>
</h2>
<div class="entry-content"> <p>在<a href="http://startover.github.io/articles/2016/08/15/golang-for-pythonistas/">第一篇文章</a>我们有提到,Golang 官方并没有推荐最佳的包管理方案,对于像我这样习惯了 Python 包管理的开发者,自然还是希望有像 pip 一样好用的工具,帮助我们进行依赖管理,下面就让我们对 Golang 的包管理机制一探究竟。</p>
<h2>Golang 包管理机制</h2>
<p>Go 语言的包管理系统是去中心化的,我们可以通过 <code>go get</code> 命令获取存放在远程仓库的代码协议。实际上,<code>go get</code> 支持以下 VCS 协议:</p>
<table class="table table-bordered">
<thead>
<tr>
<th>名称</th>
<th>主命令</th>
<th>说明</th>
</tr>
</thead>
<tbody>
<tr>
<td>Mercurial</td>
<td>hg</td>
<td>Mercurial是一种轻量级分布式版本控制系统,采用Python语言实现,易于学习和使用,扩展性强。</td>
</tr>
<tr>
<td>Git</td>
<td>git</td>
<td>Git最开始是Linux Torvalds为了帮助管理 Linux 内核开发而开发的一个开源的分布式版本控制软件。但现在已被广泛使用。它是被用来进行有效、高速的各种规模项目的版本管理。</td>
</tr>
<tr>
<td>Subversion</td>
<td>svn</td>
<td>Subversion是一个版本控制系统 ...</td></tr></tbody></table> </div>
<div class="medium primary btn"><a href="http://startover.github.io/articles/2016/09/07/golang-for-pythonistas-package/" rel="bookmark" title="Permalink to Python 程序员的 Golang 学习指南(IV): 包管理篇">Read more <i class="icon-arrow-right"></i></a></div>
<div class="clear"></div>
<div class="info">
<a href="http://startover.github.io/articles/2016/09/07/golang-for-pythonistas-package/">posted at 10:24</a>
· <a href="http://startover.github.io/category/golang/" rel="tag">Golang</a>
·
<a href="http://startover.github.io/tag/golang/" class="tags">Golang</a>
<a href="http://startover.github.io/tag/python/" class="tags">Python</a>
</div>
</article> <h4 class="date"> 8月 30, 2016</h4>
<article class="post">
<h2 class="title">
<a href="http://startover.github.io/articles/2016/08/30/golang-for-pythonistas-quickstart/" rel="bookmark" title="Permanent Link to "Python 程序员的 Golang 学习指南(III): 入门篇"">Python 程序员的 Golang 学习指南(III): 入门篇</a>
</h2>
<div class="entry-content"> <h2>基础语法</h2>
<h4>类型和关键字</h4>
<ul>
<li>类型</li>
</ul>
<div class="highlight"><pre><span></span>// 基础类型
布尔类型: bool
整型: int8,uint8,int16,uint16,int32,uint32,int64,uint64,int,rune,byte,complex128, complex64,其中,byte 是 int8 的别名
浮点类型: float32 、 float64
复数类型: complex64 、 complex128
字符串: string
字符类型: rune(int32的别名)
错误类型: error
// 复合类型
指针(pointer)
数组(array)
切片(slice)
字典(map)
通道(chan)
结构体 ...</pre></div> </div>
<div class="medium primary btn"><a href="http://startover.github.io/articles/2016/08/30/golang-for-pythonistas-quickstart/" rel="bookmark" title="Permalink to Python 程序员的 Golang 学习指南(III): 入门篇">Read more <i class="icon-arrow-right"></i></a></div>
<div class="clear"></div>
<div class="info">
<a href="http://startover.github.io/articles/2016/08/30/golang-for-pythonistas-quickstart/">posted at 13:44</a>
· <a href="http://startover.github.io/category/golang/" rel="tag">Golang</a>
·
<a href="http://startover.github.io/tag/golang/" class="tags">Golang</a>
<a href="http://startover.github.io/tag/python/" class="tags">Python</a>
</div>
</article> <h4 class="date"> 8月 22, 2016</h4>
<article class="post">
<h2 class="title">
<a href="http://startover.github.io/articles/2016/08/22/golang-for-pythonistas-environment/" rel="bookmark" title="Permanent Link to "Python 程序员的 Golang 学习指南(II): 开发环境搭建"">Python 程序员的 Golang 学习指南(II): 开发环境搭建</a>
</h2>
<div class="entry-content"> <p><a href="http://startover.github.io/articles/2016/08/15/golang-for-pythonistas/">上一篇文章</a>我们已经对 Golang 有了初步的了解,这篇主要介绍如何在 Ubuntu 14.04 上搭建 Golang 开发环境。</p>
<h2>安装 Golang</h2>
<p>这里就按照<a href="https://golang.org/doc/install#install">官方文档</a>进行安装即可,如下:</p>
<ul>
<li>下载并解压安装包到指定目录</li>
</ul>
<div class="highlight"><pre><span></span>$ wget https://storage.googleapis.com/golang/go1.6.3.linux-amd64.tar.gz
$ tar -C /usr/local -xzf go1.6.3.linux-amd64.tar.gz
</pre></div>
<ul>
<li>设置 PATH</li>
</ul>
<div class="highlight"><pre><span></span>$ <span class="nb">echo</span> <span class="s2">"export PATH=</span><span class="nv">$PATH</span><span class="s2">:/usr/local/go ...</span></pre></div> </div>
<div class="medium primary btn"><a href="http://startover.github.io/articles/2016/08/22/golang-for-pythonistas-environment/" rel="bookmark" title="Permalink to Python 程序员的 Golang 学习指南(II): 开发环境搭建">Read more <i class="icon-arrow-right"></i></a></div>
<div class="clear"></div>
<div class="info">
<a href="http://startover.github.io/articles/2016/08/22/golang-for-pythonistas-environment/">posted at 16:10</a>
· <a href="http://startover.github.io/category/golang/" rel="tag">Golang</a>
·
<a href="http://startover.github.io/tag/golang/" class="tags">Golang</a>
<a href="http://startover.github.io/tag/python/" class="tags">Python</a>
</div>
</article> <h4 class="date"> 8月 15, 2016</h4>
<article class="post">
<h2 class="title">
<a href="http://startover.github.io/articles/2016/08/15/golang-for-pythonistas/" rel="bookmark" title="Permanent Link to "Python 程序员的 Golang 学习指南(I): Go 之初体验"">Python 程序员的 Golang 学习指南(I): Go 之初体验</a>
</h2>
<div class="entry-content"> <h2>Go 语言简介</h2>
<p>Go,又称 golang,是 Google 开发的一种静态强类型,编译型,并发型,并具有垃圾回收功能的编程语言。</p>
<p>Go 语言于2009年11月正式宣布推出,自2012年发布1.0,最新稳定版1.7。目前,Go的相关工具和生态已逐渐趋于完善,也不乏重量级项目,如 Docker, Kubernetes, Etcd, InfluxDB 等。</p>
<h2>Go 语言能解决什么样的问题</h2>
<p>同绝大多数通用型编程语言相比,Go 语言更多的是为了解决我们在构建大型服务器软件过程中所遇到的软件工程方面的问题而设计的。乍看上去,这么讲可能会让人感觉 Go 非常无趣且工业化,但实际上,在设计过程中就着重于清晰和简洁,以及较高的可组合性,最后得到的反而会是一门使用起来效率高而且很有趣的编程语言,很多程序员都会发现,它有极强的表达力而且功能非常强大。</p>
<p>总结为以下几点:</p>
<ul>
<li>清晰的依赖关系</li>
<li>清晰的语法</li>
<li>清晰的语义</li>
<li>偏向组合而不是继承</li>
<li>提供简单的编程模型(垃圾回收、并发)</li>
<li>强大的内置工具 ...</li></ul> </div>
<div class="medium primary btn"><a href="http://startover.github.io/articles/2016/08/15/golang-for-pythonistas/" rel="bookmark" title="Permalink to Python 程序员的 Golang 学习指南(I): Go 之初体验">Read more <i class="icon-arrow-right"></i></a></div>
<div class="clear"></div>
<div class="info">
<a href="http://startover.github.io/articles/2016/08/15/golang-for-pythonistas/">posted at 12:00</a>
· <a href="http://startover.github.io/category/golang/" rel="tag">Golang</a>
·
<a href="http://startover.github.io/tag/golang/" class="tags">Golang</a>
<a href="http://startover.github.io/tag/python/" class="tags">Python</a>
</div>
</article>
<div class="clear"></div>
<div class="pages">
<a href="http://startover.github.io/page/2" class="next_page">Next →</a>
<span>Page 1 of 3</span>
</div>
<div class="clear"></div>
<footer>
<p>
<a href="https://github.com/jody-frankowski/blue-penguin">Blue Penguin</a> Theme
·
Powered by <a href="http://getpelican.com">Pelican</a>
·
<a href="http://startover.github.io/feeds/all.atom.xml" rel="alternate">Atom Feed</a>
</footer>
</div>
<div class="clear"></div>
</div>
<script src="http://startover.github.io/theme/js/libs/jquery-1.9.1.min.js"></script>
<script>
(function() {
var $backToTopTxt = "返回顶部", $backToTopEle = $('<div class="backToTop"></div>').appendTo($("body"))
.text($backToTopTxt).attr("title", $backToTopTxt).click(function() {
$("html, body").animate({ scrollTop: 0 }, 120);
}), $backToTopFun = function() {
var st = $(document).scrollTop(), winh = $(window).height();
(st > 0)? $backToTopEle.show(): $backToTopEle.hide();
//IE6下的定位
if (!window.XMLHttpRequest) {
$backToTopEle.css("top", st + winh - 166);
}
};
$(window).bind("scroll", $backToTopFun);
$(function() { $backToTopFun(); });
})();
</script>
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-63815463-1', 'startover.github.io');
ga('send', 'pageview');
</script>
</body>
</html>