Go語言愛好者周刊:第 98 期 — 附上期題解
這里記錄每周值得分享的 Go 語言相關(guān)內(nèi)容,周日發(fā)布。
本周刊開源(GitHub:polaris1119/golangweekly[1]),歡迎投稿,推薦或自薦文章/軟件/資源等,請提交 issue[2] 。
鑒于一些人可能沒法堅(jiān)持把英文文章看完,因此,周刊中會盡可能推薦優(yōu)質(zhì)的中文文章。優(yōu)秀的英文文章,我們的 GCTT 組織會進(jìn)行翻譯。
由于微信公眾號不支持外鏈,文中大量鏈接可通過文末「閱讀原文」查看。

題圖:生成的 O’RLY 圖書封面。地址見后文。
刊首語
上期周刊題解見:《說好 defer 在 return 之后執(zhí)行,為什么結(jié)果卻不是》。
這次來一道更簡單的題目。以下代碼輸出什么?
package main
import (
"fmt"
)
func main() {
a := make([]int, 20)
a = []int{7, 8, 9, 10}
b := a[15:16]
fmt.Println(b)
}
A:[0];B:panic;C:7;D:不清楚
資訊
1、GoLand 2021.2 EAP 版本可用[3]
免費(fèi)試用 30 天。
2、測試版已經(jīng)有 Fuzzing 了[4]
官方博文。
3、gock 1.1 發(fā)布[5]
讓 HTTP 流量 mock 和測試變得簡單。
4、GoLand 的 TinyGo 插件[6]
發(fā)布在 GoLand 官方博客。
5、go-redis 8.10.0 發(fā)布[7]
類型安全的 Redis 客戶端。
安全小版本更新。
誰在招 Gopher
整理近期的 Go 職位。有招聘需求可以到「Go招聘」發(fā)布!
文章
1、Go1.16 中的新函數(shù) signal.NotifyContext 怎么用?
os/signal 這個(gè)包大家可能用的不多。但自從 Go1.8 起,有些人開始使用這個(gè)包了。
有些錯(cuò)誤很常見。
uber 開源的提供快速,結(jié)構(gòu)化,高性能的日志記錄包。
4、驚!這個(gè) Go 開源項(xiàng)目號稱「不改一行代碼做秒殺」
看到耗子叔發(fā)推文推薦了一個(gè)新開源的網(wǎng)關(guān):Easegress。
stringer 命令的目標(biāo)是自動生成滿足 fmt.Stringer 接口的方法。它將為指定的類型生成 String() 方法, String() 返回的字符串用于描述該類型。
高端黑?
7、用 cgo 生成用于 cgo 的 C 兼容的結(jié)構(gòu)體
cgo 使用者可以看看。
8、竟然還在爭論是否學(xué)Go?本文徹底終結(jié)該話題
永遠(yuǎn)的話題。
什么是可重入鎖?
10、如何設(shè)計(jì) API 接口,實(shí)現(xiàn)統(tǒng)一格式返回?
前端通常會通過后臺提供的接口來獲取數(shù)據(jù)來完成前端頁面的渲染,前端可以為 PC 端、M 端、小程序、APP 等。
這是一個(gè) API 設(shè)計(jì)的思想實(shí)驗(yàn)。
12、搞 Go 要了解的 2 個(gè) Header,你知道嗎?
SliceHeader 和 StringHeader。
開源項(xiàng)目
1、gopatch[8]
Go 實(shí)現(xiàn)的 patch 工具(類似 Unix 的 patch 工具),Uber 出品。
2、quic[9]
Go 語言 quic 實(shí)現(xiàn)。
3、tstorage[10]
快速時(shí)間序列數(shù)據(jù)庫。
4、sonic[11]
字節(jié)開源的高性能 json 編解碼庫。
5、easegress[12]
全能型流量編排系統(tǒng)。國人開發(fā)。
6、go-i18n[13]
Go 國際化庫。
資源&&工具
1、Go 性能工具 Cheat Sheet[14]
建議收藏。
2、GoWebSSH[15]
Go 實(shí)現(xiàn)的一個(gè) WebSSH 管理工具,支持文件上傳下載。作者投稿。
3、orly[16]
使用 Go 生成你自己的 O’RLY 動物書封面。在線使用:https://orly.nanmu.me/。
4、xo-grpc[17]
從數(shù)據(jù)庫創(chuàng)建 gRPC 服務(wù)器。
5、netz[18]
發(fā)現(xiàn)互聯(lián)網(wǎng)組件服務(wù)的配置錯(cuò)誤。
6、ebpf-profiler[19]
用 eBPF 編寫的簡單跨語言(Go、Rust、C/C++)連續(xù)性能剖析器。地址:https://github.com/pixie-labs/pixie-demos/tree/main/ebpf-profiler。
7、gProfiler[20]
結(jié)合多個(gè)采樣分析器,對 CPU 開銷進(jìn)行統(tǒng)一的可視化分析,支持 Go、Java 和 Python。

8、vtprotobuf[21]
一個(gè) protobuf 編譯器,為 ProtoBuf APIv2 生成優(yōu)化的 marshaling 和 unmarshaling Go 代碼。
9、slides[22]
Go 實(shí)現(xiàn)的基于命令行終端的 slide 演示工具。
10、promdump[23]
支持讀取和打印 Prometheus 持久性數(shù)據(jù)塊,支持按時(shí)間范圍過濾持久性塊。
訂閱
這個(gè)周刊每周日發(fā)布,同步更新在Go語言中文網(wǎng)[24]和微信公眾號[25]。
微信搜索"Go語言中文網(wǎng)"或者掃描二維碼,即可訂閱。
往期推薦
參考資料
polaris1119/golangweekly: https://github.com/polaris1119/golangweekly
[2]提交 issue: https://github.com/polaris1119/golangweekly/issues
[3]GoLand 2021.2 EAP 版本可用: https://blog.jetbrains.com/go/2021/05/28/goland-2021-2-early-access-program-is-open/
[4]測試版已經(jīng)有 Fuzzing 了: https://blog.golang.org/fuzz-beta
[5]gock 1.1 發(fā)布: https://github.com/h2non/gock
[6]GoLand 的 TinyGo 插件: https://blog.jetbrains.com/go/2021/06/02/tinygo-for-tiny-applications-discover-a-new-plugin-for-goland/
[7]go-redis 8.10.0 發(fā)布: https://github.com/go-redis/redis
[8]gopatch: https://github.com/uber-go/gopatch
[9]quic: https://github.com/goburrow/quic
[10]tstorage: https://github.com/nakabonne/tstorage
[11]sonic: https://github.com/bytedance/sonic
[12]easegress: https://github.com/megaease/easegress
[13]go-i18n: https://github.com/nicksnyder/go-i18n
[14]Go 性能工具 Cheat Sheet: https://steveazz.xyz/blog/go-performance-tools-cheat-sheet/
[15]GoWebSSH: https://github.com/o8oo8o/GoWebSSH
[16]orly: https://github.com/nanmu42/orly
[17]xo-grpc: https://github.com/walterwanderley/xo-grpc
[18]netz: https://github.com/SpectralOps/netz
[19]ebpf-profiler: https://blog.px.dev/cpu-profiling-2/
[20]gProfiler: https://github.com/Granulate/gprofiler
[21]vtprotobuf: https://github.com/planetscale/vtprotobuf
[22]slides: https://github.com/maaslalani/slides
[23]promdump: https://github.com/ihcsim/promdump
[24]Go語言中文網(wǎng): https://studygolang.com/go/weekly
[25]微信公眾號: https://weixin.sogou.com/weixin?query=Go%E8%AF%AD%E8%A8%80%E4%B8%AD%E6%96%87%E7%BD%91
