-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
243 lines (207 loc) · 10.5 KB
/
index.html
File metadata and controls
243 lines (207 loc) · 10.5 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
<!DOCTYPE html>
<html>
<head lang="en">
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
<title>TargetLiu - 吃土的码农</title>
<meta name="keywords" content="target,targetliu,TargetLiu,php,laravel,lumen,golang"/>
<meta name="description" content="TargetLiu - 吃土的码农"/>
<link rel="stylesheet" href="/css/bootstrap.min.css"/>
<link rel="stylesheet" href="/css/prism.css"/>
<link rel="stylesheet" href="/css/style.css"/>
</head>
<body class="index" data-perma="index">
<header id="header">
<div class="container">
<div class="header clearfix">
<h3 id="site-title">
<a href="/">TargetLiu <sup>吃土的码农</sup></a>
</h3>
<nav id="site-nav">
<ul class="nav nav-inverse nav-pills">
<li role="presentation" class="active">
<a href="/" >首页
</a>
</li>
<li role="presentation" class="">
<a href="/archive.html" >归档
</a>
</li>
<li role="presentation" class="">
<a href="/about.html" >关于
</a>
</li>
</ul>
</nav>
</div>
</div>
</header>
<section id="main">
<div class="container">
<div id="article-list">
<article class="article">
<div class="row">
<div class="col-md-10 col-md-offset-1 panel panel-default">
<header class="header">
<div class="meta">
<span class="date">
<span class="month">5</span>
<span class="day">26</span>
</span>
</div>
<h3 class="title">
<a href="/2017/5/26/golang-WaitGroup-context-ticker-timeout.html">Golang中WaitGroup、Context、goroutine定时器及超时学习笔记</a>
</h3>
</header>
<section class="brief"><blockquote>
<p>好久没有发过文章了 - -||,今天发一篇 <code>golang</code> 中 <code>goroutine</code> 相关的学习笔记吧,以示例为主。</p>
</blockquote>
<h2 id="waitgroup">WaitGroup</h2>
<p><code>WaitGroup</code> 在 <code>sync</code> 包中,用于阻塞主线程执行直到添加的 <code>goroutine</code> 全部执行完毕。</p>
<h2 id="context">Context</h2>
<p><code>Context</code> 是在 <code>Go1.7</code> 中移入标准库的。</p>
<blockquote>
<p><code>Context</code> 包不仅实现了在程序单元之间共享状态变量的方法,同时能通过简单的方法,使我们在被调用程序单元的外部,通过设置ctx变量值,将过期或撤销这些信号传递给被调用的程序单元。</p>
</blockquote>
<h2 id="goroutine的定时器及超时">goroutine的定时器及超时</h2>
<p>这是两个有趣又实用的功能,在标准库 <code>time</code> 包里提供。</p>
<h2 id="示例">示例</h2>
<h3 id="源码">源码</h3>
</section>
<aside class="aside clearfix">
<a class="btn btn-primary btn-lg pull-right" href="/2017/5/26/golang-WaitGroup-context-ticker-timeout.html">继续阅读</a>
</aside>
</div>
</div>
</article>
<article class="article">
<div class="row">
<div class="col-md-10 col-md-offset-1 panel panel-default">
<header class="header">
<div class="meta">
<span class="date">
<span class="month">9</span>
<span class="day">16</span>
</span>
</div>
<h3 class="title">
<a href="/2016/9/16/golang-excel-xlsx-to-mysql.html">开源一个Golang写的Excel(xlsx)导入MySQL小工具</a>
</h3>
</header>
<section class="brief"><h2 id="简介">简介</h2>
<p>这是工作中用到的一个小工具,将Excel(xlsx)表导入MySQL表中,用Golang写的,每条记录单独一条 <code>goroutine</code> 处理,提高效率。支持随机数生成、密码生成、时间戳;支持关联查询、附表操作等。</p>
<h2 id="使用方法">使用方法</h2>
<ol>
<li><p>使用Go编译安装或直接下载:<a href="https://github.com/TargetLiu/xlsxtomysql/releases">https://github.com/TargetLiu/xlsxtomysql/releases</a></p></li>
<li><p>使用命令: <code>xlsxtomysql [DSN] [数据表名称] [*.xlsx]</code></p></li>
</ol>
</section>
<aside class="aside clearfix">
<a class="btn btn-primary btn-lg pull-right" href="/2016/9/16/golang-excel-xlsx-to-mysql.html">继续阅读</a>
</aside>
</div>
</div>
</article>
<article class="article">
<div class="row">
<div class="col-md-10 col-md-offset-1 panel panel-default">
<header class="header">
<div class="meta">
<span class="date">
<span class="month">8</span>
<span class="day">18</span>
</span>
</div>
<h3 class="title">
<a href="/2016/8/18/golang-http-router.html">Golang学习笔记 - 标准库'net/http'的简析及自制简单路由框架</a>
</h3>
</header>
<section class="brief"><blockquote>
<p>还是在继续学习Go的路上,曾经在使用PHP的时候吃过过度依赖框架的亏。现在学习Go的时候决定先打好基础,从标准库学起走。</p>
</blockquote>
<h2 id="源码分析">源码分析</h2>
<p>我们知道最简单的建立http服务器代码基本上都是这样的:</p>
<pre><code class="language-go">http.HandleFunc('/', func(w http.ResponseWriter, r *http.Request){
fmt.Fprint(w, "Hello world")
})
http.ListenAndServe(":8080", nil)
</code></pre>
<p>这样就成功的建立了一个监听 <code>8080</code> 端口的http服务器,当访问的时候输出 <code>Hello world</code></p>
<p>我们顺藤摸瓜来看看 <code>HandleFunc</code> 做了些什么事:</p>
<pre><code class="language-go">func HandleFunc(pattern string, handler func(ResponseWriter, *Request)) {
DefaultServeMux.HandleFunc(pattern, handler)
}
</code></pre>
</section>
<aside class="aside clearfix">
<a class="btn btn-primary btn-lg pull-right" href="/2016/8/18/golang-http-router.html">继续阅读</a>
</aside>
</div>
</div>
</article>
<article class="article">
<div class="row">
<div class="col-md-10 col-md-offset-1 panel panel-default">
<header class="header">
<div class="meta">
<span class="date">
<span class="month">8</span>
<span class="day">3</span>
</span>
</div>
<h3 class="title">
<a href="/2016/8/3/golang-tcp-chat-room.html">Go写的简单TCP聊天室示例</a>
</h3>
</header>
<section class="brief"><p>最近学习GO,写了一个聊天室来加深对 <code>net</code> 包和多线程的理解。</p>
<p>期间也遇到了一些小问题,比如 <code>scan</code> 如何读取一整行(包括空格)等。总的来说个人感觉 <code>Go</code> 还是一门很年轻的语言,资料、技巧上面还需要时间的积累。</p>
<p>不过,我已入坑…..</p>
<h2 id="github">GitHub</h2>
<p><a href="https://github.com/TargetLiu/golang-chat">GitHub地址</a></p>
<h2 id="介绍">介绍</h2>
<p>一个简单的基于GO语言的聊天室示例,参考了网上许多类似代码。代码有简单注释。</p>
<p>单执行文件,通过命令的方式选择启动服务端监听还是客户端连接。</p>
<p>功能:客户端昵称、服务端消息、服务端踢人命令。</p>
</section>
<aside class="aside clearfix">
<a class="btn btn-primary btn-lg pull-right" href="/2016/8/3/golang-tcp-chat-room.html">继续阅读</a>
</aside>
</div>
</div>
</article>
<div class="article-pager text-center">
<a class="btn btn-lg btn-info" href="/posts/2.html">以前的</a>
</div>
</div>
</div>
</section>
<footer id="footer">
<div class="container text-center">
<p>© 2015 TargetLiu.
<a href="http://creativecommons.org/licenses/by/3.0/">Some rights reserved </a> |
<a href="/feed.xml">Feed</a> |
<a href="/sitemap.xml">Sitemap</a>
</p>
<p>Powered by <a href="https://github.com/go-xiaohei/pugo">PuGo 0.10.10 (beta)</a>. Theme by Default.
</p>
<script>
var _hmt = _hmt || [];
(function() {
var hm = document.createElement("script");
hm.src = "//hm.baidu.com/hm.js?7c23b90cc9b96f4c9bc060ad11086ec1";
var s = document.getElementsByTagName("script")[0];
s.parentNode.insertBefore(hm, s);
})();
</script>
</div>
</footer>
<script src="/js/jquery-2.1.4.min.js"></script>
<script src="/js/bootstrap.min.js"></script>
<script src="/js/prism.min.js"></script>
<script>
$(document).ready(function () {
$("pre code").addClass("line-numbers")
});
</script>
</body>
</html>