-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
1308 lines (940 loc) · 86.1 KB
/
index.html
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
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width">
<meta name="theme-color" content="#222">
<meta name="generator" content="Hexo 6.0.0">
<link rel="apple-touch-icon" sizes="180x180" href="/images/apple-touch-icon-next.png">
<link rel="icon" type="image/png" sizes="32x32" href="/images/favicon-32x32-next.png">
<link rel="icon" type="image/png" sizes="16x16" href="/images/favicon-16x16-next.png">
<link rel="mask-icon" href="/images/logo.svg" color="#222">
<link rel="stylesheet" href="/css/main.css">
<link rel="stylesheet" href="https://unpkg.com/@fortawesome/fontawesome-free@5.15.4/css/all.min.css" integrity="sha256-mUZM63G8m73Mcidfrv5E+Y61y7a12O5mW4ezU3bxqW4=" crossorigin="anonymous">
<link rel="stylesheet" href="https://unpkg.com/animate.css@3.1.1/animate.min.css" integrity="sha256-PR7ttpcvz8qrF57fur/yAx1qXMFJeJFiA6pSzWi0OIE=" crossorigin="anonymous">
<script class="next-config" data-name="main" type="application/json">{"hostname":"xuanskyer.github.io","root":"/","images":"/images","scheme":"Gemini","darkmode":false,"version":"8.9.0","exturl":false,"sidebar":{"position":"left","display":"post","padding":18,"offset":12},"copycode":true,"bookmark":{"enable":true,"color":"#222","save":"auto"},"mediumzoom":false,"lazyload":false,"pangu":true,"comments":{"style":"tabs","active":null,"storage":true,"lazyload":true,"nav":null},"stickytabs":false,"motion":{"enable":true,"async":false,"transition":{"post_block":"fadeIn","post_header":"fadeInDown","post_body":"fadeInDown","coll_header":"fadeInLeft","sidebar":"fadeInUp"}},"prism":false,"i18n":{"placeholder":"搜索...","empty":"没有找到任何搜索结果:${query}","hits_time":"找到 ${hits} 个搜索结果(用时 ${time} 毫秒)","hits":"找到 ${hits} 个搜索结果"}}</script><script src="/js/config.js"></script>
<meta name="description" content="世界不可能那么远!">
<meta property="og:type" content="website">
<meta property="og:title" content="世界不可能那么远">
<meta property="og:url" content="https://xuanskyer.github.io/index.html">
<meta property="og:site_name" content="世界不可能那么远">
<meta property="og:description" content="世界不可能那么远!">
<meta property="og:locale" content="zh_CN">
<meta property="article:author" content="xuanskyer">
<meta property="article:tag" content="世界不可能那么远">
<meta name="twitter:card" content="summary">
<link rel="canonical" href="https://xuanskyer.github.io/">
<script class="next-config" data-name="page" type="application/json">{"sidebar":"","isHome":true,"isPost":false,"lang":"zh-CN","comments":"","permalink":"","path":"index.html","title":""}</script>
<script class="next-config" data-name="calendar" type="application/json">""</script>
<title>世界不可能那么远</title>
<noscript>
<link rel="stylesheet" href="/css/noscript.css">
</noscript>
</head>
<body itemscope itemtype="http://schema.org/WebPage" class="use-motion">
<div class="headband"></div>
<main class="main">
<header class="header" itemscope itemtype="http://schema.org/WPHeader">
<div class="header-inner"><div class="site-brand-container">
<div class="site-nav-toggle">
<div class="toggle" aria-label="切换导航栏" role="button">
<span class="toggle-line"></span>
<span class="toggle-line"></span>
<span class="toggle-line"></span>
</div>
</div>
<div class="site-meta">
<a href="/" class="brand" rel="start">
<i class="logo-line"></i>
<h1 class="site-title">世界不可能那么远</h1>
<i class="logo-line"></i>
</a>
</div>
<div class="site-nav-right">
<div class="toggle popup-trigger">
</div>
</div>
</div>
<nav class="site-nav">
<ul class="main-menu menu">
<li class="menu-item menu-item-home"><a href="/" rel="section"><i class="fa fa-home fa-fw"></i>首页</a></li>
<li class="menu-item menu-item-about"><a href="/about/" rel="section"><i class="fa fa-user fa-fw"></i>关于</a></li>
<li class="menu-item menu-item-categories"><a href="/categories/" rel="section"><i class="fa fa-th fa-fw"></i>分类</a></li>
<li class="menu-item menu-item-archives"><a href="/archives/" rel="section"><i class="fa fa-archive fa-fw"></i>归档</a></li>
<li class="menu-item menu-item-typecho"><a href="/typecho/" rel="section"><i class="fa fa-tasks fa-fw"></i>typecho</a></li>
</ul>
</nav>
</div>
<div class="toggle sidebar-toggle" role="button">
<span class="toggle-line"></span>
<span class="toggle-line"></span>
<span class="toggle-line"></span>
</div>
<aside class="sidebar">
<div class="sidebar-inner sidebar-overview-active">
<ul class="sidebar-nav">
<li class="sidebar-nav-toc">
文章目录
</li>
<li class="sidebar-nav-overview">
站点概览
</li>
</ul>
<div class="sidebar-panel-container">
<!--noindex-->
<div class="post-toc-wrap sidebar-panel">
</div>
<!--/noindex-->
<div class="site-overview-wrap sidebar-panel">
<div class="site-author site-overview-item animated" itemprop="author" itemscope itemtype="http://schema.org/Person">
<img class="site-author-image" itemprop="image" alt="xuanskyer"
src="/images/me.jpeg">
<p class="site-author-name" itemprop="name">xuanskyer</p>
<div class="site-description" itemprop="description">世界不可能那么远!</div>
</div>
<div class="site-state-wrap site-overview-item animated">
<nav class="site-state">
<div class="site-state-item site-state-posts">
<a href="/archives/">
<span class="site-state-item-count">27</span>
<span class="site-state-item-name">日志</span>
</a>
</div>
<div class="site-state-item site-state-categories">
<a href="/categories/">
<span class="site-state-item-count">10</span>
<span class="site-state-item-name">分类</span></a>
</div>
<div class="site-state-item site-state-tags">
<span class="site-state-item-count">16</span>
<span class="site-state-item-name">标签</span>
</div>
</nav>
</div>
<div class="links-of-author site-overview-item animated">
<span class="links-of-author-item">
<a href="https://github.com/xuanskyer" title="GitHub → https://github.com/xuanskyer" rel="noopener" target="_blank"><i class="fab fa-github fa-fw"></i>GitHub</a>
</span>
<span class="links-of-author-item">
<a href="mailto:xuanskyer@gmail.com" title="E-Mail → mailto:xuanskyer@gmail.com" rel="noopener" target="_blank"><i class="fa fa-envelope fa-fw"></i>E-Mail</a>
</span>
</div>
<div class="cc-license site-overview-item animated" itemprop="license">
<a href="https://creativecommons.org/licenses/by-nc-sa/4.0/zh" class="cc-opacity" rel="noopener" target="_blank"><img src="https://unpkg.com/@creativecommons/vocabulary@2020.11.3/assets/license_badges/small/by_nc_sa.svg" alt="Creative Commons"></a>
</div>
<div class="links-of-blogroll site-overview-item animated">
<div class="links-of-blogroll-title"><i class="fa fa-globe fa-fw"></i>
友情链接
</div>
<ul class="links-of-blogroll-list">
<li class="links-of-blogroll-item">
<a href="https://nops.icu/" title="https://nops.icu" rel="noopener" target="_blank">季总-上岸者</a>
</li>
<li class="links-of-blogroll-item">
<a href="https://www.yoytang.com/" title="https://www.yoytang.com" rel="noopener" target="_blank">刘总,N+1能力者</a>
</li>
<li class="links-of-blogroll-item">
<a href="https://www.qlee.in/" title="https://www.qlee.in/" rel="noopener" target="_blank">强哥,宇宙条</a>
</li>
<li class="links-of-blogroll-item">
<a href="https://gaolu.tech/" title="https://gaolu.tech" rel="noopener" target="_blank">高总,尊贵的特斯拉车主</a>
</li>
<li class="links-of-blogroll-item">
<a href="https://perfgao.github.io/" title="https://perfgao.github.io/" rel="noopener" target="_blank">力哥,消失的强者</a>
</li>
<li class="links-of-blogroll-item">
<a href="https://sunyunqiang.com/blog/raft_protocol/" title="https://sunyunqiang.com/blog/raft_protocol/" rel="noopener" target="_blank">孙同学的博客</a>
</li>
<li class="links-of-blogroll-item">
<a href="https://www.cyhone.com/" title="https://www.cyhone.com/" rel="noopener" target="_blank">编程沉思录</a>
</li>
<li class="links-of-blogroll-item">
<a href="http://hbchen.com/" title="http://hbchen.com/" rel="noopener" target="_blank">HB Chen</a>
</li>
</ul>
</div>
</div>
</div>
</div>
</aside>
<div class="sidebar-dimmer"></div>
</header>
<div class="back-to-top" role="button" aria-label="返回顶部">
<i class="fa fa-arrow-up"></i>
<span>0%</span>
</div>
<div class="reading-progress-bar"></div>
<a role="button" class="book-mark-link book-mark-link-fixed"></a>
<a href="https://github.com/xuanskyer" class="github-corner" title="Follow me on GitHub" aria-label="Follow me on GitHub" rel="noopener" target="_blank"><svg width="80" height="80" viewBox="0 0 250 250" aria-hidden="true"><path d="M0,0 L115,115 L130,115 L142,142 L250,250 L250,0 Z"></path><path d="M128.3,109.0 C113.8,99.7 119.0,89.6 119.0,89.6 C122.0,82.7 120.5,78.6 120.5,78.6 C119.2,72.0 123.4,76.3 123.4,76.3 C127.3,80.9 125.5,87.3 125.5,87.3 C122.9,97.6 130.6,101.9 134.4,103.2" fill="currentColor" style="transform-origin: 130px 106px;" class="octo-arm"></path><path d="M115.0,115.0 C114.9,115.1 118.7,116.5 119.8,115.4 L133.7,101.6 C136.9,99.2 139.9,98.4 142.2,98.6 C133.8,88.0 127.5,74.4 143.8,58.0 C148.5,53.4 154.0,51.2 159.7,51.0 C160.3,49.4 163.2,43.6 171.4,40.1 C171.4,40.1 176.1,42.5 178.8,56.2 C183.1,58.6 187.2,61.8 190.9,65.4 C194.5,69.0 197.7,73.2 200.1,77.6 C213.8,80.2 216.3,84.9 216.3,84.9 C212.7,93.1 206.9,96.0 205.4,96.6 C205.1,102.4 203.0,107.8 198.3,112.5 C181.9,128.9 168.3,122.5 157.7,114.1 C157.9,116.9 156.7,120.9 152.7,124.9 L141.0,136.5 C139.8,137.7 141.6,141.9 141.8,141.8 Z" fill="currentColor" class="octo-body"></path></svg></a>
<noscript>
<div class="noscript-warning">Theme NexT works best with JavaScript enabled</div>
</noscript>
<div class="main-inner index posts-expand">
<div class="post-block">
<article itemscope itemtype="http://schema.org/Article" class="post-content" lang="">
<link itemprop="mainEntityOfPage" href="https://xuanskyer.github.io/2022/04/17/%E4%B8%80%E4%B8%AA%E5%B0%8F%E5%B7%A5%E5%85%B7/">
<span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
<meta itemprop="image" content="/images/me.jpeg">
<meta itemprop="name" content="xuanskyer">
<meta itemprop="description" content="世界不可能那么远!">
</span>
<span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
<meta itemprop="name" content="世界不可能那么远">
</span>
<header class="post-header">
<h2 class="post-title" itemprop="name headline">
<a href="/2022/04/17/%E4%B8%80%E4%B8%AA%E5%B0%8F%E5%B7%A5%E5%85%B7/" class="post-title-link" itemprop="url">一个小工具</a>
</h2>
<div class="post-meta-container">
<div class="post-meta">
<span class="post-meta-item">
<span class="post-meta-item-icon">
<i class="far fa-calendar"></i>
</span>
<span class="post-meta-item-text">发表于</span>
<time title="创建时间:2022-04-17 11:23:51" itemprop="dateCreated datePublished" datetime="2022-04-17T11:23:51+08:00">2022-04-17</time>
</span>
<span class="post-meta-item">
<span class="post-meta-item-icon">
<i class="far fa-calendar-check"></i>
</span>
<span class="post-meta-item-text">更新于</span>
<time title="修改时间:2023-10-16 14:58:54" itemprop="dateModified" datetime="2023-10-16T14:58:54+08:00">2023-10-16</time>
</span>
</div>
</div>
</header>
<div class="post-body" itemprop="articleBody">
<h1 id="搞了一个分词统计的小工具"><a href="#搞了一个分词统计的小工具" class="headerlink" title="搞了一个分词统计的小工具"></a>搞了一个分词统计的小工具</h1><p>不废话了:<a target="_blank" rel="noopener" href="https://jieba.qtter.com/">传送门</a></p>
<p>算是熟悉下一些快要遗忘的知识点吧!</p>
<p>以上。</p>
</div>
<footer class="post-footer">
<div class="post-eof"></div>
</footer>
</article>
</div>
<div class="post-block">
<article itemscope itemtype="http://schema.org/Article" class="post-content" lang="">
<link itemprop="mainEntityOfPage" href="https://xuanskyer.github.io/2022/03/05/%E5%85%B3%E4%BA%8Etime-rate%E7%9A%84%E4%B8%80%E7%AF%87%E6%B0%B4%E8%B4%B4/">
<span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
<meta itemprop="image" content="/images/me.jpeg">
<meta itemprop="name" content="xuanskyer">
<meta itemprop="description" content="世界不可能那么远!">
</span>
<span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
<meta itemprop="name" content="世界不可能那么远">
</span>
<header class="post-header">
<h2 class="post-title" itemprop="name headline">
<a href="/2022/03/05/%E5%85%B3%E4%BA%8Etime-rate%E7%9A%84%E4%B8%80%E7%AF%87%E6%B0%B4%E8%B4%B4/" class="post-title-link" itemprop="url">关于time/rate的一篇水贴</a>
</h2>
<div class="post-meta-container">
<div class="post-meta">
<span class="post-meta-item">
<span class="post-meta-item-icon">
<i class="far fa-calendar"></i>
</span>
<span class="post-meta-item-text">发表于</span>
<time title="创建时间:2022-03-05 22:55:04" itemprop="dateCreated datePublished" datetime="2022-03-05T22:55:04+08:00">2022-03-05</time>
</span>
<span class="post-meta-item">
<span class="post-meta-item-icon">
<i class="far fa-calendar-check"></i>
</span>
<span class="post-meta-item-text">更新于</span>
<time title="修改时间:2023-10-16 14:58:54" itemprop="dateModified" datetime="2023-10-16T14:58:54+08:00">2023-10-16</time>
</span>
</div>
</div>
</header>
<div class="post-body" itemprop="articleBody">
</div>
<footer class="post-footer">
<div class="post-eof"></div>
</footer>
</article>
</div>
<div class="post-block">
<article itemscope itemtype="http://schema.org/Article" class="post-content" lang="">
<link itemprop="mainEntityOfPage" href="https://xuanskyer.github.io/2022/02/21/2021%E4%B8%8B/">
<span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
<meta itemprop="image" content="/images/me.jpeg">
<meta itemprop="name" content="xuanskyer">
<meta itemprop="description" content="世界不可能那么远!">
</span>
<span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
<meta itemprop="name" content="世界不可能那么远">
</span>
<header class="post-header">
<h2 class="post-title" itemprop="name headline">
<a href="/2022/02/21/2021%E4%B8%8B/" class="post-title-link" itemprop="url">2021 年底来扯扯淡(下)</a>
</h2>
<div class="post-meta-container">
<div class="post-meta">
<span class="post-meta-item">
<span class="post-meta-item-icon">
<i class="far fa-calendar"></i>
</span>
<span class="post-meta-item-text">发表于</span>
<time title="创建时间:2022-02-21 17:08:10" itemprop="dateCreated datePublished" datetime="2022-02-21T17:08:10+08:00">2022-02-21</time>
</span>
<span class="post-meta-item">
<span class="post-meta-item-icon">
<i class="far fa-calendar-check"></i>
</span>
<span class="post-meta-item-text">更新于</span>
<time title="修改时间:2023-10-16 14:58:54" itemprop="dateModified" datetime="2023-10-16T14:58:54+08:00">2023-10-16</time>
</span>
</div>
</div>
</header>
<div class="post-body" itemprop="articleBody">
<blockquote>
<p>又是一个上午请假的日子,想起来之前的年底扯扯淡的文章挖了个上、下篇的坑,现在来填上。</p>
</blockquote>
<p>日子一天天的过去,转移重心后的生活和工作都仍然在继续。</p>
<p>尝试 像 2021 年底来扯扯淡(上) 结尾说的那样的方式,遵从自己思考判断来做决定,而不是一味的为了工作里各种各样的公司战略、KPI、绩效而委曲求全着做一些其实毫无意义的事情。吃了很多年的饼之后,我终于意识到并且坚信:这些人并不是一个好的画饼师傅,而绝大数情况下,他们自己也心知肚明。</p>
<p>而在意识到这个情况之后,我也突然发现之前多年的工作里,一直是“偷懒”式工作,很长的时间里,甚至到了自我感动的地步。那时每天都很忙:</p>
<p>哇啊,公司又有了新的项目孵化目标了,加油啊,赶紧开发部署;</p>
<p>是啊,领导又有了新的方向想要尝试了,等不了,赶紧加班上线;</p>
<p>对啊,产品叕有了新的想法急需验证了,最终版,无脑迭代上架。</p>
<p>…</p>
<p>反反复复,无休无止。</p>
<p>那我就只管努力(偷懒)就好了啊,还思考啥。<br>忙吗?确实忙。可是永远是在为别人忙啊!<br>我就像个兵线上的小兵,永远固定路线、固定速度,被英雄们带着节奏漫无目的的走着、攻击着,然后倒下,最后还是变成别人的升级经验,并且不断重复。<br>就这样,一晃好多年。</p>
<p><strong>“那能怎么办呢?”</strong></p>
<p>是啊,那能怎么办呢?很多次和自己、和别人的聊天里,都会有这个疑问。被带着节奏太久了,无脑忙碌太久了,我们已经习惯了,甚至麻木了。太累了,太忙了,不想思考了。<br>只是每每总有那么一个时刻,我看着斧王的巨斧就在想:总有人要成为的英雄,为什么不能是我呢?<br>或者退一步,即使我终究是一个小兵,那我为啥不做一个有自己节奏的小兵呢?<br>那一刻,我的视角终于开始切换。</p>
<p>于是,我总结出了可能是我的人生迄今为止最重要的一个结论,并决定当做我的人生的第一优先级的奥义:</p>
<p><strong>不论工作还是生活(当然还有 DOTA ),永远要保持自己的节奏!</strong></p>
<p>基于自己当前的现状简单的分析之后,确认可能产生的影响和最坏的结果,感觉一切OK,我开始深信不疑的践行。顺带着,啪!我打开了那个情绪开关。<br>所谓树立中心思想,大刀阔斧改革,战略上藐视一切画饼师傅,战术上细化自己的目标和节奏,以此为前提,毫不迟疑的拒绝掉一切不合理的要求。</p>
<p>“什么,临时有项目需要交接要出差一段时间?”</p>
<p>“我不去,安排其他同事吧”</p>
<p>“什么,有个紧急的需求需要支持下?”</p>
<p>“当前在做需求,直接提个领导排好优先级”</p>
<p>“什么,项目紧急需要缩短工期加班?”</p>
<p>“周末有安排,不加班,自己去找领导协调”</p>
<p>还是那句话,一切的紧急都是基于你的节奏:who TM cares!</p>
<p>按照这个节奏工作下来,发现真TM爽啊!而且,最后你会发现,其实也不会有什么大影响。甚至于,保持“强硬”的态度之后会发现,之前不好沟通协调的事情竟然也开始变得容易了起来。人性从来就是这样。</p>
<p>所谓,好好先生并不能让结果事事好好。讨好型人格更是毫无必要。<br>只是,性格潜移默化,改变无法一蹴而就,意识到就好,慢慢改善。<br>工作学习节奏调整好了之后,接下来可能就是发育期吧,一切还是要慢慢来。</p>
<p>这个时候,我遇见了我的那个她。</p>
<p>懂得我说的:</p>
<blockquote>
<p>“不要回答! 不要回答!! 不要回答!!!”</p>
</blockquote>
<p>梗的她。</p>
<p>懂得大刘笔下</p>
<blockquote>
<p>“只送大脑!”</p>
</blockquote>
<p>的疯狂和浪漫的她。</p>
<p>这让我不得不感慨缘分的奇妙。甚至后面我回想起来,很难想清楚这是不是得益于我这段时间的想法改变之后整个人生活状态的蜕变。不能早,也不能晚,只能是这个时候的遇见才是最正确的时机。</p>
<p>回想着不知道从多久远的以前起,初中?高中?,我被每日负面、悲观、绝望的情绪裹挟着。在快要不堪重负而垮掉时,我开始有意识的训练自己的情绪。我想把自己机器化、数字化,想象着自己的大脑中有一个情绪开关。</p>
<p>啪!关闭它,啊,真好!我不再有任何的情绪了。</p>
<p>啪!打开它,啊,呼吸,忍受无数汹涌如潮水般的情绪把我吞没!</p>
<p>就这样,一天一天,不停的关闭、打开,关闭打开…</p>
<p>经过不知道多少次这样近乎病态式的疯狂训练之后,我觉得我成功了。<br>之后的一些年里,我差不多无限期的关闭着这个开关,这样我觉得生活不那么沉重了,我觉得轻松。如果有个情绪的电图,那这些年我的情绪电图应该几乎是一条长长而乏味的直线。<br>然而人毕竟是人啊,和机器不同啊。如果只是仅仅为了活得轻松而舍弃掉所以的情绪,那又有什么意义呢?</p>
<p>所以,<strong>做个人吧!</strong> 哈哈哈 🙂</p>
<p>现在坐在这里,想着遇见她之后这段时间里一起经历的各种各样的事情和看过的风景,竟然也一时间不知道从何讲起。只是这段时间里,我开始感受到我的情绪了。很开心。原来生活或许不如意事十之八九,却依然让我觉得值得和美好!</p>
<p>总之,感谢生活,感谢大刘,感谢她 🙂</p>
<p>到这里,2021年底的这篇扯淡基本该结束了。上、下这两篇里算是把我这一年的感悟和改变理了七七八八了。后面的日子里,继续保持这自己的节奏,猥琐发育吧!</p>
<p>共勉:<strong>永远要保持自己的节奏!</strong></p>
<p>以上。</p>
</div>
<footer class="post-footer">
<div class="post-eof"></div>
</footer>
</article>
</div>
<div class="post-block">
<article itemscope itemtype="http://schema.org/Article" class="post-content" lang="">
<link itemprop="mainEntityOfPage" href="https://xuanskyer.github.io/2022/01/26/mq/nsq/index/">
<span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
<meta itemprop="image" content="/images/me.jpeg">
<meta itemprop="name" content="xuanskyer">
<meta itemprop="description" content="世界不可能那么远!">
</span>
<span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
<meta itemprop="name" content="世界不可能那么远">
</span>
<header class="post-header">
<h2 class="post-title" itemprop="name headline">
<a href="/2022/01/26/mq/nsq/index/" class="post-title-link" itemprop="url">nsq</a>
</h2>
<div class="post-meta-container">
<div class="post-meta">
<span class="post-meta-item">
<span class="post-meta-item-icon">
<i class="far fa-calendar"></i>
</span>
<span class="post-meta-item-text">发表于</span>
<time title="创建时间:2022-01-26 15:36:10" itemprop="dateCreated datePublished" datetime="2022-01-26T15:36:10+08:00">2022-01-26</time>
</span>
<span class="post-meta-item">
<span class="post-meta-item-icon">
<i class="far fa-calendar-check"></i>
</span>
<span class="post-meta-item-text">更新于</span>
<time title="修改时间:2023-10-16 14:58:54" itemprop="dateModified" datetime="2023-10-16T14:58:54+08:00">2023-10-16</time>
</span>
<span class="post-meta-item">
<span class="post-meta-item-icon">
<i class="far fa-folder"></i>
</span>
<span class="post-meta-item-text">分类于</span>
<span itemprop="about" itemscope itemtype="http://schema.org/Thing">
<a href="/categories/MessageQueue/" itemprop="url" rel="index"><span itemprop="name">MessageQueue</span></a>
</span>
</span>
</div>
</div>
</header>
<div class="post-body" itemprop="articleBody">
<h1 id="关于nsq的问题"><a href="#关于nsq的问题" class="headerlink" title="关于nsq的问题"></a>关于nsq的问题</h1><p><img src="/images/nsq/13257331-ad44d7516e6e53a5.webp" alt="topic,channel和consumer"></p>
<p><img src="/images/nsq/13257331-68f2845de0c8dcfa.webp" alt="consumer"></p>
</div>
<footer class="post-footer">
<div class="post-eof"></div>
</footer>
</article>
</div>
<div class="post-block">
<article itemscope itemtype="http://schema.org/Article" class="post-content" lang="">
<link itemprop="mainEntityOfPage" href="https://xuanskyer.github.io/2022/01/26/mq/kafka/index/">
<span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
<meta itemprop="image" content="/images/me.jpeg">
<meta itemprop="name" content="xuanskyer">
<meta itemprop="description" content="世界不可能那么远!">
</span>
<span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
<meta itemprop="name" content="世界不可能那么远">
</span>
<header class="post-header">
<h2 class="post-title" itemprop="name headline">
<a href="/2022/01/26/mq/kafka/index/" class="post-title-link" itemprop="url">kafaka</a>
</h2>
<div class="post-meta-container">
<div class="post-meta">
<span class="post-meta-item">
<span class="post-meta-item-icon">
<i class="far fa-calendar"></i>
</span>
<span class="post-meta-item-text">发表于</span>
<time title="创建时间:2022-01-26 15:35:52" itemprop="dateCreated datePublished" datetime="2022-01-26T15:35:52+08:00">2022-01-26</time>
</span>
<span class="post-meta-item">
<span class="post-meta-item-icon">
<i class="far fa-calendar-check"></i>
</span>
<span class="post-meta-item-text">更新于</span>
<time title="修改时间:2023-10-16 14:58:54" itemprop="dateModified" datetime="2023-10-16T14:58:54+08:00">2023-10-16</time>
</span>
<span class="post-meta-item">
<span class="post-meta-item-icon">
<i class="far fa-folder"></i>
</span>
<span class="post-meta-item-text">分类于</span>
<span itemprop="about" itemscope itemtype="http://schema.org/Thing">
<a href="/categories/MessageQueue/" itemprop="url" rel="index"><span itemprop="name">MessageQueue</span></a>
</span>
</span>
</div>
</div>
</header>
<div class="post-body" itemprop="articleBody">
<!-- toc -->
<h1 id="kafka-架构图"><a href="#kafka-架构图" class="headerlink" title="kafka 架构图"></a>kafka 架构图</h1><p><img src="/images/kafka/architecture.png" alt="kafka架构图"></p>
<h1 id="关于Kafka-的问题"><a href="#关于Kafka-的问题" class="headerlink" title="关于Kafka 的问题"></a>关于Kafka 的问题</h1><h2 id="kafka-是怎么做到-高吞吐率、速度快的?"><a href="#kafka-是怎么做到-高吞吐率、速度快的?" class="headerlink" title="kafka 是怎么做到 高吞吐率、速度快的?"></a>kafka 是怎么做到 高吞吐率、速度快的?</h2><h3 id="顺序读写"><a href="#顺序读写" class="headerlink" title="顺序读写"></a>顺序读写</h3><h4 id="partition-并行处理"><a href="#partition-并行处理" class="headerlink" title="partition 并行处理"></a>partition 并行处理</h4><h3 id="Page-Cache"><a href="#Page-Cache" class="headerlink" title="Page Cache"></a>Page Cache</h3><h3 id="零拷贝"><a href="#零拷贝" class="headerlink" title="零拷贝"></a>零拷贝</h3><p><img src="/images/kafka/zerocopy.svg" alt="零拷贝原理"></p>
<h4 id="mmap、sendfile"><a href="#mmap、sendfile" class="headerlink" title="mmap、sendfile"></a>mmap、sendfile</h4><ul>
<li>Producer生产的数据持久化到broker,采用mmap文件映射</li>
<li>Customer从broker读取数据,采用sendfile,将磁盘文件读到OS内核缓冲区后,直接转到socket buffer进行网络发送。</li>
</ul>
<h4 id="用户缓冲区、内核缓冲区、socket-buffer、NIC-buffer"><a href="#用户缓冲区、内核缓冲区、socket-buffer、NIC-buffer" class="headerlink" title="用户缓冲区、内核缓冲区、socket buffer、NIC buffer"></a>用户缓冲区、内核缓冲区、socket buffer、NIC buffer</h4><h4 id="定期-flush-到磁盘"><a href="#定期-flush-到磁盘" class="headerlink" title="定期 flush 到磁盘"></a>定期 flush 到磁盘</h4><h3 id="分区分段-索引"><a href="#分区分段-索引" class="headerlink" title="分区分段+索引"></a>分区分段+索引</h3><h3 id="数据压缩"><a href="#数据压缩" class="headerlink" title="数据压缩"></a>数据压缩</h3><h3 id="批量读写"><a href="#批量读写" class="headerlink" title="批量读写"></a>批量读写</h3><h2 id="kafka-如何保证不重复消费又不丢失数据?"><a href="#kafka-如何保证不重复消费又不丢失数据?" class="headerlink" title="kafka 如何保证不重复消费又不丢失数据?"></a>kafka 如何保证不重复消费又不丢失数据?</h2><p>首先我们要了解的是message delivery semantic 也就是消息传递语义。</p>
<p>这是一个通用的概念,也就是消息传递过程中消息传递的保证性。</p>
<p>分为三种:</p>
<ul>
<li><p>最多一次(at most once):</p>
<p>消息可能丢失也可能被处理,但最多只会被处理一次。<br>可能丢失 不会重复</p>
</li>
<li><p>至少一次(at least once): 消息不会丢失,但可能被处理多次。<br>可能重复 不会丢失</p>
</li>
<li><p>精确传递一次(exactly once): 消息被处理且只会被处理一次。</p>
<p>不丢失 不重复 就一次</p>
</li>
</ul>
<p>而kafka其实有两次消息传递,一次生产者发送消息给kafka,一次消费者去kafka消费消息。</p>
<p>两次传递都会影响最终结果,</p>
<p>两次都是精确一次,最终结果才是精确一次。</p>
<p>两次中有一次会丢失消息,或者有一次会重复,那么最终的结果就是可能丢失或者重复的。</p>
<h3 id="分布式存储"><a href="#分布式存储" class="headerlink" title="分布式存储"></a>分布式存储</h3><h3 id="producer-端"><a href="#producer-端" class="headerlink" title="producer 端"></a>producer 端</h3><h4 id="幂等的producer(idempotent-producer)"><a href="#幂等的producer(idempotent-producer)" class="headerlink" title="幂等的producer(idempotent producer)"></a>幂等的producer(idempotent producer)</h4><h4 id="Kafka-的-ISR-机制"><a href="#Kafka-的-ISR-机制" class="headerlink" title="Kafka 的 ISR 机制"></a>Kafka 的 ISR 机制</h4><p>所以如果要让写入 Kafka 的数据不丢失,你需要保证如下几点:</p>
<ul>
<li><p>每个 Partition 都至少得有 1 个 Follower 在 ISR 列表里</p>
</li>
<li><p>每次写入数据的时候,都要求至少写入 Partition Leader 成功,同时还有至少一个 ISR 里的 Follower 也写入成功,才算这个写入是成功了。</p>
</li>
</ul>
<p>如果不满足上述两个条件,那就一直写入失败,让生产系统不停的尝试重试,直到满足上述两个条件,然后才能认为写入成功。</p>
<p>按照上述思路去配置相应的参数,才能保证写入 Kafka 的数据不会丢失。</p>
<h2 id="参考文献"><a href="#参考文献" class="headerlink" title="参考文献"></a>参考文献</h2><ul>
<li><p><a target="_blank" rel="noopener" href="https://zhuanlan.zhihu.com/p/120967989">Kafka为什么吞吐量大、速度快?</a></p>
</li>
<li><p><a target="_blank" rel="noopener" href="https://zhuanlan.zhihu.com/p/78335525">Kafka零拷贝</a></p>
</li>
<li><p><a target="_blank" rel="noopener" href="https://zhuanlan.zhihu.com/p/183808742">终于知道Kafka为什么这么快了!</a></p>
</li>
<li><p><a target="_blank" rel="noopener" href="https://www.cnblogs.com/gxyandwmm/p/11432598.html">Kafka如何保证百万级写入速度以及保证不丢失不重复消费</a></p>
</li>
</ul>
</div>
<footer class="post-footer">
<div class="post-eof"></div>
</footer>
</article>
</div>
<div class="post-block">
<article itemscope itemtype="http://schema.org/Article" class="post-content" lang="">
<link itemprop="mainEntityOfPage" href="https://xuanskyer.github.io/2021/12/10/2021%E4%B8%8A/">
<span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
<meta itemprop="image" content="/images/me.jpeg">
<meta itemprop="name" content="xuanskyer">
<meta itemprop="description" content="世界不可能那么远!">
</span>
<span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
<meta itemprop="name" content="世界不可能那么远">
</span>
<header class="post-header">
<h2 class="post-title" itemprop="name headline">
<a href="/2021/12/10/2021%E4%B8%8A/" class="post-title-link" itemprop="url">2021 年底来扯扯淡(上)</a>
</h2>
<div class="post-meta-container">
<div class="post-meta">
<span class="post-meta-item">
<span class="post-meta-item-icon">
<i class="far fa-calendar"></i>
</span>
<span class="post-meta-item-text">发表于</span>
<time title="创建时间:2021-12-10 12:50:44" itemprop="dateCreated datePublished" datetime="2021-12-10T12:50:44+08:00">2021-12-10</time>
</span>
<span class="post-meta-item">
<span class="post-meta-item-icon">
<i class="far fa-calendar-check"></i>
</span>
<span class="post-meta-item-text">更新于</span>
<time title="修改时间:2023-10-16 14:58:54" itemprop="dateModified" datetime="2023-10-16T14:58:54+08:00">2023-10-16</time>
</span>
<span class="post-meta-item">
<span class="post-meta-item-icon">
<i class="far fa-folder"></i>
</span>
<span class="post-meta-item-text">分类于</span>
<span itemprop="about" itemscope itemtype="http://schema.org/Thing">
<a href="/categories/%E6%88%91%E5%BD%93%E7%84%B6%E5%9C%A8%E6%89%AF%E6%B7%A1/" itemprop="url" rel="index"><span itemprop="name">我当然在扯淡</span></a>
</span>
</span>
</div>
</div>
</header>
<div class="post-body" itemprop="articleBody">
<p>最近可能由于工(刀)作(塔)过于辛苦,导致我今天早上闹钟响的时候,只有手醒了。<br>于是睡过头了。<br>然后顺手请个半天假。<br>一套操作感觉就是这么行云流水。</p>
<p>所以现在有时间坐在电脑旁来扯这个淡。</p>
<p>想想2021年马上就要过去了,时间真快啊!<br>仔细回顾下今年都经历了啥呢?好像大的分界点是从年中6月份项目组解散开始的吧。如果是在小说里,这个一定是一个很好的故事展开线,哈哈。<br>6月份的时候,在大家刚结束了上周末的一次常规加班之后的一个周一,领导不出所料的突然宣布:项目组原地爆炸。现在我回过头来看感觉很魔幻。那种感觉就像,你们一队人正在和对面开团:<br>我方斧王先手果断跳吼直接控住对面所有人!<br>宙斯直接开大!<br>sven开大跳上去,准备团灭对面!<br>然后,停电了!!!<br>沉默了一会后,大家揪着的一颗心总算了放了下来。因为真实的情况是,斧王sven其实在对面:)。<br>接下来差不多一个月的时间里,事情的发展和大多数无节操的的IT公司的剧情没什么太大区别:临时抽调一个经验丰富的HR来挨个找大家言辞亲切的谈话,大概的内容也很明白:要么流放到其他项目组,要么自己滚,别想着N+1。<br>本想着争取一下的,无奈发现孤立无援,领导也来劝:公司也不容易啊。<br>大家相视而笑,悟了。<br>再后面的一段时间里,大家有的自谋出路走了,有的迫于无奈接受流放,有的不知所踪。最终,大家都有了光明的穷途。</p>
<p>然后时间就到了7月份。我开始了我长达半年的流放的日子,而且似乎看起来结束的日子还是遥遥无期。</p>
<p>现在细细回想起来,有点塞翁失马的感觉。</p>
<p>这下半年的时间可以说是我从毕业工作到现在,业务工作最少的一段时间了。正是因为这样,我有了大把大把的时间来思考、反思、总结。</p>
<p>最后反思下来的结论是:人不能太闲啊!真的好讽刺啊! </p>
<p><strong>这个时代的节奏过于碎片和快速,使得你渐渐变得已经无法系统性的思考问题。</strong></p>
<p>我们总是为了这样那样的事情左右,为了眼前的问题寻找临时性的救火方案。这是一个漩涡陷阱,让所有深陷其中的人终日疲于奔命,无法停下,也无法逃脱。而这就是我这近十年的工作和生活状态啊!<br>每年,每月,每一天,我就在这个漩涡中努力的前进着以保持自己不会被吞噬。这样的日子不停歇的循环往复着,就像那个一日囚里的人一样。庆幸的是,心里也一直有着挣脱的期盼和希望,总觉得这些都是暂时的,会有那么一天事情会迎来转机。这些年的日子里,竟然就是靠着这个近乎盲目的信念支撑着走了过来。</p>
<p>而且,似乎还要这么走下去。<br>这就是生活的真相啊!一切并不会想电影里演的那样励志:突然有一天,主角有了奇遇一切都开挂般的好了起来。一切似乎都没么变化。<br>然后,项目黄了。这个漩涡似乎?竟然?真的停了下来。<br>经过短暂的眩晕之后,我发现自己很快的适应了起来。<br>这期间,我也终于第一次完整的看完了一届TI。当然,其中详情就不去过多描述了,总之全村的希望最后败给了一个颠勺的大厨,就是这么简单。<br>然后,经过了几天的短暂抑郁之后,我发现好像悟了!<br>因为,我突然发现我姓张,张三的张。</p>
<p><strong>张三说:人要接受自己的有限性。</strong></p>
<p>这种感觉很奇妙。这个事情对我来说,就好像是我在打野的时候突然插了个眼在高台上。我感觉自己的生活突然明亮了起来,视野清晰!<br>人甚至一下子变得洒脱起来,一种莫名其妙的自信油然而生!我感觉自己浑身充满了能量!<br>我隐隐的感觉到:我到6了! </p>
<p>于是,我开始试着把重心从工作转移到生活中去。我发现没有996,没有那些感动自己、缓解领导焦虑的加班,天也没有塌下来。我开始慢慢体会到了什么是真实感。<br>生活,也慢慢的变得美好起来。 </p>
<p>未完,待续。</p>
</div>
<footer class="post-footer">
<div class="post-eof"></div>
</footer>
</article>
</div>
<div class="post-block">
<article itemscope itemtype="http://schema.org/Article" class="post-content" lang="">
<link itemprop="mainEntityOfPage" href="https://xuanskyer.github.io/2021/11/24/go-type-assertion/">
<span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
<meta itemprop="image" content="/images/me.jpeg">
<meta itemprop="name" content="xuanskyer">
<meta itemprop="description" content="世界不可能那么远!">
</span>
<span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
<meta itemprop="name" content="世界不可能那么远">
</span>
<header class="post-header">
<h2 class="post-title" itemprop="name headline">
<a href="/2021/11/24/go-type-assertion/" class="post-title-link" itemprop="url">golang断言:一个蛋疼的处理场景</a>
</h2>
<div class="post-meta-container">
<div class="post-meta">
<span class="post-meta-item">
<span class="post-meta-item-icon">
<i class="far fa-calendar"></i>
</span>
<span class="post-meta-item-text">发表于</span>
<time title="创建时间:2021-11-24 15:33:57" itemprop="dateCreated datePublished" datetime="2021-11-24T15:33:57+08:00">2021-11-24</time>
</span>
<span class="post-meta-item">
<span class="post-meta-item-icon">
<i class="far fa-calendar-check"></i>
</span>
<span class="post-meta-item-text">更新于</span>
<time title="修改时间:2023-10-16 14:58:54" itemprop="dateModified" datetime="2023-10-16T14:58:54+08:00">2023-10-16</time>
</span>
<span class="post-meta-item">
<span class="post-meta-item-icon">
<i class="far fa-folder"></i>
</span>
<span class="post-meta-item-text">分类于</span>
<span itemprop="about" itemscope itemtype="http://schema.org/Thing">
<a href="/categories/Golang/" itemprop="url" rel="index"><span itemprop="name">Golang</span></a>
</span>
,
<span itemprop="about" itemscope itemtype="http://schema.org/Thing">
<a href="/categories/%E6%8A%80%E6%9C%AF/" itemprop="url" rel="index"><span itemprop="name">技术</span></a>
</span>
</span>
</div>
</div>
</header>
<div class="post-body" itemprop="articleBody">
<p>这一切都来源于一个蛋疼的需求场景处理:</p>
<p>因为历史原因,一个需要用到的JSON数据被整个缓存进Redis的一个key中,大概如下:</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">127.0.0.1:6379> get dt</span><br><span class="line">"{\"address\":[{\"duration\":90,\"format\":\"mp4\",\"url\":\"xxx.mp4\",\"ext\":\"{\\\"key\\\":\\\"val\\\"}\"},{\"duration\":90,\"format\":\"mp4\",\"url\":\"xxx.mp4\",\"ext\":\"{\\\"key\\\":\\\"val\\\"}\"}],\"value\":\"web\"}"</span><br><span class="line">127.0.0.1:6379></span><br></pre></td></tr></table></figure>
<p>这里还是做了脱敏处理,实际的情形JSON的层级更深…<br>格式化显示的JSON结构大概是这样: </p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br></pre></td><td class="code"><pre><span class="line">{</span><br><span class="line"> "address": [</span><br><span class="line"> {</span><br><span class="line"> "duration": 90,</span><br><span class="line"> "format": "mp4",</span><br><span class="line"> "url": "xxx.mp4",</span><br><span class="line"> "ext": "{\"key\":\"val\"}"</span><br><span class="line"> },</span><br><span class="line"> {</span><br><span class="line"> "duration": 90,</span><br><span class="line"> "format": "mp4",</span><br><span class="line"> "url": "xxx.mp4",</span><br><span class="line"> "ext": "{\"key\":\"val\"}"</span><br><span class="line"> }</span><br><span class="line"> ],</span><br><span class="line"> "value": "web"</span><br><span class="line">}</span><br></pre></td></tr></table></figure>
<p>现在要做的是: address 里的每个元素的 url 字段需要更新。</p>
<p>现在知道的是:address 的值 是一个数组,数组的每个元素是一个map[string]interface{} 类型,map里的元素除了 <strong>“url”: “xxx.mp4”</strong>, 其他的数量不确定</p>
<p>实现代码大概如下(方便展示,省略了Redis读写的步骤):</p>
<figure class="highlight go"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br></pre></td><td class="code"><pre><span class="line">detailByte := []<span class="keyword">byte</span>(<span class="string">`{"address":[{"duration":90,"format":"mp4","url":"xxx.mp4","ext":"{\"key\":\"val\"}"},{"duration":90,"format":"mp4","url":"xxx.mp4","ext":"{\"key\":\"val\"}"}],"value":"web"}`</span>)</span><br><span class="line">detail := <span class="built_in">make</span>(<span class="keyword">map</span>[<span class="keyword">string</span>]<span class="keyword">interface</span>{}, <span class="number">0</span>)</span><br><span class="line">json.Unmarshal(detailByte, &detail)</span><br><span class="line">formatJson, _ := json.MarshalIndent(detail, <span class="string">""</span>, <span class="string">" "</span>)</span><br><span class="line">fmt.Println(<span class="string">"before: "</span>, <span class="keyword">string</span>(formatJson))</span><br><span class="line"><span class="keyword">if</span> address, ok := detail[<span class="string">"address"</span>]; ok {</span><br><span class="line"><span class="keyword">if</span> item, ok2 := address.([]<span class="keyword">interface</span>{}); ok2 {</span><br><span class="line"><span class="keyword">for</span> index, value := <span class="keyword">range</span> item {</span><br><span class="line"><span class="keyword">if</span> vMap, ok3 := value.(<span class="keyword">map</span>[<span class="keyword">string</span>]<span class="keyword">interface</span>{}); ok3 {</span><br><span class="line"><span class="keyword">if</span> _, ok4 := vMap[<span class="string">"url"</span>];ok4 {</span><br><span class="line">vMap[<span class="string">"url"</span>] = <span class="string">"wtf.mp4"</span></span><br><span class="line">}</span><br><span class="line">item[index] = vMap</span><br><span class="line">}</span><br><span class="line">}</span><br><span class="line">detail[<span class="string">"address"</span>] = item</span><br><span class="line">}</span><br><span class="line">}</span><br><span class="line">formatJson, _ = json.MarshalIndent(detail, <span class="string">""</span>, <span class="string">" "</span>)</span><br><span class="line">fmt.Println(<span class="string">"after: "</span>, <span class="keyword">string</span>(formatJson))</span><br></pre></td></tr></table></figure>
<p>运行结果:</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br></pre></td><td class="code"><pre><span class="line">before: {</span><br><span class="line"> "address": [</span><br><span class="line"> {</span><br><span class="line"> "duration": 90,</span><br><span class="line"> "ext": "{\"key\":\"val\"}",</span><br><span class="line"> "format": "mp4",</span><br><span class="line"> "url": "xxx.mp4"</span><br><span class="line"> },</span><br><span class="line"> {</span><br><span class="line"> "duration": 90,</span><br><span class="line"> "ext": "{\"key\":\"val\"}",</span><br><span class="line"> "format": "mp4",</span><br><span class="line"> "url": "xxx.mp4"</span><br><span class="line"> }</span><br><span class="line"> ],</span><br><span class="line"> "value": "web"</span><br><span class="line">}</span><br><span class="line">after: {</span><br><span class="line"> "address": [</span><br><span class="line"> {</span><br><span class="line"> "duration": 90,</span><br><span class="line"> "ext": "{\"key\":\"val\"}",</span><br><span class="line"> "format": "mp4",</span><br><span class="line"> "url": "wtf.mp4"</span><br><span class="line"> },</span><br><span class="line"> {</span><br><span class="line"> "duration": 90,</span><br><span class="line"> "ext": "{\"key\":\"val\"}",</span><br><span class="line"> "format": "mp4",</span><br><span class="line"> "url": "wtf.mp4"</span><br><span class="line"> }</span><br><span class="line"> ],</span><br><span class="line"> "value": "web"</span><br><span class="line">}</span><br></pre></td></tr></table></figure>
<p>怎么说呢,实现了感觉又没有真正实现…</p>
<p>哎,蛋疼。</p>
</div>
<footer class="post-footer">
<div class="post-eof"></div>
</footer>
</article>
</div>
<div class="post-block">
<article itemscope itemtype="http://schema.org/Article" class="post-content" lang="">
<link itemprop="mainEntityOfPage" href="https://xuanskyer.github.io/2021/11/15/%E8%80%8C%E4%BB%8A%E5%A4%A9%E6%98%AF%E4%BD%A0%E5%89%A9%E4%BD%99%E4%BA%BA%E7%94%9F%E7%9A%84%E5%BC%80%E5%A7%8B/">
<span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
<meta itemprop="image" content="/images/me.jpeg">
<meta itemprop="name" content="xuanskyer">
<meta itemprop="description" content="世界不可能那么远!">
</span>
<span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
<meta itemprop="name" content="世界不可能那么远">
</span>
<header class="post-header">
<h2 class="post-title" itemprop="name headline">
<a href="/2021/11/15/%E8%80%8C%E4%BB%8A%E5%A4%A9%E6%98%AF%E4%BD%A0%E5%89%A9%E4%BD%99%E4%BA%BA%E7%94%9F%E7%9A%84%E5%BC%80%E5%A7%8B/" class="post-title-link" itemprop="url">而今天是你剩余人生的开始</a>
</h2>
<div class="post-meta-container">
<div class="post-meta">
<span class="post-meta-item">
<span class="post-meta-item-icon">
<i class="far fa-calendar"></i>
</span>
<span class="post-meta-item-text">发表于</span>
<time title="创建时间:2021-11-15 11:18:31" itemprop="dateCreated datePublished" datetime="2021-11-15T11:18:31+08:00">2021-11-15</time>
</span>
<span class="post-meta-item">
<span class="post-meta-item-icon">
<i class="far fa-calendar-check"></i>
</span>
<span class="post-meta-item-text">更新于</span>
<time title="修改时间:2023-10-16 14:58:54" itemprop="dateModified" datetime="2023-10-16T14:58:54+08:00">2023-10-16</time>
</span>
<span class="post-meta-item">
<span class="post-meta-item-icon">
<i class="far fa-folder"></i>
</span>
<span class="post-meta-item-text">分类于</span>
<span itemprop="about" itemscope itemtype="http://schema.org/Thing">
<a href="/categories/%E6%88%91%E5%BD%93%E7%84%B6%E5%9C%A8%E6%89%AF%E6%B7%A1/" itemprop="url" rel="index"><span itemprop="name">我当然在扯淡</span></a>
</span>
</span>
</div>
</div>
</header>
<div class="post-body" itemprop="articleBody">
<blockquote>
<p>在最后</p>
<p>总会看见自己</p>
<p>你一直知道</p>
<p>那是尽头</p>
<p>也是开始</p>
</blockquote>
</div>
<footer class="post-footer">
<div class="post-eof"></div>
</footer>
</article>
</div>
<div class="post-block">
<article itemscope itemtype="http://schema.org/Article" class="post-content" lang="">
<link itemprop="mainEntityOfPage" href="https://xuanskyer.github.io/2021/10/30/lock-atomic-cas-mesi/">
<span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
<meta itemprop="image" content="/images/me.jpeg">
<meta itemprop="name" content="xuanskyer">
<meta itemprop="description" content="世界不可能那么远!">
</span>
<span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
<meta itemprop="name" content="世界不可能那么远">
</span>
<header class="post-header">
<h2 class="post-title" itemprop="name headline">
<a href="/2021/10/30/lock-atomic-cas-mesi/" class="post-title-link" itemprop="url">并发安全&锁&原子操作&CAS&MESI</a>
</h2>
<div class="post-meta-container">
<div class="post-meta">
<span class="post-meta-item">
<span class="post-meta-item-icon">
<i class="far fa-calendar"></i>
</span>
<span class="post-meta-item-text">发表于</span>
<time title="创建时间:2021-10-30 12:41:14" itemprop="dateCreated datePublished" datetime="2021-10-30T12:41:14+08:00">2021-10-30</time>
</span>
<span class="post-meta-item">