go-nanoid:Go 短 ID 生成庫
“An amazing level of senseless perfectionism, which is simply impossible not to respect.“go-nanoid (github.com/matoous/go-nanoid) 是 JavaScript 知名庫 ai/nanoid (github.com/ai/nanoid) 的 Go 語言實現版本。原版 nanoi ⌘ Read more
Golang 的多任務調度系統:從 BaseJob 到 ProductJob 的 “泛型” 與 “繼承” 實現
突破 Go 語言限制! 揭祕如何用組合 + 接口實現類繼承效果,打造高擴展任務調度系統。以 BaseJob 泛型基類和 ProductJob 實戰爲例,深度解析:配置泛型化設計 方法重寫技巧 運行時多態實現 讓您的 Go 應用輕鬆處理百萬級定時任務!💪🚀 基礎架構:BaseJob 的 “泛型” 實現————————-在 lib/basejob.g ⌘ Read more
Golang 的多任務調度系統:從 BaseJob 到 ProductJob 的 “泛型” 與 “繼承” 實現
突破 Go 語言限制! 揭祕如何用組合 + 接口實現類繼承效果,打造高擴展任務調度系統。以 BaseJob 泛型基類和 ProductJob 實戰爲例,深度解析:配置泛型化設計 方法重寫技巧 運行時多態實現 讓您的 Go 應用輕鬆處理百萬級定時任務!💪🚀 基礎架構:BaseJob 的 “泛型” 實現————————-在 lib/basejob.g ⌘ Read more
《Go 語言精進之路》筆記
最近看完了這本書,又想撿起來寫文這個輸出型的愛好,所以寫篇筆記整理一下閱讀這本書中的查漏補缺。目錄for range 的坑 & 閉坑方式 & go1.22 規避 defer 使用中的注意點 函數作爲一等公民的經典應用 變長參數函數在對象初始化時的妙用 接口在單測中的應用 for range 的坑 & 閉坑方式 & go1.22 規避for range 有兩個常見的坑, ⌘ Read more
《Go 語言精進之路》筆記
最近看完了這本書,又想撿起來寫文這個輸出型的愛好,所以寫篇筆記整理一下閱讀這本書中的查漏補缺。目錄for range 的坑 & 閉坑方式 & go1.22 規避 defer 使用中的注意點 函數作爲一等公民的經典應用 變長參數函數在對象初始化時的妙用 接口在單測中的應用 for range 的坑 & 閉坑方式 & go1.22 規避for range 有兩個常見的坑, ⌘ Read more
終極真相:Go 中的參數傳遞
在 Go 社區常能聽到 “按值傳遞”“按引用傳遞” 兩種說法:基本類型、數組、結構體被稱爲 “按值”; 指針、切片、映射、通道則被稱爲 “按引用”。 然而,上述分類容易造成誤解。在 Go 語言中,一切函數實參都以 值 的形式被複制傳遞。區別僅在於:複製的是 “完整數據”(整數、數組等); 複製的是 “描述符” 或指針(切片、映射、字符串等)。 理解這一點後,再看各類示例便能 ⌘ Read more
終極真相:Go 中的參數傳遞
在 Go 社區常能聽到 “按值傳遞”“按引用傳遞” 兩種說法:基本類型、數組、結構體被稱爲 “按值”; 指針、切片、映射、通道則被稱爲 “按引用”。 然而,上述分類容易造成誤解。在 Go 語言中,一切函數實參都以 值 的形式被複制傳遞。區別僅在於:複製的是 “完整數據”(整數、數組等); 複製的是 “描述符” 或指針(切片、映射、字符串等)。 理解這一點後,再看各類示例便能 ⌘ Read more
Go 加密和解密:實踐指南
無論您是在構建 Web 應用、CLI 工具還是後端服務,加密和解密都是保護數據安全的核心。在 Go 語言中,標準庫和外部包使得實現安全加密變得簡單直接,無需重新發明輪子。本指南深入探討了 Go 中加密和解密的工作原理,並提供了可以編譯運行的實際示例。我們將涵蓋從對稱加密到非對稱加密的基礎知識,並提供清晰的代碼和解釋。爲什麼加密在 Go 中很重要————–加密通過將敏感數據(如用戶 ⌘ Read more
Go 加密和解密:實踐指南
無論您是在構建 Web 應用、CLI 工具還是後端服務,加密和解密都是保護數據安全的核心。在 Go 語言中,標準庫和外部包使得實現安全加密變得簡單直接,無需重新發明輪子。本指南深入探討了 Go 中加密和解密的工作原理,並提供了可以編譯運行的實際示例。我們將涵蓋從對稱加密到非對稱加密的基礎知識,並提供清晰的代碼和解釋。爲什麼加密在 Go 中很重要————–加密通過將敏感數據(如用戶 ⌘ Read more
Gin 框架深度分析
Gin 是一個採用 Go 語言實現的 HTTP web 框架,提供了類似 Martini 的 API,但是性能遠強於 Martini,峯值性能是 Martini 的 40 倍。如果我們的項目需要高性能,毫無疑問採用 Gin。Gin 官網列舉了該項目的 8 個如下關鍵特性:高性能 中間件支持 防崩潰機制 JSON 校驗 路由分組 錯誤管理 內容渲染 示例 D ⌘ Read more
Gin 框架深度分析
Gin 是一個採用 Go 語言實現的 HTTP web 框架,提供了類似 Martini 的 API,但是性能遠強於 Martini,峯值性能是 Martini 的 40 倍。如果我們的項目需要高性能,毫無疑問採用 Gin。Gin 官網列舉了該項目的 8 個如下關鍵特性:高性能 中間件支持 防崩潰機制 JSON 校驗 路由分組 錯誤管理 內容渲染 示例 D ⌘ Read more
數據流的藝術:Go 語言中的 io-Pipe
在 Go 語言中,使用 io.Pipe() 來流式處理數據可以避免將所有數據一次性讀入內存。io.Reader 和 io.Writer 接口堪稱 Go 語言的藝術品,相關討論已有很多。它們簡潔而強大——正如 Go 本身。本文介紹 Go 標準庫中另一個同樣簡潔強大的存在:io.Pipe。// src/io/pipe.gofunc Pipe() (PipeReader, PipeWriter) { p ⌘ Read more
數據流的藝術:Go 語言中的 io-Pipe
在 Go 語言中,使用 io.Pipe() 來流式處理數據可以避免將所有數據一次性讀入內存。io.Reader 和 io.Writer 接口堪稱 Go 語言的藝術品,相關討論已有很多。它們簡潔而強大——正如 Go 本身。本文介紹 Go 標準庫中另一個同樣簡潔強大的存在:io.Pipe。// src/io/pipe.gofunc Pipe() (PipeReader, PipeWriter) { p ⌘ Read more
Go 語言開發技巧合輯,全網整理最全的一篇
一、Go 語言字符串切片排序要對 Go 語言中的字符串切片進行排序,可以使用 sort 包中的 Strings 函數。以下是對一個字符串切片進行升序排序的示例代碼:package mainimport ( ”fmt” ”sort”)func main() { fruits := []string{“banana”, ”apple”, ”orange”, ”pear”} so ⌘ Read more
Go 語言開發技巧合輯,全網整理最全的一篇
一、Go 語言字符串切片排序要對 Go 語言中的字符串切片進行排序,可以使用 sort 包中的 Strings 函數。以下是對一個字符串切片進行升序排序的示例代碼:package mainimport ( ”fmt” ”sort”)func main() { fruits := []string{“banana”, ”apple”, ”orange”, ”pear”} so ⌘ Read more
We covered quite some ground in the two and a half hours today. The weather was nice, mostly cloudy and just 23°C. That’s also why we decided to take a longer tour. We saw four deer in the wild, three of which I managed to just ban on film, quality could be better, though. My camera produced a hell lot of defocused photos this time. Not sure what’s going on with the autofocus. https://lyse.isobeef.org/waldspaziergang-2025-07-10/
When the sun came out, colors were just beautiful:

Go 開發實時推送太難?試試 Sponge SSE,一鍵搞定!
各位 Gopher 們!你們是否曾遇到過這樣的場景:• 你正在開發一個後臺監控系統,想讓 CPU 使用率、內存佔用這些數據實時展現在前端,但只能讓前端小哥每隔幾秒就發一次請求,把服務器累得夠嗆? • 你想做一個類似微博、Twitter 的信息流,當有新消息時,能立刻 “叮” 一下推送到用戶頁面上,而不是等用戶抓耳撓腮地手動刷新? • 或者,你只是想簡單地通知用戶:“您的外賣已由【帥哥張 ⌘ Read more
Go 開發實時推送太難?試試 Sponge SSE,一鍵搞定!
各位 Gopher 們!你們是否曾遇到過這樣的場景:• 你正在開發一個後臺監控系統,想讓 CPU 使用率、內存佔用這些數據實時展現在前端,但只能讓前端小哥每隔幾秒就發一次請求,把服務器累得夠嗆? • 你想做一個類似微博、Twitter 的信息流,當有新消息時,能立刻 “叮” 一下推送到用戶頁面上,而不是等用戶抓耳撓腮地手動刷新? • 或者,你只是想簡單地通知用戶:“您的外賣已由【帥哥張 ⌘ Read more
上手 MCP 官方 Go SDK:一份面向實戰的入門指南
大家好,我是 Tony Bai。隨着大型語言模型(LLM)的能力邊界不斷擴展,“function calling”或 “tool use” 已成爲釋放其潛力的關鍵。MCP(Model Context Protocol)正是爲此而生,它定義了一套標準的、與模型無關的通信規範,使得任何應用都能以 “工具” 的形式被 LLM 調用。長期以來,mcp 官方都沒有發佈 go-sdk,Go 社區也一直在使用像 ⌘ Read more
上手 MCP 官方 Go SDK:一份面向實戰的入門指南
大家好,我是 Tony Bai。隨着大型語言模型(LLM)的能力邊界不斷擴展,“function calling”或 “tool use” 已成爲釋放其潛力的關鍵。MCP(Model Context Protocol)正是爲此而生,它定義了一套標準的、與模型無關的通信規範,使得任何應用都能以 “工具” 的形式被 LLM 調用。長期以來,mcp 官方都沒有發佈 go-sdk,Go 社區也一直在使用像 ⌘ Read more
❤️ 🎶: Never Going Back by Kim Gyeol
@prologic@twtxt.net Hm, I wouldn’t say that. Go code could fall into that category as well.
Maybe this topic could use a blog post / article, that explains what it’s about. I’m finding it hard to really define what “suckless-like software” is. 🤔 (Their own philosophy focuses too much on elitism, if you ask me.)
@movq@www.uninformativ.de So you wouldn;t consider things written in Go to be “suckless”-esque? 🤔
I’ve been playing around with AI at home over the past few months and building my own neural networks from scratch (in Go) with genetic algorithms
Oh, is that all 🤣
That sounds like some intensive ‘playing around’ haha
@eldersnake@we.loveprivacy.club Yeah for sure! The thing that annoys me about a lot of this, is the sheer fact you can’t really self-host let alone self-train these things I’ve been playing around with AI at home over the past few months and building my own neural networks from scratch (in Go) with genetic algorithms on a few tasks and training sets, but man it’s hard™ 🤣 I feel like we’re doing something wrong here…
golang 反射 new?
今天來聊一個在 Golang 裏新手容易踩坑但高級用法又很關鍵的點:反射 + reflect.New。看上去很底層,實際在做框架開發、泛型模擬、動態構造對象的時候,全靠它撐場子!我前段時間折騰一個插件系統(Go 寫的),要從字符串配置動態構造 struct 對象實例,就必須用 reflect.New。這塊調試了好一陣,今天把經驗和注意事項總結一下,走一波實戰向的乾貨分享。1)reflect.New ⌘ Read more
In all fairness, GOG says that Forsaken is only supported on Ubuntu 16.04 – not current Arch Linux. If you ask me, this just goes to show that Linux is not a good platform for proprietary binary software.
Is it free software, do you have the source code? Then you’re good to go, things can be patched/updated (that can still be a lot of work). But proprietary binary blobs? Very bad idea.
golang 每日一庫之 rqlite
rqlite 是一個基於 SQLite 的輕量級、分佈式關係數據庫,旨在提供高可用性和容錯能力。它是一個 將 SQLite 封裝爲分佈式系統的項目,用 Go 編寫,後端使用 Raft 共識算法實現多節點數據複製與一致性。地址–GitHub: https://github.com/rqlite/rqlite文檔: https://rqlite.io目標–SQLite 是一個嵌入式的、本地文件型數 ⌘ Read more
Go 開發者必知:結構體方法接收器的選擇藝術
在 Go 語言開發中,結構體方法的定義方式直接影響程序的行爲和性能。本文將深入探討值接收器和指針接收器的區別,幫助開發者做出明智的選擇。一、結構體基礎回顧package mainimport”fmt”type User struct{ Name string Email string}funcmain(){// 值類型實例化 u1 := User{“張三”,“zhang@exa ⌘ Read more
基於泛型的輕量級依賴注入庫 do
在 Go 語言的開發實踐中,我們經常需要處理各種依賴關係,例如,一個 service 層可能依賴一個或多個 repository 層。如何優雅地管理這些依賴,是我們在項目開發中需要重點關注的問題。一個好的依賴管理方案,可以顯著提高代碼的可讀性、可維護性和可測試性。今天,我們就來介紹一個 Go 語言生態中非常受歡迎的輕量級依賴注入庫:samber/do。它基於 Go 1.18+ 的泛型特性,實現了一 ⌘ Read more
使用 Go - Redis 構建高性能排名系統
構建排名系統(排行榜)在各類應用中都具有實用價值:無論是遊戲中的玩家排名、電商平臺的熱銷商品展示。構建這類系統需要高速的讀寫操作、精準的排序能力以及可擴展的後端支持。Redis 的有序集合(Sorted Sets)正是實現這一需求的理想數據結構。現在我們開始構建一個實時排名系統,滿足以下核心需求:分數越高排名越靠前;同分情況下先達到該分數的用戶排名更高。構建複合分數實際分數越高,排名越靠前。 ⌘ Read more
Go 圖形庫: github-com-fogleman-gg
簡介:什麼是 gggg 是由 Fogleman 開發的一個用 Go 編寫的 2D 圖形繪製庫,靈感來源於 Python 的 Cairo 和 Processing 項目。gg 旨在提供簡潔、直觀的 API,以實現圖像繪製、文本渲染、圖形組合等操作,適用於圖像處理、數據可視化、圖像合成等多種用途。適用場景包括:圖像處理(添加水印、標識等) 數據可視化(繪圖、圖表生成) 自定義圖像合成(如生 ⌘ Read more
Go 語言延遲初始化 -Lazy Initialization- 最佳實踐
簡介—–在有些資源初始化成本很高,甚至在某些代碼路徑未觸發根本沒有必要初始化,可以將對象的創建、配置等耗時操作推遲到真正需要使用時才執行。延遲初始化實現———-2.1 sync.Oncesync.Once 是 Go 標準庫提供的線程安全初始化工具,確保初始化代碼只執行一次:var ( resource MyResource // 需要延遲初始化的資源 once ⌘ Read more
golang 每日一庫之參數校驗工具 go-tagexpr
go-tagexpr 是字節跳動開源的一款輕量級 Go 標籤解析與表達式求值引擎。我一般用來校驗參數。它的主要功能是支持通過結構體標籤(struct tag)定義表達式,然後在運行時動態解析這些表達式,實現靈活的數據校驗、默認值設置等功能。核心特性VzBq9U示例type User struct { Name string json:“name” tagexpr:“len(name) 0 ⌘ Read more
5 分鐘搞定 Go 自定義結構體標籤
本文介紹瞭如何通過自定義結構體標籤實現對結構體字段值的自定義處理,並討論了該方法的優缺點。原文:Struct Tags in Go: Implementing Custom Tag Functionality[1]Go 的 struct 標籤提供了一種爲 struct 字段定義元數據的方法,允許開發人員指定在序列化或驗證等操作期間如何處理這些字段。一個常見用例是 json 標籤,告訴 Go 的 ⌘ Read more
Golong 語言如何實現遞歸?
*說到遞歸函數這個東西,別看名字高大上,真要在 Golang(Go 語言)裏寫,其實一不小心就把自己繞暈了,我當年第一次寫遞歸找文件目錄的時候,腦殼都轉麻了。但話說回來,只要你把幾個關鍵點弄清楚,其實寫起來挺爽的,甚至有點 “優雅”!這篇就從我實戰經驗出發,帶你搞懂 “在 Golang 裏怎麼寫遞歸函數”,順帶踩幾個坑出來,保你一看就會、馬上能寫!啥是遞歸?簡單說下一句話:遞歸就是函數自己調自己! ⌘ Read more
went to vote. got told i can’t vote because i’m not registered. handed a form to fill out that i later learn is not in english.
go home and find out the problem is widespread among young voters like me.
fuck this country.
golang 每日一庫之 goplantuml
goplantuml 是一個用 Go 編寫的工具,能夠 自動將 Go 語言項目的結構生成 PlantUML 類圖(Class Diagram),適合用於 代碼可視化、架構審查、文檔編寫、團隊溝通** 等場景。項目地址—-GitHub 地址:https://github.com/jfeliu007/goplantuml概述–goplantuml 解析你的 Go 源碼,識別其中的:結構體(st ⌘ Read more
golang 每日一庫之 picfit
thoas/picfit 是一個用 Go 語言編寫的圖片處理服務器,主要用於 動態圖像裁剪、縮放、格式轉換和緩存 等功能。它適合用於圖片 CDN、圖像代理服務或網站中的動態圖片展示,尤其適合現代化網站、媒體服務、電子商務平臺等場景。項目地址—-GitHub: https://github.com/thoas/picfit優點–支持多種操作 :裁剪(crop)、縮放(resize ⌘ Read more
golang 每日一庫之 go-echarts
go-echarts/go-echarts是一個用 Go 編寫的現代圖表庫,提供了一整套易用的 API 來生成基於 Apache ECharts 的交互式圖表,適合用於數據可視化儀表盤、報表服務、網頁嵌入等應用場景。簡介–GitHub: https://github.com/go-echarts/go-echarts Stars: 6k+ License:MIT 基於:Apac ⌘ Read more
think i’m gonna use this license on my git repos going forward. it kicks ass https://anticapitalist.software/
Option and error handling. (Or the more complex Result, but it’s easier to explain with Option.)
@prologic@twtxt.net I’d say: Yes, because in Go it’s easier to ignore errors.
We’re talking about this pattern, right?
f, err := os.Open("filename.ext")
if err != nil {
log.Fatal(err)
}
Nothing stops you from leaving out the if, right? 🤔
Option and error handling. (Or the more complex Result, but it’s easier to explain with Option.)
@movq@www.uninformativ.de Is this much different to Go’s error handling as values though really? 🧐🤣😈
Go should be more opinionated
1 points posted by Elton Minetto ⌘ Read more
sync-Cond :無需通道的高效 Goroutine 信號傳遞
介紹–Go 語言的併發通常讓我們想到通道(channels),但還有另一個同步原語可能在某些場景下是:sync.Cond。。文章結束時,我們將看到一個簡單的自定義實現,理解真正的 sync.Cond 如何在底層工作,並知道何時在自己的項目中選擇它。爲什麼使用 sync.Cond?—————-大多數 Go 開發者本能地使用通道來協調 goroutine:發送值、等待結果等。然而 ⌘ Read more
告別接口緩慢:在 Go Gin 應用中一鍵啓用 Gzip 壓縮
在當今追求極致用戶體驗的互聯網時代,網站和應用的加載速度是至關重要的。如果你正在使用 Go 語言和 Gin 框架開發後端服務,並且遇到了數據包過大導致接口響應緩慢的問題,那麼 gin-contrib/gzip 這個庫絕對是你的救星!本文將介紹如何利用 github.com/gin-contrib/gzip 這個 Gin 官方擴展庫,輕鬆爲你的 Go Web 應用啓用 Gzip 壓縮功能,顯著提升接 ⌘ Read more
@movq@www.uninformativ.de neither do I 😆 and I’m going full Albert Camus mode. Embracing the Absurdism of life just to cope, it’s the only choice I have left.
FFS! Can’t I just get results, accurate no BS results? No erroneous/misleading AI-Slop of a summary I’ve never asked for ? I get it, there is plenty of people who LOooove (if not worship) that shit, Good for them! But at least make it opt-in or add in some kind of “Do Not Slop” browser option (as if the “Do Not Track” one made a difference, but I digress). Shit’s only going down-hill from here, I might as well as just spin up my own Searx instance and call it a day.
@prologic@twtxt.net I’m trying to call some libc functions (because the Rust stdlib does not have an equivalent for getpeername(), for example, so I don’t have a choice), so I have to do some FFI stuff and deal with raw pointers and all that, which is very gnarly in Rust – because you’re not supposed to do this. Things like that are trivial in C or even Assembler, but I have not yet understood what Rust does under the hood. How and when does it allocate or free memory … is the pointer that I get even still valid by the time I do the libc call? Stuff like that.
I hope that I eventually learn this over time … but I get slapped in the face at every step. It’s very frustrating and I’m always this 🤏 close to giving up (only to try again a year later).
Oh, yeah, yeah, I guess I could “just” use some 3rd party library for this. socket2 gets mentioned a lot in this context. But I don’t want to. I literally need one getpeername() call during the lifetime of my program, I don’t even do the socket(), bind(), listen(), accept() dance, I already have a fully functional file descriptor. Using a library for that is total overkill and I’d rather do it myself. (And look at the version number: 0.5.10. The library is 6 years old but they’re still saying: “Nah, we’re not 1.0 yet, we reserve the right to make breaking changes with every new release.” So many Rust libs are still unstable …)
… and I could go on and on and on … 🤣
golang 每日一庫之 barcode
boombuler/barcode 是一個用 Go 編寫的高質量條形碼生成庫,支持多種類型的條形碼和二維碼,使用簡單、擴展性強,非常適合用於生成圖像格式的條碼、二維碼等。倉庫信息—-GitHub: https://github.com/boombuler/barcode Stars: ★ 1.6k+ 許可證: MIT 安裝方式: go get githu ⌘ Read more