這裡記錄每周值得分享的 Go 語言相關內容,周日發布。
本周刊開源(GitHub:polaris1119/golangweekly[1]),歡迎投稿,推薦或自薦文章/軟體/資源等,請提交 issue[2] 。
鑑於大部分人可能沒法堅持把英文文章看完,因此,周刊中會儘可能推薦優質的中文文章。優秀的英文文章,我們的 GCTT 組織會進行翻譯。
題圖:TamaGo,一個 TinyGo ARM 替代品
Go101 作者發布了一道有意思的題目,這道題主要考察細節點,Go101 這本書也是以摳細節著稱。看看這道題,以下程序輸出什麼?(單選)
package mainconst s = "Go101.org"// len(s) == 9// 1 << 9 == 512// 512 / 128 == 4var a byte = 1 << len(s) / 128var b byte = 1 << len(s[:]) / 128func main() { println(a, b)}
這裡涉及到兩個知識點,在 Go 語言規範中都有明確的說明,但確實很細節。你答對了嗎?原因知曉嗎?
1、Go 對靜態資源的內嵌支持的提案被接受,在 Go1.16 實現[3]
提案在這裡:https://github.com/golang/proposal/blob/master/design/draft-embed.md。
2、pkg.go.dev 計劃重新設計[4]
之前寫文章分析過,現有的設計確實。。。期待重新設計能夠更好。
3、TinyGo 對 ESP32 和 ESP8266 的初始支持[5]
你可能已經聽說過,上周我們在 0.15 版本的 TinyGo 中添加了 ESP32 和 ESP8266 支持。如果你熟悉微控制器,這將是令人振奮的消息,因為這些 ESP 設備既便宜又受歡迎。但是,這只是一個初始埠,在你可以利用 WiFi 和藍牙等所有功能之前,還有很多工作要做。
4、Caddy 2.2.0 發布[6]
支持 ZeroSSL[7] 和 HTTP/2 server push。
5、twirp 7.1 發布[8]
具有 Protobuf 服務定義的簡單 RPC 框架。
6、Go 1.16 go module 機制默認開啟[9]
官方還是很謹慎。沒有使用 module 真的說不過去了。
7、k6 v0.28.0 發布[10]
k6 是一種現代的開源性能和負載測試工具,用 Go 編寫並且可以用 JavaScript 編寫腳本。
1、Go:跨團隊協作時如何共享對象
對象怎麼可以共享呢?
2、Go Playground 還能這麼玩?
多人協同編輯。
3、unsafe 真就 unsafe 嗎?
知道自己在幹什麼還是可以使用的。
4、你必須了解的 Go 歷史:幫助理解 Go 的設計思想和每個版本的優勢或弱點
回顧 Go 版本的發展歷史。
5、2 分鐘定製一個高大上的 GitHub 首頁
GitHub 這個功能出來有一段時間了,GitHub 粉應該定製下。
6、手撕 hashicorp/raft 算法【萬字長文】
本文是第 104 期手撕 hashicrop/raft 算法的文字版,建議搭配著視頻(本文文末)一起閱讀。
7、原來 9 張圖就可以弄懂 Go 內存管理
從高層看內存管理的文章,而不拘於很多細節。
8、Go 程序性能分析[11]
性能分析是排查內存洩露等問題的常見手段,可以讓我們了解和捕獲到程序堆內存和 Profile 信息,方便定位問題。Go 原生提供了豐富的分析工具,下面是通過幾個內存洩露的案例對 Go 程序做性能分析,並介紹相關工具原理和細節。
1、tamago[12]
適用於 ARM SoC 的 Bare Metal Go。該框架可在裸機 ARM System-on-Chip(SoC)設置(包括到目前為止的 Raspberry Pi 2 和 Zero)上啟用 Go 應用的編譯和執行。可能是更成熟的 TinyGo[13] 的唯一 ARM 替代品,因為 TamaGo 修改了標準 Go 發行版,而 TinyGo 是基於 LLVM 的獨特編譯器。
2、go-diagrams[14]
使用 Go 創建漂亮的系統圖。
3、mouthful[15]
Disqus 評論系統的自助託管 Go 替代方案。為你的網站添加評論。
4、twtxt[16]
Go 實現的去中心化類 Twitter的微博客平臺。
5、prisma-client-go[17]
Prisma Client Go 是一個自動生成且完全類型安全的資料庫客戶端。
6、overseer[18]
用於創建可監控、支持優雅重啟和自升級的 Go 應用的 module。
7、gin-metrics[19]
為 prometheus 準備的度量指標,針對 Gin 框架。
8、gomponents[20]
Go 中的聲明性視圖組件,可以渲染為 HTML。這裡有一篇介紹的文章:https://www.maragu.dk/blog/gomponents-declarative-view-components-in-go/。
1、goconst[21]
在 Go 中查找可以被常量替換的重複字符串。
2、logo-ls[22]
現代 ls 命令與 VS Code 一樣的文件"圖標"和 Git 集成。
3、siegfried[23]
基於籤名的文件格式識別。
4、Dbmate[24]
輕量級,與框架無關的資料庫遷移工具。用 Go 語言編寫,但可以與以任何語言編寫的使用資料庫的應用程式一起使用。支持 MySQL,Postgres,SQLite 和 ClickHouse。
5、msfs2020-go[25]
使用 golang 連接到 Microsoft Flight Simulator 2020。
6、程式設計師的數學[26](英文)
免費電子書,專為程式設計師準備。
7、pixelvideo[27]
如何使用 2D 遊戲庫製作視頻的簡單示例。
[1]
polaris1119/golangweekly: https://github.com/polaris1119/golangweekly
[2]
提交 issue: https://github.com/polaris1119/golangweekly/issues
[3]
Go 對靜態資源的內嵌支持的提案被接受,在 Go1.16 實現: https://github.com/golang/go/issues/41191#issuecomment-697710797
[4]
pkg.go.dev 計劃重新設計: https://github.com/golang/go/issues/41585
[5]
TinyGo 對 ESP32 和 ESP8266 的初始支持: https://aykevl.nl/2020/09/tinygo-esp32
[6]
Caddy 2.2.0 發布: https://github.com/caddyserver/caddy/releases/tag/v2.2.0
[7]
ZeroSSL: https://zerossl.com/features/acme/
[8]
twirp 7.1 發布: https://github.com/twitchtv/twirp
[9]
Go 1.16 go module 機制默認開啟: https://go-review.googlesource.com/c/go/+/255052
[10]
k6 v0.28.0 發布: https://github.com/loadimpact/k6/releases/tag/v0.28.0
[11]
Go 程序性能分析: https://segmentfault.com/a/1190000024541490
[12]
tamago: https://github.com/f-secure-foundry/tamago
[13]
TinyGo: https://tinygo.org/
[14]
go-diagrams: https://github.com/blushft/go-diagrams
[15]
mouthful: https://github.com/vkuznecovas/mouthful
[16]
twtxt: https://github.com/jointwt/twtxt
[17]
prisma-client-go: https://github.com/prisma/prisma-client-go
[18]
overseer: https://github.com/jpillora/overseer
[19]
gin-metrics: https://github.com/penglongli/gin-metrics
[20]
gomponents: https://github.com/maragudk/gomponents
[21]
goconst: https://github.com/jgautheron/goconst
[22]
logo-ls: https://github.com/Yash-Handa/logo-ls
[23]
siegfried: https://github.com/richardlehane/siegfried
[24]
Dbmate: https://github.com/amacneil/dbmate
[25]
msfs2020-go: https://github.com/lian/msfs2020-go
[26]
程式設計師的數學: https://yurichev.com/writings/Math-for-programmers.pdf
[27]
pixelvideo: https://github.com/markustenghamn/pixelvideo
[28]
Go語言中文網: https://studygolang.com/go/weekly
[29]
微信公眾號: https://weixin.sogou.com/weixin?query=Go%E8%AF%AD%E8%A8%80%E4%B8%AD%E6%96%87%E7%BD%91