PageSourceSearch

https://andrewpqc.github.io/

html andrewpqc.github.io collected 2026-10-03 08:37:24 UTC 37,946 bytes, 1,925 lines download raw bytes

1<!DOCTYPE html>
2
3
4
5  
6
7
8<html class="theme-next pisces use-motion" lang="en">
9<head><meta name="generator" content="Hexo 3.9.0">
10  <meta charset="UTF-8">
11<meta http-equiv="X-UA-Compatible" content="IE=edge">
12<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
13<meta name="theme-color" content="#222">
14
15
16
17
18
19
20
21
22
23<meta http-equiv="Cache-Control" content="no-transform">
24<meta http-equiv="Cache-Control" content="no-siteapp">
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41  
42  
43  <link href="/lib/fancybox/source/jquery.fancybox.css?v=2.1.5" rel="stylesheet" type="text/css">
44
45
46
47
48
49
50
51<link href="/lib/font-awesome/css/font-awesome.min.css?v=4.6.2" rel="stylesheet" type="text/css">
52
53<link href="/css/main.css?v=5.1.4" rel="stylesheet" type="text/css">
54
55
56  <link rel="apple-touch-icon" sizes="180x180" href="/images/apple-touch-icon-next.png?v=5.1.4">
57
58
59  <link rel="icon" type="image/png" sizes="32x32" href="/images/favicon-32x32-next.png?v=5.1.4">
60
61
62  <link rel="icon" type="image/png" sizes="16x16" href="/images/favicon-16x16-next.png?v=5.1.4">
63
64
65  <link rel="mask-icon" href="/images/logo.svg?v=5.1.4" color="#222">
66
67
68
69
70
71  <meta name="keywords" content="编程, 技术">
72
73
74
75
76
77
78
79
80
81
82<meta name="description" content="All In">
83<meta property="og:type" content="website">
84<meta property="og:title" content="Andrew&#39;s Blog">
85<meta property="og:url" content="http://andrewpqc.github.io/index.html">
86<meta property="og:site_name" content="Andrew&#39;s Blog">
87<meta property="og:description" content="All In">
88<meta property="og:locale" content="en">
89<meta name="twitter:card" content="summary">
90<meta name="twitter:title" content="Andrew&#39;s Blog">
91<meta name="twitter:description" content="All In">
92
93
94
95<script type="text/javascript" id="hexo.configurations">
96  var NexT = window.NexT || {};
97  var CONFIG = {
98    root: '/',
99    scheme: 'Pisces',
100    version: '5.1.4',
101    sidebar: {"position":"left","display":"post","offset":12,"b2t":false,"scrollpercent":false,"onmobile":false},
102    fancybox: true,
103    tabs: true,
104    motion: {"enable":true,"async":false,"transition":{"post_block":"fadeIn","post_header":"slideDownIn","post_body":"slideDownIn","coll_header":"slideLeftIn","sidebar":"slideUpIn"}},
105    duoshuo: {
106      userId: '0',
107      author: 'Author'
108    },
109    algolia: {
110      applicationID: '',
111      apiKey: '',
112      indexName: '',
113      hits: {"per_page":10},
114      labels: {"input_placeholder":"Search for Posts","hits_empty":"We didn't find any results for the search: ${query}","hits_stats":"${hits} results found in ${time} ms"}
115    }
116  };
117</script>
117
118
119
120
121  <link rel="canonical" href="http://andrewpqc.github.io/">
122
123
124
125
126
127  <title>Andrew's Blog</title>
128  
129
130
131
132
133
134
135
136
137</head>
138
139<body itemscope itemtype="http://schema.org/WebPage" lang="en">
140
141  
142  
143    
144  
145
146  <div class="container sidebar-position-left 
147  page-home">
148    <div class="headband"></div>
149
150    <header id="header" class="header" itemscope itemtype="http://schema.org/WPHeader">
151      <div class="header-inner"><div class="site-brand-wrapper">
152  <div class="site-meta ">
153    
154
155    <div class="custom-logo-site-title">
156      <a href="/" class="brand" rel="start">
157        <span class="logo-line-before"><i></i></span>
158        <span class="site-title">Andrew's Blog</span>
159        <span class="logo-line-after"><i></i></span>
160      </a>
161    </div>
162      
163        <p class="site-subtitle">Stay hungry, Stay foolish.</p>
164      
165  </div>
166
167  <div class="site-nav-toggle">
168    <button>
169      <span class="btn-bar"></span>
170      <span class="btn-bar"></span>
171      <span class="btn-bar"></span>
172    </button>
173  </div>
174</div>
175
176<nav class="site-nav">
177  
178
179  
180    <ul id="menu" class="menu">
181      
182        
183        <li class="menu-item menu-item-home">
184          <a href="/" rel="section">
185            
186              <i class="menu-item-icon fa fa-fw fa-home"></i> <br>
187            
188            Home
189          </a>
190        </li>
191      
192        
193        <li class="menu-item menu-item-about">
194          <a href="/about/" rel="section">
195            
196              <i class="menu-item-icon fa fa-fw fa-user"></i> <br>
197            
198            About
199          </a>
200        </li>
201      
202        
203        <li class="menu-item menu-item-tags">
204          <a href="/tags/" rel="section">
205            
206              <i class="menu-item-icon fa fa-fw fa-tags"></i> <br>
207            
208            Tags
209          </a>
210        </li>
211      
212        
213        <li class="menu-item menu-item-categories">
214          <a href="/categories/" rel="section">
215            
216              <i class="menu-item-icon fa fa-fw fa-th"></i> <br>
217            
218            Categories
219          </a>
220        </li>
221      
222        
223        <li class="menu-item menu-item-archives">
224          <a href="/archives/" rel="section">
225            
226              <i class="menu-item-icon fa fa-fw fa-archive"></i> <br>
227            
228            Archives
229          </a>
230        </li>
231      
232
233      
234    </ul>
235  
236
237  
238</nav>
239
240
241
242 </div>
243    </header>
244
245    <main id="main" class="main">
246      <div class="main-inner">
247        <div class="content-wrap">
248          <div id="content" class="content">
249            
250  <section id="posts" class="posts-expand">
251    
252      
253
254  
255
256  
257  
258  
259
260  <article class="post post-type-normal" itemscope itemtype="http://schema.org/Article">
261  
262  
263  
264  <div class="post-block">
265    <link itemprop="mainEntityOfPage" href="http://andrewpqc.github.io/2020/11/09/algorithm-prefix-sum-diff-array/">
266
267    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
268      <meta itemprop="name" content="Andrew">
269      <meta itemprop="description" content>
270      <meta itemprop="image" content="/images/avatar.gif">
271    </span>
272
273    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
274      <meta itemprop="name" content="Andrew's Blog">
275    </span>
276
277    
278      <header class="post-header">
279
280        
281        
282          <h1 class="post-title" itemprop="name headline">
283                
284                <a class="post-title-link" href="/2020/11/09/algorithm-prefix-sum-diff-array/" itemprop="url">前缀和与差分数组</a></h1>
285        
286
287        <div class="post-meta">
288          <span class="post-time">
289            
290              <span class="post-meta-item-icon">
291                <i class="fa fa-calendar-o"></i>
292              </span>
293              
294                <span class="post-meta-item-text">Posted on</span>
295              
296              <time title="Post created" itemprop="dateCreated datePublished" datetime="2020-11-09T23:31:01+08:00">
297                2020-11-09
298              </time>
299            
300
301            
302
303            
304          </span>
305
306          
307
308          
309            
310          
311
312          
313          
314
315          
316
317          
318
319          
320
321        </div>
322      </header>
323    
324
325    
326    
327    
328    <div class="post-body" itemprop="articleBody">
329
330      
331      
332
333      
334        
335          
336          前缀和计算一个长度为N的数组中元素和为K的连续子数组的个数?如:在长度为3的数组[1,1,1]中元素和为2的连续子数组的个数为2,即[1,1], [1,1] 
337这里一个很简单的思路是枚举出原始数组所有的子数组,然后计算出子数组的元素和,判断是否等于K。问题是如何快速计算出子数组的元素和呢,这里可以使
338          ...
339          <!--noindex-->
340          <div class="post-button text-center">
341            <a class="btn" href="/2020/11/09/algorithm-prefix-sum-diff-array/#more" rel="contents">
342              Read more &raquo;
343            </a>
344          </div>
345          <!--/noindex-->
346        
347      
348    </div>
349    
350    
351    
352
353    
354
355    
356
357    
358
359    <footer class="post-footer">
360      
361
362      
363
364      
365
366      
367      
368        <div class="post-eof"></div>
369      
370    </footer>
371  </div>
372  
373  
374  
375  </article>
376
377
378    
379      
380
381  
382
383  
384  
385  
386
387  <article class="post post-type-normal" itemscope itemtype="http://schema.org/Article">
388  
389  
390  
391  <div class="post-block">
392    <link itemprop="mainEntityOfPage" href="http://andrewpqc.github.io/202
3920/11/09/about-kafka/">
393
394    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
395      <meta itemprop="name" content="Andrew">
396      <meta itemprop="description" content>
397      <meta itemprop="image" content="/images/avatar.gif">
398    </span>
399
400    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
401      <meta itemprop="name" content="Andrew's Blog">
402    </span>
403
404    
405      <header class="post-header">
406
407        
408        
409          <h1 class="post-title" itemprop="name headline">
410                
411                <a class="post-title-link" href="/2020/11/09/about-kafka/" itemprop="url">Kafka浅析</a></h1>
412        
413
414        <div class="post-meta">
415          <span class="post-time">
416            
417              <span class="post-meta-item-icon">
418                <i class="fa fa-calendar-o"></i>
419              </span>
420              
421                <span class="post-meta-item-text">Posted on</span>
422              
423              <time title="Post created" itemprop="dateCreated datePublished" datetime="2020-11-09T00:42:05+08:00">
424                2020-11-09
425              </time>
426            
427
428            
429
430            
431          </span>
432
433          
434
435          
436            
437          
438
439          
440          
441
442          
443
444          
445
446          
447
448        </div>
449      </header>
450    
451
452    
453    
454    
455    <div class="post-body" itemprop="articleBody">
456
457      
458      
459
460      
461        
462          
463          一、三种常见的消息队列RabbitMQErlang语言开发的,轻量级的,基于队列模式的消息队列,性能较差(相比于Kafka, RocketMQ),不支持消息的大量堆积。
464RocketMQ阿里用Java开发的,基于发布订阅模式的消息队列,性能,稳定性久经考验,但与Kafka相比,在国际上不够流行,与周
465          ...
466          <!--noindex-->
467          <div class="post-button text-center">
468            <a class="btn" href="/2020/11/09/about-kafka/#more" rel="contents">
469              Read more &raquo;
470            </a>
471          </div>
472          <!--/noindex-->
473        
474      
475    </div>
476    
477    
478    
479
480    
481
482    
483
484    
485
486    <footer class="post-footer">
487      
488
489      
490
491      
492
493      
494      
495        <div class="post-eof"></div>
496      
497    </footer>
498  </div>
499  
500  
501  
502  </article>
503
504
505    
506      
507
508  
509
510  
511  
512  
513
514  <article class="post post-type-normal" itemscope itemtype="http://schema.org/Article">
515  
516  
517  
518  <div class="post-block">
519    <link itemprop="mainEntityOfPage" href="http://andrewpqc.github.io/2020/01/12/memory-alignment-rule/">
520
521    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
522      <meta itemprop="name" content="Andrew">
523      <meta itemprop="description" content>
524      <meta itemprop="image" content="/images/avatar.gif">
525    </span>
526
527    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
528      <meta itemprop="name" content="Andrew's Blog">
529    </span>
530
531    
532      <header class="post-header">
533
534        
535        
536          <h1 class="post-title" itemprop="name headline">
537                
538                <a class="post-title-link" href="/2020/01/12/memory-alignment-rule/" itemprop="url">内存对齐规则</a></h1>
539        
540
541        <div class="post-meta">
542          <span class="post-time">
543            
544              <span class="post-meta-item-icon">
545                <i class="fa fa-calendar-o"></i>
546              </span>
547              
548                <span class="post-meta-item-text">Posted on</span>
549              
550              <time title="Post created" itemprop="dateCreated datePublished" datetime="2020-01-12T16:36:07+08:00">
551                2020-01-12
552              </time>
553            
554
555            
556
557            
558          </span>
559
560          
561
562          
563            
564          
565
566          
567          
568
569          
570
571          
572
573          
574
575        </div>
576      </header>
577    
578
579    
580    
581    
582    <div class="post-body" itemprop="articleBody">
583
584      
585      
586
587      
588        
589          
590          后面填坑
591
592          
593          <!--noindex-->
594          <div class="post-button text-center">
595            <a class="btn" href="/2020/01/12/memory-alignment-rule/#more" rel="contents">
596              Read more &raquo;
597            </a>
598          </div>
599          <!--/noindex-->
600        
601      
602    </div>
603    
604    
605    
606
607    
608
609    
610
611    
612
613    <footer class="post-footer">
614      
615
616      
617
618      
619
620      
621      
622        <div class="post-eof"></div>
623      
624    </footer>
625  </div>
626  
627  
628  
629  </article>
630
631
632    
633      
634
635  
636
637  
638  
639  
640
641  <article class="post post-type-normal" itemscope itemtype="http://schema.org/Article">
642  
643  
644  
645  <div class="post-block">
646    <link itemprop="mainEntityOfPage" href="http://andrewpqc.github.io/202
6460/01/12/govaluate-expression-engine/">
647
648    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
649      <meta itemprop="name" content="Andrew">
650      <meta itemprop="description" content>
651      <meta itemprop="image" content="/images/avatar.gif">
652    </span>
653
654    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
655      <meta itemprop="name" content="Andrew's Blog">
656    </span>
657
658    
659      <header class="post-header">
660
661        
662        
663          <h1 class="post-title" itemprop="name headline">
664                
665                <a class="post-title-link" href="/2020/01/12/govaluate-expression-engine/" itemprop="url">govaluate表达式引擎</a></h1>
666        
667
668        <div class="post-meta">
669          <span class="post-time">
670            
671              <span class="post-meta-item-icon">
672                <i class="fa fa-calendar-o"></i>
673              </span>
674              
675                <span class="post-meta-item-text">Posted on</span>
676              
677              <time title="Post created" itemprop="dateCreated datePublished" datetime="2020-01-12T15:47:49+08:00">
678                2020-01-12
679              </time>
680            
681
682            
683
684            
685          </span>
686
687          
688
689          
690            
691          
692
693          
694          
695
696          
697
698          
699
700          
701
702        </div>
703      </header>
704    
705
706    
707    
708    
709    <div class="post-body" itemprop="articleBody">
710
711      
712      
713
714      
715        
716          
717          https://github.com/Knetic/govaluatego语言实现的识别go语言语法的执行引擎,可以做golang语法的表达式解析,常被用于实现规则引擎等
718https://github.com/robertkrimen/ottogo语言实现的识别Js的语法的执行引擎,功能同上
719
720          
721          <!--noindex-->
722          <div class="post-button text-center">
723            <a class="btn" href="/2020/01/12/govaluate-expression-engine/#more" rel="contents">
724              Read more &raquo;
725            </a>
726          </div>
727          <!--/noindex-->
728        
729      
730    </div>
731    
732    
733    
734
735    
736
737    
738
739    
740
741    <footer class="post-footer">
742      
743
744      
745
746      
747
748      
749      
750        <div class="post-eof"></div>
751      
752    </footer>
753  </div>
754  
755  
756  
757  </article>
758
759
760    
761      
762
763  
764
765  
766  
767  
768
769  <article class="post post-type-normal" itemscope itemtype="http://schema.org/Article">
770  
771  
772  
773  <div class="post-block">
774    <link itemprop="mainEntityOfPage" href="http://andrewpqc.github.io/2020/01/12/golang-goroutine-pool/">
775
776    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
777      <meta itemprop="name" content="Andrew">
778      <meta itemprop="description" content>
779      <meta itemprop="image" content="/images/avatar.gif">
780    </span>
781
782    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
783      <meta itemprop="name" content="Andrew's Blog">
784    </span>
785
786    
787      <header class="post-header">
788
789        
790        
791          <h1 class="post-title" itemprop="name headline">
792                
793                <a class="post-title-link" href="/2020/01/12/golang-goroutine-pool/" itemprop="url">goroutine pool</a></h1>
794        
795
796        <div class="post-meta">
797          <span class="post-time">
798            
799              <span class="post-meta-item-icon">
800                <i class="fa fa-calendar-o"></i>
801              </span>
802              
803                <span class="post-meta-item-text">Posted on</span>
804              
805              <time title="Post created" itemprop="dateCreated datePublished" datetime="2020-01-12T15:46:04+08:00">
806                2020-01-12
807              </time>
808            
809
810            
811
812            
813          </span>
814
815          
816
817          
818            
819          
820
821          
822          
823
824          
825
826          
827
828          
829
830        </div>
831      </header>
832    
833
834    
835    
836    
837    <div class="post-body" itemprop="articleBody">
838
839      
840      
841
842      
843        
844          
845          ants: https://github.com/panjf2000/antsants是一个高性能的 goroutine 池,实现了对大规模 goroutine 的调度管理、goroutine 复用,允许使用者在开发并发程序的时候限制 goroutine 数量,复用资源,达到更高效执行任务的效果。
846
847          
848          <!--noindex-->
849          <div class="post-button text-center">
850            <a class="btn" href="/2020/01/12/golang-goroutine-pool/#more" rel="contents">
851              Read more &raquo;
852            </a>
853          </div>
854          <!--/noindex-->
855        
856      
857    </div>
858    
859    
860    
861
862    
863
864    
865
866    
867
868    <footer class="post-footer">
869      
870
871      
872
873      
874
875      
876      
877        <div class="post-eof"></div>
878      
879    </footer>
880  </div>
881  
882  
883  
884  </article>
885
886
887    
888      
889
890  
891
892  
893  
894  
895
896  <article class="post post-type-normal" itemscope itemtype="http://schema.org/Article">
897  
898  
899  
900  <div class="post-block">
901    <link itemprop="mainEntityOfPage" href="http://andrewpqc.github.io/202
9010/01/12/recover-and-panic/">
902
903    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
904      <meta itemprop="name" content="Andrew">
905      <meta itemprop="description" content>
906      <meta itemprop="image" content="/images/avatar.gif">
907    </span>
908
909    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
910      <meta itemprop="name" content="Andrew's Blog">
911    </span>
912
913    
914      <header class="post-header">
915
916        
917        
918          <h1 class="post-title" itemprop="name headline">
919                
920                <a class="post-title-link" href="/2020/01/12/recover-and-panic/" itemprop="url">golang中painc和recover的坑</a></h1>
921        
922
923        <div class="post-meta">
924          <span class="post-time">
925            
926              <span class="post-meta-item-icon">
927                <i class="fa fa-calendar-o"></i>
928              </span>
929              
930                <span class="post-meta-item-text">Posted on</span>
931              
932              <time title="Post created" itemprop="dateCreated datePublished" datetime="2020-01-12T15:42:09+08:00">
933                2020-01-12
934              </time>
935            
936
937            
938
939            
940          </span>
941
942          
943
944          
945            
946          
947
948          
949          
950
951          
952
953          
954
955          
956
957        </div>
958      </header>
959    
960
961    
962    
963    
964    <div class="post-body" itemprop="articleBody">
965
966      
967      
968
969      
970        
971          
972          本文记录一个golang的recover和painc的坑。
973recover和painc1234567891011121314151617181920212223242526272829303132333435363738394041424344// 不能捕获func f1())&#123;    r
974          ...
975          <!--noindex-->
976          <div class="post-button text-center">
977            <a class="btn" href="/2020/01/12/recover-and-panic/#more" rel="contents">
978              Read more &raquo;
979            </a>
980          </div>
981          <!--/noindex-->
982        
983      
984    </div>
985    
986    
987    
988
989    
990
991    
992
993    
994
995    <footer class="post-footer">
996      
997
998      
999
1000      
1001
1002      
1003      
1004        <div class="post-eof"></div>
1005      
1006    </footer>
1007  </div>
1008  
1009  
1010  
1011  </article>
1012
1013
1014    
1015      
1016
1017  
1018
1019  
1020  
1021  
1022
1023  <article class="post post-type-normal" itemscope itemtype="http://schema.org/Article">
1024  
1025  
1026  
1027  <div class="post-block">
1028    <link itemprop="mainEntityOfPage" href="http://andrewpqc.github.io/2020/01/12/cpp-smart-pointer/">
1029
1030    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
1031      <meta itemprop="name" content="Andrew">
1032      <meta itemprop="description" content>
1033      <meta itemprop="image" content="/images/avatar.gif">
1034    </span>
1035
1036    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
1037      <meta itemprop="name" content="Andrew's Blog">
1038    </span>
1039
1040    
1041      <header class="post-header">
1042
1043        
1044        
1045          <h1 class="post-title" itemprop="name headline">
1046                
1047                <a class="post-title-link" href="/2020/01/12/cpp-smart-pointer/" itemprop="url">cpp智能指针详解</a></h1>
1048        
1049
1050        <div class="post-meta">
1051          <span class="post-time">
1052            
1053              <span class="post-meta-item-icon">
1054                <i class="fa fa-calendar-o"></i>
1055              </span>
1056              
1057                <span class="post-meta-item-text">Posted on</span>
1058              
1059              <time title="Post created" itemprop="dateCreated datePublished" datetime="2020-01-12T15:35:00+08:00">
1060                2020-01-12
1061              </time>
1062            
1063
1064            
1065
1066            
1067          </span>
1068
1069          
1070
1071          
1072            
1073          
1074
1075          
1076          
1077
1078          
1079
1080          
1081
1082          
1083
1084        </div>
1085      </header>
1086    
1087
1088    
1089    
1090    
1091    <div class="post-body" itemprop="articleBody">
1092
1093      
1094      
1095
1096      
1097        
1098          
1099          cpp是一种没有垃圾回收的语言,给了程序员十足的控制感,同时也为内存泄漏问题留下了重大的隐患。Modern Cpp不推荐程序员完全用new和delete手动管理内存,而是应该使用智能指针。这一节我们就来梳理下智能指针的特性与应用场景。
1100auto_ptr我们从std::auto_ptr说起。在C++ 
1101          ...
1102          <!--noindex-->
1103          <div class="post-button text-center">
1104            <a class="btn" href="/2020/01/12/cpp-smart-pointer/#more" rel="contents">
1105              Read more &raquo;
1106            </a>
1107          </div>
1108          <!--/noindex-->
1109        
1110      
1111    </div>
1112    
1113    
1114    
1115
1116    
1117
1118    
1119
1120    
1121
1122    <footer class="post-footer">
1123      
1124
1125      
1126
1127      
1128
1129      
1130      
1131        <div class="post-eof"></div>
1132      
1133    </footer>
1134  </div>
1135  
1136  
1137  
1138  </article>
1139
1140
1141    
1142      
1143
1144  
1145
1146  
1147  
1148  
1149
1150  <article class="post post-type-normal" itemscope itemtype="http://schema.org/Article">
1151  
1152  
1153  
1154  <div class="post-block">
1155    <link itemprop="mainEntityOfPage" href="http://andrewpqc.github.io/202
11550/01/12/little-big-endian/">
1156
1157    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
1158      <meta itemprop="name" content="Andrew">
1159      <meta itemprop="description" content>
1160      <meta itemprop="image" content="/images/avatar.gif">
1161    </span>
1162
1163    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
1164      <meta itemprop="name" content="Andrew's Blog">
1165    </span>
1166
1167    
1168      <header class="post-header">
1169
1170        
1171        
1172          <h1 class="post-title" itemprop="name headline">
1173                
1174                <a class="post-title-link" href="/2020/01/12/little-big-endian/" itemprop="url">网络字节序与主机字节序</a></h1>
1175        
1176
1177        <div class="post-meta">
1178          <span class="post-time">
1179            
1180              <span class="post-meta-item-icon">
1181                <i class="fa fa-calendar-o"></i>
1182              </span>
1183              
1184                <span class="post-meta-item-text">Posted on</span>
1185              
1186              <time title="Post created" itemprop="dateCreated datePublished" datetime="2020-01-12T14:48:02+08:00">
1187                2020-01-12
1188              </time>
1189            
1190
1191            
1192
1193            
1194          </span>
1195
1196          
1197            <span class="post-category">
1198            
1199              <span class="post-meta-divider">|</span>
1200            
1201              <span class="post-meta-item-icon">
1202                <i class="fa fa-folder-o"></i>
1203              </span>
1204              
1205                <span class="post-meta-item-text">In</span>
1206              
1207              
1208                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
1209                  <a href="/categories/Network/" itemprop="url" rel="index">
1210                    <span itemprop="name">Network</span>
1211                  </a>
1212                </span>
1213
1214                
1215                
1216              
1217            </span>
1218          
1219
1220          
1221            
1222          
1223
1224          
1225          
1226
1227          
1228
1229          
1230
1231          
1232
1233        </div>
1234      </header>
1235    
1236
1237    
1238    
1239    
1240    <div class="post-body" itemprop="articleBody">
1241
1242      
1243      
1244
1245      
1246        
1247          
1248          主机字节序在网络编程中涉及到的IP地址和端口号通常是多字节整数,多字节整数在不同的硬件结构上字节序可能不同。所谓字节序指的是对于存储需要多个字节(大于 1 字节)的整数来说,其每个字节在不同的机器内存中存储的顺序。这就是所谓的主机字节序,一般分为两类:
1249大端序(big endian)内存地址从小到大
1250          ...
1251          <!--noindex-->
1252          <div class="post-button text-center">
1253            <a class="btn" href="/2020/01/12/little-big-endian/#more" rel="contents">
1254              Read more &raquo;
1255            </a>
1256          </div>
1257          <!--/noindex-->
1258        
1259      
1260    </div>
1261    
1262    
1263    
1264
1265    
1266
1267    
1268
1269    
1270
1271    <footer class="post-footer">
1272      
1273
1274      
1275
1276      
1277
1278      
1279      
1280        <div class="post-eof"></div>
1281      
1282    </footer>
1283  </div>
1284  
1285  
1286  
1287  </article>
1288
1289
1290    
1291      
1292
1293  
1294
1295  
1296  
1297  
1298
1299  <article class="post post-type-normal" itemscope itemtype="http://schema.org/Article">
1300  
1301  
1302  
1303  <div class="post-block">
1304    <link itemprop="mainEntityOfPage" href="http://andrewpqc.github.io/2020/01/11/false-sharing/">
1305
1306    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
1307      <meta itemprop="name" content="Andrew">
1308      <meta itemprop="description" content>
1309      <meta itemprop="image" content="/images/avatar.gif">
1310    </span>
1311
1312    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
1313      <meta itemprop="name" content="Andrew's Blog">
1314    </span>
1315
1316    
1317      <header class="post-header">
1318
1319        
1320        
1321          <h1 class="post-title" itemprop="name headline">
1322                
1323                <a class="post-title-link" href="/2020/01/11/false-sharing/" itemprop="url">伪共享</a></h1>
1324        
1325
1326        <div class="post-meta">
1327          <span class="post-time">
1328            
1329              <span class="post-meta-item-icon">
1330                <i class="fa fa-calendar-o"></i>
1331              </span>
1332              
1333                <span class="post-meta-item-text">Posted on</span>
1334              
1335              <time title="Post created" itemprop="dateCreated datePublished" datetime="2020-01-11T21:34:41+08:00">
1336                2020-01-11
1337              </time>
1338            
1339
1340            
1341
1342            
1343          </span>
1344
1345          
1346            <span class="post-category">
1347            
1348              <span class="post-meta-divider">|</span>
1349            
1350              <span class="post-meta-item-icon">
1351                <i class="fa fa-folder-o"></i>
1352              </span>
1353              
1354                <span class="post-meta-item-text">In</span>
1355              
1356              
1357                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
1358                  <a href="/categories/OS/" itemprop="url" rel="index">
1359                    <span itemprop="name">OS</span>
1360                  </a>
1361                </span>
1362
1363                
1364                
1365              
1366            </span>
1367          
1368
1369          
1370            
1371          
1372
1373          
1374          
1375
1376          
1377
1378          
1379
1380          
1381
1382        </div>
1383      </header>
1384    
1385
1386    
1387    
1388    
1389    <div class="post-body" itemprop="articleBody">
1390
1391      
1392      
1393
1394      
1395        
1396          
1397          CPU缓存与缓存行多核时代的到来使得并发编程愈来愈受到关注,这一节我们来了解一下号称多核并发编程中的性能刺客的伪共享(False Sharing)。要了解伪共享还得从CPU缓存讲起。
1398CPU缓存是位于CPU和主存之间的临时存储器,它的容量比主存小得多但是交换速度比主存快得多。CPU缓存的基本单位是缓
1399          ...
1400          <!--noindex-->
1401          <div class="post-button text-center">
1402            <a class="btn" href="/2020/01/11/false-sharing/#more" rel="contents">
1403              Read more &raquo;
1404            </a>
1405          </div>
1406          <!--/noindex-->
1407        
1408      
1409    </div>
1410    
1411    
1412    
1413
1414    
1415
1416    
1417
1418    
1419
1420    <footer class="post-footer">
1421      
1422
1423      
1424
1425      
1426
1427      
1428      
1429        <div class="post-eof"></div>
1430      
1431    </footer>
1432  </div>
1433  
1434  
1435  
1436  </article>
1437
1438
1439    
1440      
1441
1442  
1443
1444  
1445  
1446  
1447
1448  <article class="post post-type-normal" itemscope itemtype="http://schema.org/Article">
1449  
1450  
1451  
1452  <div class="post-block">
1453    <link itemprop="mainEntityOfPage" href="http://andrewpqc.github.io/2019/08/04/go-pre-commit/">
1454
1455    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
1456      <meta itemprop="name" content="Andrew">
1457      <meta itemprop="description" content>
1458      <meta itemprop="image" content="/images/avatar.gif">
1459    </span>
1460
1461    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
1462      <meta itemprop="name" content="Andrew's Blog">
1463    </span>
1464
1465    
1466      <header class="post-header">
1467
1468        
1469        
1470          <h1 class="post-title" itemprop="name headline">
1471                
1472                <a class="post-title-link" href="/2019/08/04/go-pre-commit/" itemprop="url">Go项目配置pre-commit hook</a></h1>
1473        
1474
1475        <div class="post-meta">
1476          <span class="post-time">
1477            
1478              <span class="post-meta-item-icon">
1479                <i class="fa fa-calendar-o"></i>
1480              </span>
1481              
1482                <span class="post-meta-item-text">Posted on</span>
1483              
1484              <time title="Post created" itemprop="dateCreated datePublished" datetime="2019-08-04T21:27:47+08:00">
1485                2019-08-04
1486              </time>
1487            
1488
1489            
1490
1491            
1492          </span>
1493
1494          
1495            <span class="post-category">
1496            
1497              <span class="post-meta-divider">|</span>
1498            
1499              <span class="post-meta-item-icon">
1500                <i class="fa fa-folder-o"></i>
1501              </span>
1502              
1503                <span class="post-meta-item-text">In</span>
1504              
1505              
1506                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
1507                  <a href="/categories/GO/" itemprop="url" rel="index">
1508                    <span itemprop="name">GO</span>
1509                  </a>
1510                </span>
1511
1512                
1513                
1514              
1515            </span>
1516          
1517
1518          
1519            
1520          
1521
1522          
1523          
1524
1525          
1526
1527          
1528
1529          
1530
1531        </div>
1532      </header>
1533    
1534
1535    
1536    
1537    
1538    <div class="post-body" itemprop="articleBody">
1539
1540      
1541      
1542
1543      
1544        
1545          
1546          一、前言Go语言官方提供有:
1547
1548gofmt 来进行Go代码格式化
1549go tool vet 检查Go源码中静态错误第三方提供有:
1550golint 检查GO代码风格(注释,命名等)
1551goimports 自动导入需要的import statement和自动移除未被使用import statement
1552
1553下面
1554          ...
1555          <!--noindex-->
1556          <div class="post-button text-center">
1557            <a class="btn" href="/2019/08/04/go-pre-commit/#more" rel="contents">
1558              Read more &raquo;
1559            </a>
1560          </div>
1561          <!--/noindex-->
1562        
1563      
1564    </div>
1565    
1566    
1567    
1568
1569    
1570
1571    
1572
1573    
1574
1575    <footer class="post-footer">
1576      
1577
1578      
1579
1580      
1581
1582      
1583      
1584        <div class="post-eof"></div>
1585      
1586    </footer>
1587  </div>
1588  
1589  
1590  
1591  </article>
1592
1593
1594    
1595  </section>
1596
1597  
1598  <nav class="pagination">
1599    <span class="page-number current">1</span><a class="page-number" href="/page/2/">2</a><span class="space">&hellip;</span><a class="page-number" href="/page/6/">6</a><a class="extend next" rel="next" href="/page/2/"><i class="fa fa-angle-right"></i></a>
1600  </nav>
1601
1602
1603
1604          </div>
1605          
1606
1607
1608          
1609
1610        </div>
1611        
1612          
1613  
1614  <div class="sidebar-toggle">
1615    <div class="sidebar-toggle-line-wrap">
1616      <span class="sidebar-toggle-line sidebar-toggle-line-first"></span>
1617      <span class="sidebar-toggle-line sidebar-toggle-line-middle"></span>
1618      <span class="sidebar-toggle-line sidebar-toggle-line-last"></span>
1619    </div>
1620  </div>
1621
1622  <aside id="sidebar" class="sidebar">
1623    
1624    <div class="sidebar-inner">
1625
1626      
1627
1628      
1629
1630      <section class="site-overview-wrap sidebar-panel sidebar-panel-active">
1631        <div class="site-overview">
1632          <div class="site-author motion-element" itemprop="author" itemscope itemtype="http://schema.org/Person">
1633            
1634              <p class="site-author-name" itemprop="name">Andrew</p>
1635              <p class="site-description motion-element" itemprop="description">All In</p>
1636          </div>
1637
1638          <nav class="site-state motion-element">
1639
1640            
1641              <div class="site-state-item site-state-posts">
1642              
1643                <a href="/archives/">
1644              
1645                  <span class="site-state-item-count">60</span>
1646                  <span class="site-state-item-name">posts</span>
1647                </a>
1648              </div>
1649            
1650
1651            
1652              
1653              
1654              <div class="site-state-item site-state-categories">
1655                <a href="/categories/index.html">
1656                  <span class="site-state-item-count">13</span>
1657                  <span class="site-state-item-name">categories</span>
1658                </a>
1659              </div>
1660            
1661
1662            
1663              
1664              
1665              <div class="site-state-item site-state-tags">
1666                <a href="/tags/index.html">
1667                  <span class="site-state-item-count">67</span>
1668                  <span class="site-state-item-name">tags</span>
1669                </a>
1670              </div>
1671            
1672
1673          </nav>
1674
1675          
1676
1677          
1678            <div class="links-of-author motion-element">
1679                
1680                  <span class="links-of-author-item">
1681                    <a href="https://github.com/Andrewpqc" target="_blank" title="GitHub">
1682                      
1683                        <i class="fa fa-fw fa-github"></i></a>
1684                  </span>
1685                
1686                  <span class="links-of-author-item">
1687                    <a href="https://twitter.com/Andrewpqc" target="_blank" title="Twitter">
1688                      
1689                        <i class="fa fa-fw fa-twitter"></i></a>
1690                  </span>
1691                
1692            </div>
1693          
1694
1695          
1696          
1697            <div class="cc-license motion-element" itemprop="license">
1698              <a href="https://creativecommons.org/licenses/by-nc-sa/4.0/" class="cc-opacity" target="_blank">
1699                <img src="/images/cc-by-nc-sa.svg" alt="Creative 
1699Commons">
1700              </a>
1701            </div>
1702          
1703
1704          
1705          
1706
1707          
1708
1709        </div>
1710      </section>
1711
1712      
1713
1714      
1715
1716    </div>
1717  </aside>
1718
1719
1720        
1721      </div>
1722    </main>
1723
1724    <footer id="footer" class="footer">
1725      <div class="footer-inner">
1726        <div class="copyright">&copy; 2017 &mdash; <span itemprop="copyrightYear">2020</span>
1727  <span class="with-love">
1728    <i class="fa fa-user"></i>
1729  </span>
1730  <span class="author" itemprop="copyrightHolder">Andrew</span>
1731
1732  
1733</div>
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743        
1744
1745
1746
1747
1748
1749
1750
1751        
1752      </div>
1753    </footer>
1754
1755    
1756      <div class="back-to-top">
1757        <i class="fa fa-arrow-up"></i>
1758        
1759      </div>
1760    
1761
1762    
1763
1764  </div>
1765
1766  
1767
1768<script type="text/javascript">
1769  if (Object.prototype.toString.call(window.Promise) !== '[object Function]') {
1770    window.Promise = null;
1771  }
1772</script>
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782  
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795  
1796  
1797    
1797<script type="text/javascript" src="/lib/jquery/index.js?v=2.1.3"></script>
1797
1798  
1799
1800  
1801  
1802    
1802<script type="text/javascript" src="/lib/fastclick/lib/fastclick.min.js?v=1.0.6"></script>
1802
1803  
1804
1805  
1806  
1807    
1807<script type="text/javascript" src="/lib/jquery_lazyload/jquery.lazyload.js?v=1.9.7"></script>
1807
1808  
1809
1810  
1811  
1812    
1812<script type="text/javascript" src="/lib/velocity/velocity.min.js?v=1.2.1"></script>
1812
1813  
1814
1815  
1816  
1817    
1817<script type="text/javascript" src="/lib/velocity/velocity.ui.min.js?v=1.2.1"></script>
1817
1818  
1819
1820  
1821  
1822    
1822<script type="text/javascript" src="/lib/fancybox/source/jquery.fancybox.pack.js?v=2.1.5"></script>
1822
1823  
1824
1825
1826  
1827
1828
1829  
1829<script type="text/javascript" src="/js/src/utils.js?v=5.1.4"></script>
1829
1830
1831  
1831<script type="text/javascript" src="/js/src/motion.js?v=5.1.4"></script>
1831
1832
1833
1834
1835  
1836  
1837
1838
1839  
1839<script type="text/javascript" src="/js/src/affix.js?v=5.1.4"></script>
1839
1840
1841  
1841<script type="text/javascript" src="/js/src/schemes/pisces.js?v=5.1.4"></script>
1841
1842
1843
1844
1845  
1846
1847  
1848
1849
1850  
1850<script type="text/javascript" src="/js/src/bootstrap.js?v=5.1.4"></script>
1850
1851
1852
1853
1854  
1855
1856
1857  
1858
1859
1860
1861
1862	
1863
1864
1865
1866
1867
1868  
1869
1870
1871
1872
1873
1874  
1875
1876
1877
1878
1879
1880
1881
1882<!-- LOCAL: You can save these files to your site and update links -->
1883    
1884        
1885        <link rel="stylesheet" href="https://aimingoo.github.io/gitmint/style/default.css">
1886        
1886<script src="https://aimingoo.github.io/gitmint/dist/gitmint.browser.js"></script>
1886
1887    
1888<!-- END LOCAL -->
1889
1890    
1891
1892    
1893
1894
1895
1896
1897
1898
1899
1900  
1901
1902
1903
1904
1905
1906  
1907
1908  
1909
1910  
1911
1912  
1913  
1914
1915  
1916
1917  
1918  
1918<script type="text/javascript" src="/js/src/js.cookie.js?v=5.1.4"></script>
1918
1919  
1919<script type="text/javascript" src="/js/src/scroll-cookie.js?v=5.1.4"></script>
1919
1920
1921
1922  
1923
1924</body>
1925</html>

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.