-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathatom.xml
314 lines (175 loc) · 44.4 KB
/
atom.xml
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
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
<title>Silver Chan</title>
<subtitle>传银的博客</subtitle>
<link href="/atom.xml" rel="self"/>
<link href="http://chenchuanyin.github.io/"/>
<updated>2018-04-04T07:17:05.249Z</updated>
<id>http://chenchuanyin.github.io/</id>
<author>
<name>chen chuanyin</name>
</author>
<generator uri="http://hexo.io/">Hexo</generator>
<entry>
<title>几个优雅的C++ STL算法代码</title>
<link href="http://chenchuanyin.github.io/2018/04/04/%E5%87%A0%E4%B8%AA%E4%BC%98%E9%9B%85C++%20STL%E7%AE%97%E6%B3%95%E4%BE%8B%E5%AD%90/"/>
<id>http://chenchuanyin.github.io/2018/04/04/几个优雅C++ STL算法例子/</id>
<published>2018-04-04T06:52:37.694Z</published>
<updated>2018-04-04T07:17:05.249Z</updated>
<content type="html"><![CDATA[<blockquote><p>几个使用C++11的算法例子,收藏下。</p></blockquote><h2 id="插入排序-Insertion-Sort"><a href="#插入排序-Insertion-Sort" class="headerlink" title="插入排序(Insertion Sort)"></a>插入排序(Insertion Sort)</h2><p>代码:<br><figure class="highlight cpp"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div></pre></td><td class="code"><pre><div class="line"><span class="keyword">template</span> <<span class="class"><span class="keyword">class</span> <span class="title">FwdIt</span>> <span class="title">void</span> <span class="title">insertSort</span>(<span class="title">FwdIt</span> <span class="title">first</span>, <span class="title">FwdIt</span> <span class="title">last</span>) {</span></div><div class="line"> <span class="keyword">for</span> (<span class="keyword">auto</span> i = first; i != last; ++i)</div><div class="line"> <span class="built_in">std</span>::rotate(<span class="built_in">std</span>::upper_bound(first, i, *i), i, <span class="built_in">std</span>::next(i));</div><div class="line">}</div></pre></td></tr></table></figure></p><h2 id="快速排序-Quick-Sort"><a href="#快速排序-Quick-Sort" class="headerlink" title="快速排序(Quick Sort)"></a>快速排序(Quick Sort)</h2><p>代码:<br><figure class="highlight cpp"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div></pre></td><td class="code"><pre><div class="line"><span class="keyword">template</span> <<span class="class"><span class="keyword">class</span> <span class="title">FwdIt</span>, <span class="title">class</span> <span class="title">Compare</span> = <span class="title">std</span>:</span>:less<<span class="keyword">typename</span> FwdIt::value_type>></div><div class="line"><span class="function"><span class="keyword">void</span> <span class="title">quickSort</span><span class="params">(FwdIt first, FwdIt last, Compare cmp = Compare{})</span> </span>{</div><div class="line"> <span class="keyword">auto</span> <span class="keyword">const</span> N = <span class="built_in">std</span>::distance(first, last);</div><div class="line"> <span class="keyword">if</span> (N <= <span class="number">1</span>)</div><div class="line"> <span class="keyword">return</span>;</div><div class="line"> <span class="keyword">auto</span> <span class="keyword">const</span> pivot = <span class="built_in">std</span>::next(first, N / <span class="number">2</span>);</div><div class="line"> <span class="built_in">std</span>::nth_element(first, pivot, last, cmp);</div><div class="line"> quickSort(first, pivot, cmp);</div><div class="line"> quickSort(pivot, last, cmp);</div><div class="line">}</div></pre></td></tr></table></figure></p>]]></content>
<summary type="html">
<blockquote>
<p>几个使用C++11的算法例子,收藏下。</p>
</blockquote>
<h2 id="插入排序-Insertion-Sort"><a href="#插入排序-Insertion-Sort" class="headerlink" title="
</summary>
<category term="学习" scheme="http://chenchuanyin.github.io/categories/%E5%AD%A6%E4%B9%A0/"/>
<category term="cpp" scheme="http://chenchuanyin.github.io/tags/cpp/"/>
</entry>
<entry>
<title>《TCP IP高效编程————改造网络程序的44个技巧》学习记录</title>
<link href="http://chenchuanyin.github.io/2018/01/15/%E3%80%8ATCP%20IP%E9%AB%98%E6%95%88%E7%BC%96%E7%A8%8B%E2%80%94%E2%80%94%E2%80%94%E2%80%94%E6%94%B9%E9%80%A0%E7%BD%91%E7%BB%9C%E7%A8%8B%E5%BA%8F%E7%9A%8444%E4%B8%AA%E6%8A%80%E5%B7%A7%E3%80%8B%E5%AD%A6%E4%B9%A0%E8%AE%B0%E5%BD%95/"/>
<id>http://chenchuanyin.github.io/2018/01/15/《TCP IP高效编程————改造网络程序的44个技巧》学习记录/</id>
<published>2018-01-15T10:31:03.047Z</published>
<updated>2018-01-15T10:32:47.418Z</updated>
<content type="html"><![CDATA[<ul><li><p>技巧1:理解面向链接和无连接协议之间的区别</p><ul><li>对于无连接协议来说,每个分组的处理都独立于所有其他分组,而对于面向连接的协议来说,协议实现维护了与后继分组有关的状态信息。</li><li>对TCP来说,连接完全是想象的,它是由端点所记忆的状态组成的, 并不存在“物理”连接。</li></ul></li><li><p>技巧2:理解子网和CIDR的概念</p><ul><li>A、B、C、D、E类网络,网络ID和主机ID</li><li>子网划分</li><li>CIDR——Classless Inter Domain Routing,无类别域间路由</li></ul></li><li><p>技巧3:理解私有地址和NAT</p><ul><li>10.0.0.0-10.255.255.255(前缀10/8)、172.16.0.0-172.31.255.255(前缀172.16/12)、192.168.0.0-192.168.255.255(前缀192.168/16)</li><li>NAT——Network Address Translation,网络地址翻译</li><li>PAT——Port Address Translation,端口地址转换</li></ul></li><li><p>技巧4:开发并使用应用程序“框架”</p><ul><li>TCP服务端:socket->bind->listen->accept</li><li>TCP客户端:socket->connect</li><li>UDP服务端:socket->bind</li><li>UDP客户端:socket</li></ul></li><li><p>技巧5:套接字接口比XTI/TLI更好用</p></li><li><p>技巧6:记住,TCP是一种流协议</p><ul><li>TCP是一种流协议,数据以字节流的形式传递给接收者的,没有固有的“报文”或“报文边界”的概念</li></ul></li><li><p>技巧7:不要低估TCP的性能</p></li><li><p>技巧8:避免重新编写TCP</p></li><li><p>技巧9:要认识到TCP是一个可靠的,但并不绝对可靠的协议</p></li><li><p>技巧10:记住,TCP/IP不是轮询的</p><ul><li>TCP没有提供将连接丢失即时通知给应用程序的方法</li><li>保持活跃(keep-alive)</li><li>心跳信号(epoll, pthread)</li></ul></li><li><p>技巧11:提防对等尸体的不友好动作</p></li><li><p>技巧12:成功的LAN策略不一定能推广到WAN中</p></li><li><p>技巧13:了解协议是怎样工作的</p><ul><li>RFC是TCP/IP的官方规范</li></ul></li><li><p>技巧14:不要把OSI七层参考模型太当回事</p><ul><li>OSI和TCP/IP</li></ul></li><li><p>技巧15:理解TCP的写操作</p><ul><li>从应用程序的角度来看,最好把写操作当作是一项将数据从用户空间拷贝到内核发送缓冲区,然后就返回的操作。</li><li>如果发送端应用程序崩溃了,TCP会继续尝试着将数据传递给对等实体。</li></ul></li><li><p>技巧16:理解TCP的有序释放操作</p><ul><li>有序释放是在确保没有数据丢失的情况下拆除n连接的一个过程。</li><li>shutdown与close的区别</li></ul></li></ul><ul><li><p>技巧17:考虑用inetd来装载应用程序</p></li><li><p>技巧18:考虑用tcpmux为服务器“分配”知名端口</p></li><li><p>技巧19:考虑使用两条TCP连接</p></li><li><p>技巧20:使应用程序成为事件驱动的(1)</p></li><li><p>技巧21:使应用程序成为事件驱动的(2)</p></li><li><p>技巧22:不要用TIME-WAIT暗杀来关闭一条连接</p><ul><li>通常只有一端——主动关闭的那一端会进入TIME-WAIT状态</li><li>使用TIME-WAIT状态主要由两个目的:<br>1) 维护连接状态,以防主动关闭连接的那段发送的最后一条ACK丢失后造成另一端重新发送FIN信号<br>2) 为耗尽网络中所有此连接的“走失段”提供时间</li></ul></li><li><p>技巧23:服务器应该设置SO_REUSERADDR选项</p></li><li><p>技巧24:可能的话,使用一个大规模的写操作,而不是多个小规模的写操作</p><ul><li>上下文的切换耗时</li><li>Nagle算法影响</li></ul></li><li><p>技巧25:理解如何使connect调用超时</p></li><li><p>技巧26:避免数据复制</p></li><li><p>技巧27:使用前将结构sockaddr_in清零</p></li><li><p>技巧28:不要忘记字节的“性别”</p></li><li><p>技巧29:不要将IP地址或端口号硬编入应用程序中</p></li><li><p>技巧30:理解已连接的UDP套接字</p><ul><li>connect操作</li></ul></li><li><p>技巧31:记住,并不是所有程序都是用C编写的</p></li><li><p>技巧32:理解缓冲区长度带来的影响</p></li><li><p>技巧33:熟悉ping使用工具</p><ul><li>ping没有使用TCP或UDP,因此没有相关的知名端口,使用ICMP</li></ul></li><li><p>技巧34:学习使用tcpdump或类似的工具</p></li><li><p>技巧35:学习使用traceroute</p><ul><li>traceroute是诊断网络问题,学习网络路由以及探查网络拓扑的非常游泳的工具。</li></ul></li><li><p>技巧36:学习使用ttcp</p></li><li><p>技巧37:学习使用lsof</p></li><li><p>技巧38:学习使用netstat</p></li><li><p>技巧39:学习使用系统中的调用追踪工具(strace)</p></li><li><p>技巧40:构建并使用捕获ICMP报文的工具</p></li><li><p>技巧41:读Stevens的书</p></li><li><p>技巧42:阅读代码</p></li><li><p>技巧43:访问RFC编辑者的页面</p></li><li><p>技巧44:经常访问新闻组</p></li></ul>]]></content>
<summary type="html">
<ul>
<li><p>技巧1:理解面向链接和无连接协议之间的区别</p>
<ul>
<li>对于无连接协议来说,每个分组的处理都独立于所有其他分组,而对于面向连接的协议来说,协议实现维护了与后继分组有关的状态信息。</li>
<li>对TCP来说,连接完全是想象的,它是由端点所
</summary>
<category term="学习" scheme="http://chenchuanyin.github.io/categories/%E5%AD%A6%E4%B9%A0/"/>
<category term="network" scheme="http://chenchuanyin.github.io/tags/network/"/>
</entry>
<entry>
<title>cpp目录结构及工具相关的一些工程经验总结</title>
<link href="http://chenchuanyin.github.io/2018/01/15/cpp%E7%9B%AE%E5%BD%95%E7%BB%93%E6%9E%84%E5%8F%8A%E5%B7%A5%E5%85%B7%E7%9B%B8%E5%85%B3%E7%9A%84%E4%B8%80%E4%BA%9B%E5%B7%A5%E7%A8%8B%E7%BB%8F%E9%AA%8C/"/>
<id>http://chenchuanyin.github.io/2018/01/15/cpp目录结构及工具相关的一些工程经验/</id>
<published>2018-01-15T03:50:50.390Z</published>
<updated>2018-01-15T06:19:44.575Z</updated>
<content type="html"><![CDATA[<blockquote><p>在开发Linux环境下cpp组件时,自己形成了一套模式框架,对于常规项目开发可以方便套用。</p></blockquote><h3 id="工具"><a href="#工具" class="headerlink" title="工具"></a>工具</h3><ul><li>编辑器:使用emacs,配置文件使用spacemacs</li><li>自动补全:使用spacemacs的两个layer:<code>auto-complete</code>、<code>c/c++</code>。</li></ul><figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div></pre></td><td class="code"><pre><div class="line">(auto-completion :variables</div><div class="line"> auto-completion-enable-sort-by-usage t)</div></pre></td></tr></table></figure><figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div></pre></td><td class="code"><pre><div class="line">(c-c++ :variables</div><div class="line"> c-c++-default-mode-for-headers 'c++-mode</div><div class="line"> c-c++-enable-clang-support t</div><div class="line"> c-c++-enable-clang-format-on-save t</div><div class="line"> c-c++-enable-google-newline t</div><div class="line"> c-c++-enable-google-style t)</div></pre></td></tr></table></figure><p>同时,针对项目来配置.clang_complete文件。</p><figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div></pre></td><td class="code"><pre><div class="line">-Wall</div><div class="line">-std=c++11</div><div class="line">-Wc++-compat</div><div class="line">-I.</div><div class="line">-Ithird_party/googletest/include</div><div class="line">-Ithird_party/benchmark/include</div><div class="line">-Ithird_party/googletest</div><div class="line">-Ithird_party/abseil-cpp</div></pre></td></tr></table></figure><ul><li>自动跳转工具:使用ctags,配置spacemacs的<code>ctags</code> layer</li></ul><figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">(gtags :disabled-for go clojure emacs-lisp javascript latex python shell-scripts)</div></pre></td></tr></table></figure><ul><li>代码格式化工具:使用clang-format,配置.clang-format文件</li><li>调试工具:GDB</li><li>项目代码编译管理工具:cmake</li><li>脚本工具:makefile</li></ul><h3 id="目录结构"><a href="#目录结构" class="headerlink" title="目录结构"></a>目录结构</h3><figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div><div class="line">15</div><div class="line">16</div><div class="line">17</div></pre></td><td class="code"><pre><div class="line">.</div><div class="line">├── CMakeLists.txt :cmake工程文件</div><div class="line">├── Makefile :构建管理文件</div><div class="line">├── .clang_complete :自动补全设置文件</div><div class="line">├── doc :文档目录</div><div class="line"> ├── README.md</div><div class="line">├── out :构建编译编译目录</div><div class="line">├── src :项目代码目录</div><div class="line">│ ├── CMakeLists.txt</div><div class="line">│ ├── .clang-format :代码格式化设置文件</div><div class="line">└── third_party :第三方依赖目录</div><div class="line"> ├── abseil-cpp</div><div class="line"> ├── benchmark</div><div class="line"> ├── cctz</div><div class="line"> ├── gflags</div><div class="line"> ├── glog</div><div class="line"> └── googletest</div></pre></td></tr></table></figure><h3 id="常用的第三方库"><a href="#常用的第三方库" class="headerlink" title="常用的第三方库"></a>常用的第三方库</h3><ul><li><a href="https://github.com/gflags/gflags" target="_blank" rel="noopener">gflags</a>,命令行flag设置,支持cmake</li><li><a href="https://github.com/google/googletest" target="_blank" rel="noopener">googletest</a>,单元测试,支持cmake</li><li><a href="https://github.com/google/glog" target="_blank" rel="noopener">glog</a>,日志打印,支持cmake</li><li><a href="https://github.com/google/benchmark" target="_blank" rel="noopener">benchmark</a>,函数性能测试工具,支持cmake</li><li><a href="https://github.com/abseil/abseil-cpp" target="_blank" rel="noopener">abseil-cpp</a>,common库,支持cmake</li></ul>]]></content>
<summary type="html">
<blockquote>
<p>在开发Linux环境下cpp组件时,自己形成了一套模式框架,对于常规项目开发可以方便套用。</p>
</blockquote>
<h3 id="工具"><a href="#工具" class="headerlink" title="工具"></a>
</summary>
<category term="学习" scheme="http://chenchuanyin.github.io/categories/%E5%AD%A6%E4%B9%A0/"/>
<category term="cpp" scheme="http://chenchuanyin.github.io/tags/cpp/"/>
</entry>
<entry>
<title>网络上的一些学习资料列表</title>
<link href="http://chenchuanyin.github.io/2018/01/08/%E7%BD%91%E7%BB%9C%E4%B8%8A%E7%9A%84%E4%B8%80%E4%BA%9B%E5%AD%A6%E4%B9%A0%E8%B5%84%E6%96%99%E5%88%97%E8%A1%A8/"/>
<id>http://chenchuanyin.github.io/2018/01/08/网络上的一些学习资料列表/</id>
<published>2018-01-08T07:13:29.216Z</published>
<updated>2018-01-23T05:52:58.019Z</updated>
<content type="html"><![CDATA[<p>GitHub</p><ul><li><a href="https://www.github.com/mymmsc/books" target="_blank" rel="noopener">mymmsc/books</a>,存储了一些经典书籍,包括《深度学习》,《TCP/IP详解》。</li><li><a href="https://github.com/donnemartin/system-design-primer" target="_blank" rel="noopener">donnemartin/system-design-primer</a>,系统设计。</li><li><a href="https://github.com/isocpp/CppCoreGuidelines" target="_blank" rel="noopener">isocpp/CppCoreGuidelines</a>,C++入门指南,提供了一些使用技巧和使用规范。</li><li><a href="https://github.com/qyuhen/book" target="_blank" rel="noopener">qyuhen/book</a>, 存储了一些C、Go、Python相关的书籍。</li></ul>]]></content>
<summary type="html">
<p>GitHub</p>
<ul>
<li><a href="https://www.github.com/mymmsc/books" target="_blank" rel="noopener">mymmsc/books</a>,存储了一些经典书籍,包括《深度学习》,《TCP
</summary>
<category term="学习" scheme="http://chenchuanyin.github.io/categories/%E5%AD%A6%E4%B9%A0/"/>
<category term="resource" scheme="http://chenchuanyin.github.io/tags/resource/"/>
</entry>
<entry>
<title>golang目录结构及工具相关的一些工程经验总结</title>
<link href="http://chenchuanyin.github.io/2017/11/16/golang%E7%9B%AE%E5%BD%95%E7%BB%93%E6%9E%84%E5%8F%8A%E5%B7%A5%E5%85%B7%E7%9B%B8%E5%85%B3%E7%9A%84%E4%B8%80%E4%BA%9B%E5%B7%A5%E7%A8%8B%E7%BB%8F%E9%AA%8C%E6%80%BB%E7%BB%93/"/>
<id>http://chenchuanyin.github.io/2017/11/16/golang目录结构及工具相关的一些工程经验总结/</id>
<published>2017-11-16T03:41:15.289Z</published>
<updated>2018-01-15T06:12:25.406Z</updated>
<content type="html"><![CDATA[<blockquote><p>在开发golang组件的时候需要版本管理及组件管理,自己形成了一套模式框架,对于常规项目开发可以方便套用。</p></blockquote><h3 id="工具"><a href="#工具" class="headerlink" title="工具"></a>工具</h3><ul><li>使用glide工具进行第三方版本包管理,不用依赖环境变量$GOPATH</li><li>使用makefile作为脚本工具,管理下载三方包,构建,打包</li><li>使用emacs+gocode来进行代码编写</li></ul><h3 id="目录结构"><a href="#目录结构" class="headerlink" title="目录结构"></a>目录结构</h3><figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div></pre></td><td class="code"><pre><div class="line">.</div><div class="line">├── Makefile :脚本</div><div class="line">├── bin :组件产物输出目录,不用进行版本管理</div><div class="line">├── conf :配置脚本</div><div class="line">├── glide.lock :glide生成的文件</div><div class="line">├── glide.yaml :glide生成的文件</div><div class="line">├── pkg :gocode需要根据这个目录.a文件进行自动补全</div><div class="line">├── src :源代码目录</div><div class="line">└── vendor :glide下载的三方代码放置在这个目录,不用进行版本管理</div></pre></td></tr></table></figure><ul><li>Makefile的模板如下:</li></ul><figure class="highlight makefile"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div><div class="line">15</div><div class="line">16</div><div class="line">17</div><div class="line">18</div><div class="line">19</div><div class="line">20</div><div class="line">21</div><div class="line">22</div><div class="line">23</div><div class="line">24</div><div class="line">25</div><div class="line">26</div><div class="line">27</div><div class="line">28</div><div class="line">29</div><div class="line">30</div><div class="line">31</div><div class="line">32</div><div class="line">33</div><div class="line">34</div><div class="line">35</div><div class="line">36</div><div class="line">37</div><div class="line">38</div><div class="line">39</div><div class="line">40</div><div class="line">41</div></pre></td><td class="code"><pre><div class="line">PWD := <span class="variable">$(<span class="built_in">shell</span> pwd)</span></div><div class="line">GO := go</div><div class="line">GLIDE := glide</div><div class="line">GOCODE := gocode</div><div class="line">TARGET := IATOpenAPI</div><div class="line">VENDOR := ${PWD}/vendor</div><div class="line">GOPATH := ${PWD}/gopath</div><div class="line">OUT := ${PWD}/bin/</div><div class="line">OUT_TARGET := ${PWD}/bin/${TARGET}</div><div class="line"></div><div class="line"><span class="comment">#批量工具</span></div><div class="line"><span class="section">all: deps build package</span></div><div class="line"></div><div class="line"><span class="comment">#生成glide.yaml文件</span></div><div class="line"><span class="section">init:</span></div><div class="line">rm -f glide.yaml</div><div class="line"><span class="keyword">export</span> GOPATH=${PWD} && ${GLIDE} init</div><div class="line"></div><div class="line"><span class="comment">#下载三方依赖包</span></div><div class="line"><span class="section">deps:</span></div><div class="line">rm -rf ${GOPATH}/src</div><div class="line">mkdir -p ${GOPATH}/src</div><div class="line"><span class="keyword">export</span> GOPATH=${PWD} && ${GLIDE} install</div><div class="line">ln -s ${VENDOR}/* ${GOPATH}/src/</div><div class="line"></div><div class="line"><span class="comment">#构建</span></div><div class="line"><span class="section">build:</span></div><div class="line"><span class="keyword">export</span> GOPATH=${PWD}:${GOPATH} && ${GO} build -o ${OUT_TARGET} ${PWD}/src/main.go</div><div class="line"></div><div class="line"><span class="comment">#清理</span></div><div class="line"><span class="section">clean:</span></div><div class="line">rm -fr ${OUT}/*</div><div class="line"></div><div class="line"><span class="comment">#打包</span></div><div class="line"><span class="section">package:</span></div><div class="line">cd ${OUT} && tar cvzf mock.tar.gz ${TARGET} config.yaml</div><div class="line"></div><div class="line"><span class="comment">#gocode需要依赖环境变量$GOPATH来选中pkg,因此通过使用脚本来启动gocode</span></div><div class="line"><span class="section">gocode:</span></div><div class="line">${GOCODE} close</div><div class="line">GOPATH=${PWD} ${GOCODE} -s &</div></pre></td></tr></table></figure><ul><li><p>glide支持三方包管理,但国内经常访问不了golang.org等网站,需要使用<a href="https://chenchuanyin.github.io/2017/11/07/%E4%BF%AE%E5%A4%8DGO%E5%8C%85%E7%AE%A1%E7%90%86%E5%B7%A5%E5%85%B7GLIDE%E4%B8%8D%E8%83%BD%E8%AE%BF%E9%97%AEgolang.org%E7%9A%84%E6%9B%BF%E4%BB%A3%E6%96%B9%E6%A1%88/">镜像或代理</a>的方式访问。</p></li><li><p>emacs配置go编码环境<br>我是emacs重度使用者,coding的时候会优先选择emacs。 经过一段时间的探索,常规项目可以通过emacs下编写go代码,自动补全。</p></li></ul><ol><li>自动补全配置:spacemacs打开两个layer:go,autocomplete;gocode使用到了$GOPATH,需要根据项目目录来配置$GOPATH,配置启动方式我放在makefile脚本里。</li><li>代码跳转配置:go-guru使用到了环境变量$GOPATH,因此根据项目目录来配置$GOPATH,配置方式可以通过打开emacs后<code>M-x setenv <RET> GOPATH <RET> GO_DIRS</code>来设置。</li></ol>]]></content>
<summary type="html">
<blockquote>
<p>在开发golang组件的时候需要版本管理及组件管理,自己形成了一套模式框架,对于常规项目开发可以方便套用。</p>
</blockquote>
<h3 id="工具"><a href="#工具" class="headerlink" title="
</summary>
<category term="学习" scheme="http://chenchuanyin.github.io/categories/%E5%AD%A6%E4%B9%A0/"/>
<category term="golang" scheme="http://chenchuanyin.github.io/tags/golang/"/>
</entry>
<entry>
<title>Makefile中重复创建目录提示错误的解决方案</title>
<link href="http://chenchuanyin.github.io/2017/11/13/Makefile%E4%B8%AD%E5%88%9B%E5%BB%BA%E5%B7%B2%E5%AD%98%E5%9C%A8%E7%9B%AE%E5%BD%95%E6%8F%90%E7%A4%BA%E9%94%99%E8%AF%AF%E7%9A%84%E8%A7%A3%E5%86%B3%E6%96%B9%E6%A1%88/"/>
<id>http://chenchuanyin.github.io/2017/11/13/Makefile中创建已存在目录提示错误的解决方案/</id>
<published>2017-11-13T11:55:56.331Z</published>
<updated>2017-11-13T11:57:14.874Z</updated>
<content type="html"><![CDATA[<p>如题,我们经常需要在构建脚本Makefile中创建目录。例如下面一段脚本:<br><figure class="highlight makefile"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div></pre></td><td class="code"><pre><div class="line"><span class="section">deps:</span></div><div class="line">git submodule update --init --recursive</div><div class="line">mkdir -p out</div><div class="line"></div><div class="line"><span class="section">build:</span></div><div class="line">cd out && cmake -DBUILD_TESTING=OFF ../ && make -j8</div><div class="line"></div><div class="line"><span class="section">package: deps build</span></div><div class="line"></div><div class="line"><span class="section">clean:</span></div><div class="line">rm -rf out/*</div></pre></td></tr></table></figure></p><p>在<code>out</code>目录已存在后执行<code>make deps</code>,会出现以下错误:<br><figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div></pre></td><td class="code"><pre><div class="line">➜ cpp-demo git:(master) ✗ make deps</div><div class="line">git submodule update --init --recursive</div><div class="line">mkdir out</div><div class="line">mkdir: out: File exists</div><div class="line">make: *** [deps] Error 1</div><div class="line">➜ cpp-demo git:(master)</div></pre></td></tr></table></figure></p><p>为了消除这个错误提示,我们可以在<code>mkdir out</code>加入参数<code>-p</code>:<code>mkdir -p out</code>。<br>这样就不会提示错误了。</p>]]></content>
<summary type="html">
<p>如题,我们经常需要在构建脚本Makefile中创建目录。例如下面一段脚本:<br><figure class="highlight makefile"><table><tr><td class="gutter"><pre><div class="line">1</div><
</summary>
<category term="学习" scheme="http://chenchuanyin.github.io/categories/%E5%AD%A6%E4%B9%A0/"/>
<category term="makefile" scheme="http://chenchuanyin.github.io/tags/makefile/"/>
</entry>
<entry>
<title>pip国内下载失败超时等问题的解决方案</title>
<link href="http://chenchuanyin.github.io/2017/11/10/pip%E4%B8%8B%E8%BD%BD%E8%B6%85%E6%97%B6%E8%A7%A3%E5%86%B3%E6%96%B9%E6%A1%88/"/>
<id>http://chenchuanyin.github.io/2017/11/10/pip下载超时解决方案/</id>
<published>2017-11-10T09:08:06.646Z</published>
<updated>2017-11-13T11:47:38.973Z</updated>
<content type="html"><![CDATA[<p>可以通过国内开源镜像来下载python的库,操作步骤如下:<br><figure class="highlight shell"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div></pre></td><td class="code"><pre><div class="line">mkdir ~/.pip</div><div class="line">vim ~/.pip/pip.conf</div></pre></td></tr></table></figure></p><p>pip.conf内容如下:<br><figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div></pre></td><td class="code"><pre><div class="line">[global]</div><div class="line">index-url = https://pypi.mirrors.ustc.edu.cn/simple</div></pre></td></tr></table></figure></p>]]></content>
<summary type="html">
<p>可以通过国内开源镜像来下载python的库,操作步骤如下:<br><figure class="highlight shell"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="
</summary>
<category term="学习" scheme="http://chenchuanyin.github.io/categories/%E5%AD%A6%E4%B9%A0/"/>
<category term="python" scheme="http://chenchuanyin.github.io/tags/python/"/>
</entry>
<entry>
<title>交叉编译工具远程调试小结</title>
<link href="http://chenchuanyin.github.io/2017/11/08/%E4%BA%A4%E5%8F%89%E7%BC%96%E8%AF%91%E5%B7%A5%E5%85%B7%E8%BF%9C%E7%A8%8B%E8%B0%83%E8%AF%95%E6%80%BB%E7%BB%93/"/>
<id>http://chenchuanyin.github.io/2017/11/08/交叉编译工具远程调试总结/</id>
<published>2017-11-08T08:48:08.634Z</published>
<updated>2017-11-21T07:55:44.631Z</updated>
<content type="html"><![CDATA[<blockquote><p>我们在开发ARM板子C/C++项目过程中,我们会需要查找定位BUG,一种方式是通过网络发送日志;另一种方式是通过调试方式,而很多板子没有执行GDB性能,<br>因此我们需要远程调试的方式来进行调试。现在总结下项目中使用的两种方式。</p></blockquote><h2 id="调试可执行程序"><a href="#调试可执行程序" class="headerlink" title="调试可执行程序"></a>调试可执行程序</h2><ol><li>环境准备:一台装有交叉编译工具链的机器A,一般是linux操作系统的机器;被调试程序的机器B上装有gdbserver</li><li>首先拷贝调试所需要的库及可执行程序到机器A上(【注】需要no-strip,带debug信息的库和可执行程序,可以通过<code>file</code>或<code>info shared</code>查看)</li><li><p>A机器准备gdb启动脚本.gdbinit,模板类似于:</p><figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div></pre></td><td class="code"><pre><div class="line">set solid-search-path [调试库目录]</div><div class="line">file [需要调试可执行程序]</div><div class="line">target remote [调试可执行程序的机器ip]:[gdbserver暴露出来的端口号]</div></pre></td></tr></table></figure></li><li><p>B机器准备gdbserver启动脚本,模板类似于:</p><figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">gdbserver :[暴露出来的端口号] 可执行程序</div></pre></td></tr></table></figure></li><li><p>A机器gdb启动后,紧接着启动B机器脚本;这个时候A机器的gdb窗口进入可调试状态,我们可以设置断点或者查看线程栈信息,输入<code>c</code>程序继续执行,<code>Ctrl-c</code>进入打断状态</p></li></ol><h2 id="调试正在运行的进程"><a href="#调试正在运行的进程" class="headerlink" title="调试正在运行的进程"></a>调试正在运行的进程</h2><ol><li>调试环境、拷贝相关库及可执行程序、A机器准备的gdb脚本和调试可执行程序相同,只是通过attach的方式来调试</li><li>A机器gdb启动后,紧接着B机器执行如下命令:<figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">gdbserver :[暴露出来的端口号] --attach [进程ID]</div></pre></td></tr></table></figure></li></ol><p>这个时候A机器的gdb窗口进入可调试状态。</p><p>这两种方式各有各的使用场景:<strong>调试可执行程序</strong>适合调试进程启动时候出现的BUG,<strong>调试正在运行的进程</strong>适合调试进程BUG已经出现的场景。</p>]]></content>
<summary type="html">
<blockquote>
<p>我们在开发ARM板子C/C++项目过程中,我们会需要查找定位BUG,一种方式是通过网络发送日志;另一种方式是通过调试方式,而很多板子没有执行GDB性能,<br>因此我们需要远程调试的方式来进行调试。现在总结下项目中使用的两种方式。</p>
</bl
</summary>
<category term="学习" scheme="http://chenchuanyin.github.io/categories/%E5%AD%A6%E4%B9%A0/"/>
<category term="gdb" scheme="http://chenchuanyin.github.io/tags/gdb/"/>
</entry>
<entry>
<title>git status中文显示不对问题修复</title>
<link href="http://chenchuanyin.github.io/2017/11/07/git%20status%E4%B8%AD%E6%96%87%E6%98%BE%E7%A4%BA%E4%B8%8D%E5%87%BA%E6%9D%A5%E9%97%AE%E9%A2%98%E4%BF%AE%E5%A4%8D/"/>
<id>http://chenchuanyin.github.io/2017/11/07/git status中文显示不出来问题修复/</id>
<published>2017-11-07T09:12:17.185Z</published>
<updated>2017-11-09T02:09:40.072Z</updated>
<content type="html"><![CDATA[<p>如题,我的mac上git status显示<br><figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div><div class="line">15</div><div class="line">16</div><div class="line">17</div><div class="line">18</div><div class="line">19</div><div class="line">20</div><div class="line">21</div><div class="line">22</div><div class="line">23</div><div class="line">24</div></pre></td><td class="code"><pre><div class="line">➜ hexo git:(master) ✗ gst</div><div class="line">On branch master</div><div class="line">Changes not staged for commit:</div><div class="line"> (use "git add/rm <file>..." to update what will be committed)</div><div class="line"> (use "git checkout -- <file>..." to discard changes in working directory)</div><div class="line"> (commit or discard the untracked or modified content in submodules)</div><div class="line"></div><div class="line">modified: _config.yml</div><div class="line">modified: package-lock.json</div><div class="line">modified: package.json</div><div class="line">deleted: source/_posts/hello-world.md</div><div class="line">deleted: "source/_posts/\346\265\213\350\257\225\344\275\277\347\224\250-md.md"</div><div class="line">deleted: "source/_posts/\347\254\254\344\272\214\344\270\252\346\265\213\350\257\225.md"</div><div class="line">modified: themes/maupassant (modified content)</div><div class="line">modified: themes/next (untracked content)</div><div class="line"></div><div class="line">Untracked files:</div><div class="line"> (use "git add <file>..." to include in what will be committed)</div><div class="line"></div><div class="line">"source/_posts/emacs\346\217\222\345\205\245\345\275\223\345\211\215\346\227\266\351\227\264\346\210\263.md"</div><div class="line">"source/_posts/\344\277\256\345\244\215GO\345\214\205\347\256\241\347\220\206\345\267\245\345\205\267GLIDE\344\270\215\350\203\275\350\256\277\351\227\256golang.org\347\232\204\346\233\277\344\273\243\346\226\271\346\241\210.md"</div><div class="line">source/about/</div><div class="line"></div><div class="line">no changes added to commit (use "git add" and/or "git commit -a")</div></pre></td></tr></table></figure></p><p>修复方法:<br><figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div></pre></td><td class="code"><pre><div class="line">#不对0x80以上的字符进行quote,解决git status/commit时中文文件名乱码</div><div class="line">git config --global core.quotepath false</div></pre></td></tr></table></figure></p><p>再次git status就显示OK了。<br><figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div><div class="line">15</div><div class="line">16</div><div class="line">17</div><div class="line">18</div><div class="line">19</div><div class="line">20</div><div class="line">21</div><div class="line">22</div><div class="line">23</div><div class="line">24</div></pre></td><td class="code"><pre><div class="line">➜ hexo git:(master) ✗ gst</div><div class="line">On branch master</div><div class="line">Changes not staged for commit:</div><div class="line"> (use "git add/rm <file>..." to update what will be committed)</div><div class="line"> (use "git checkout -- <file>..." to discard changes in working directory)</div><div class="line"> (commit or discard the untracked or modified content in submodules)</div><div class="line"></div><div class="line">modified: _config.yml</div><div class="line">modified: package-lock.json</div><div class="line">modified: package.json</div><div class="line">deleted: source/_posts/hello-world.md</div><div class="line">deleted: source/_posts/测试使用-md.md</div><div class="line">deleted: source/_posts/第二个测试.md</div><div class="line">modified: themes/maupassant (modified content)</div><div class="line">modified: themes/next (untracked content)</div><div class="line"></div><div class="line">Untracked files:</div><div class="line"> (use "git add <file>..." to include in what will be committed)</div><div class="line"></div><div class="line">source/_posts/emacs插入当前时间戳.md</div><div class="line">source/_posts/修复GO包管理工具GLIDE不能访问golang.org的替代方案.md</div><div class="line">source/about/</div><div class="line"></div><div class="line">no changes added to commit (use "git add" and/or "git commit -a")</div></pre></td></tr></table></figure></p>]]></content>
<summary type="html">
<p>如题,我的mac上git status显示<br><figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2<
</summary>
<category term="学习" scheme="http://chenchuanyin.github.io/categories/%E5%AD%A6%E4%B9%A0/"/>
<category term="git" scheme="http://chenchuanyin.github.io/tags/git/"/>
</entry>
<entry>
<title>emacs插入当前时间戳</title>
<link href="http://chenchuanyin.github.io/2017/11/07/emacs%E6%8F%92%E5%85%A5%E5%BD%93%E5%89%8D%E6%97%B6%E9%97%B4%E6%88%B3/"/>
<id>http://chenchuanyin.github.io/2017/11/07/emacs插入当前时间戳/</id>
<published>2017-11-07T08:40:57.503Z</published>
<updated>2017-11-09T02:09:33.499Z</updated>
<content type="html"><![CDATA[<figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">C-u M-! date</div></pre></td></tr></table></figure>]]></content>
<summary type="html">
<figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="lin
</summary>
<category term="学习" scheme="http://chenchuanyin.github.io/categories/%E5%AD%A6%E4%B9%A0/"/>
<category term="emacs" scheme="http://chenchuanyin.github.io/tags/emacs/"/>
</entry>
<entry>
<title>glide不能下载golang.org/x包的替代方案</title>
<link href="http://chenchuanyin.github.io/2017/11/07/%E4%BF%AE%E5%A4%8DGO%E5%8C%85%E7%AE%A1%E7%90%86%E5%B7%A5%E5%85%B7GLIDE%E4%B8%8D%E8%83%BD%E8%AE%BF%E9%97%AEgolang.org%E7%9A%84%E6%9B%BF%E4%BB%A3%E6%96%B9%E6%A1%88/"/>
<id>http://chenchuanyin.github.io/2017/11/07/修复GO包管理工具GLIDE不能访问golang.org的替代方案/</id>
<published>2017-11-07T08:32:09.703Z</published>
<updated>2017-11-14T06:36:50.607Z</updated>
<content type="html"><![CDATA[<blockquote><p>glide是go的一个包管理工具,可以直接扫描工程管理import依赖。而golang.org/x下的包是viper、logrus等github开源包的依赖,国内又不能访问。一个好消息是golang.org/x在github上有镜像(github.com/golang)。下面是我尝试成功的替代方案。</p></blockquote><p>如果go工程中有golang.org/x/net的依赖,就可以在glide.yaml中加入以下配置:<br><figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div></pre></td><td class="code"><pre><div class="line">- package: golang.org/x/net</div><div class="line"> repo: https://github.com:golang/net.git</div><div class="line"> vcs: git</div></pre></td></tr></table></figure></p><p>这样<code>glide install/update</code>就可以从github.com镜像中下载相关库了。</p><p>另一种方式通过代理的方式配置go下载:<br><figure class="highlight shell"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div></pre></td><td class="code"><pre><div class="line"><span class="meta">#</span>127.0.0.1:9999是sock5代理地址</div><div class="line">alias go="http_proxy=socks5://127.0.0.1:9999 https_proxy=socks5://127.0.0.1:9999 go"</div></pre></td></tr></table></figure></p>]]></content>
<summary type="html">
<blockquote>
<p>glide是go的一个包管理工具,可以直接扫描工程管理import依赖。而golang.org/x下的包是viper、logrus等github开源包的依赖,国内又不能访问。一个好消息是golang.org/x在github上有镜像(github.
</summary>
<category term="学习" scheme="http://chenchuanyin.github.io/categories/%E5%AD%A6%E4%B9%A0/"/>
<category term="golang" scheme="http://chenchuanyin.github.io/tags/golang/"/>
<category term="glide" scheme="http://chenchuanyin.github.io/tags/glide/"/>
</entry>
</feed>