Searching txt.sour.is

Twts matching #go
Sort by: Newest, Oldest, Most Relevant

golang 每日一庫之 volatiletech-authboss
Authboss 是一個強大且可擴展的 Go 語言認證(authentication)和授權(authorization)框架,適用於 Web 應用程序。它提供了一套完整的用戶身份驗證方案,包括用戶註冊、登錄、註銷、賬號恢復、密碼重置、OAuth2、雙因素認證(2FA)等功能,使開發者能夠快速構建安全的身份認證系統。核心特性——–模塊化設計 :Authboss 由多個獨立的 ⌘ Read more

⤋ Read More

如何使用 go:linkname 指令訪問 Go 包中的私有函數
在 Go 語言的包設計中,函數和變量通過首字母大小寫來嚴格區分導出(exported)與未導出(unexported)的可見性規則。這種機制是 Go 模塊化設計的基石,但同時也爲底層系統級開發帶來了限制。//go:linkname 指令正是 Go 爲突破這一限制預留的「後門」,它通過編譯器的符號重定向能力,允許開發者直接鏈接任意包的未導出符號——無論是標準庫的私有函數,還是第三方包的隱藏變量。本文 ⌘ Read more

⤋ Read More

Go 語言 TCP 服務構建:原理到工程實踐
在分佈式系統架構中,傳輸層協議扮演着關鍵角色。作爲可靠傳輸的代表,TCP 協議通過三次握手建立連接、滑動窗口流量控制、序列號確認機制等技術,爲上層應用提供了有序且可靠的數據傳輸通道。這種面向連接的協議特性,使其成爲實時通信、文件傳輸、遠程控制等場景的首選方案。Go 語言自誕生之初就將網絡編程能力作爲核心設計目標。其標準庫中完善的 net 包提供了跨平臺的網絡 I/O 接口,結合輕量級線程 goro ⌘ Read more

⤋ Read More

It Isn’t Just Trump. America’s Whole Reputation Is Shot.
David Brooks,  Columnist  -  The New York Times

_Stephan: We are no longer a functioning democracy. We have one party, the MAGAts (formerly Republican) that is openly fascist, and the other, the Democrats, who are led in Congress by spineless individuals who don’t seem to understand what is going on. And all of this is being observed by all the other countries of the world. As David Brooks describes in his column, f … ⌘ Read more

⤋ Read More

Extreme weather and powerful winds predicted for 100m Americans
,    -  Associated Press

Stephan: Maybe this is getting covered on your local media, but I don’t see much discussion in the national media (this came from A British newspaper). It is, of course, yet another manifestation of the changing climate. Anyway if these storms are headed your way, prepare. This is all just going to get worse and worse.

![](https://www.schwartzreport.net/wp-content/uploa … ⌘ Read more

⤋ Read More

Trump calls his opponents ‘scum’ and lawbreakers in bellicose speech at Justice Department
Irie Sentner and Josh Gerstein,  Staff Writers  -  Politico

_Stephan: Trump is a fascist, and today he went to the Department of Justice he has gutted and turned into his personal law firm and told us it was going to be used by him to get revenge on those who oppose him, and to end freedom of the press so the media will stop saying negative things … ⌘ Read more

⤋ Read More

SQL scares me i tweaked a bash script that pulled from a DB and the bash part was easy even if i was just going off of the code in there that i didn’t write (like i understood it at least) but the SQL parts had me suffering

⤋ Read More

golang 每日一庫之 fatih-color
fatih/color 是一個流行的 Go 語言庫,用於在終端中輸出彩色文本和樣式化的內容。由開發者 Fatih Arslan 創建,它簡化了 ANSI 轉義碼的使用,使開發者能夠輕鬆爲 CLI 工具、日誌系統等添加顏色和樣式。特點豐富的顏色和樣式支持 顏色 :支持 16 種基礎前景色(如紅色、綠色)和背景色。 樣式 :支持加粗(bold)、斜體(itali ⌘ Read more

⤋ Read More

用 Go 構建跨平臺桌面應用:Wails 框架的深度實踐指南
在桌面應用開發領域,Electron 等基於 Web 技術的方案長期佔據主導地位,但其資源消耗問題始終是開發者心中的痛點。Go 語言的高效性和簡潔性爲這個問題提供了新的解題思路,而 Wails 框架正是這種思路的具象化體現。Wails 框架的核心價值在於將 Go 的後端能力與現代化前端技術無縫結合。通過內置的 Vite 支持,開發者可以自由選擇 React、Vue 或 Svelte 等前端框架,同 ⌘ Read more

⤋ Read More
In-reply-to » I got a small desk calendar as advertising gift. It shows three months at once. I'm using this thing since the beginning of this year and I have to say that it turned out to be super useful. I'm happily surprised.

@eapl.me@eapl.me @bender@twtxt.net @prologic@twtxt.net Not including a photo was a stupid move, sorry. There you go:

Image

This particular one is 95mm wide and 185mm high. Fairly compact.

I can only use it figure out distances to other dates and to do some basic calendar math. I’m not able to actually schedule anything. But I grew up with a month calendar like you have there where all appointments of the entire family was recorded.

By far most of my paper use is drawing random stuff on scratch paper during meetings. :-D

Image

⤋ Read More

International Push for Consumer Boycott of US Grows
Julia Conley,  Staff Writer  -  Common Dreams

_Stephan: I predict that anti-Americanism is going to become a prominent view of populations throughout the world, and that this new attitude is going to have a disastrous effect on our economy. People throughout the world will make it a point not to buy anything made in America, and other businesses in other countries, particularly China, will see the opportunity created by p … ⌘ Read more

⤋ Read More

Go 語言中的 LangGraph:基於 LangGraphgo 的 AI 任務編排
在 AI 任務編排領域,LangChain 提供了 LangGraph,幫助開發者搭建複雜、多步驟、有狀態的 AI 工作流。但這個庫主要基於 Python,而在 Go 語言生態中,如何實現類似的 AI 任務編排呢?今天,我們來介紹 langgraphgo,一個爲 Golang 量身定製的 AI 任務流管理框架。通 langgraphgo,你可以高效地構建 AI 代碼審計、對話系統、多智能體協作等應 ⌘ Read more

⤋ Read More

golang 每日一庫之 jinzhu-now
jinzhu/now 是一個用於增強 Go 語言時間處理的第三方庫,它基於標準庫 time 進行了擴展,提供了更便捷的時間操作功能,適用於需要頻繁處理時間區間、時區轉換或複雜時間解析的場景。以下是該庫的核心功能和用法詳解:一、核心功能時間區間的便捷計算now 庫提供了快速獲取時間區間(如某分鐘的開始 / 結束、某周的開始 / 結束等)的方法,無需手動計算。例如: import ⌘ Read more

⤋ Read More

Oops, Scientists May Have Miscalculated Our Global Warming Timeline
Darren Orf,  Contributing Writer  -  Popular Mechanics

_Stephan: The latest research, as this report describes, is that climate change is happening faster than has previously been estimated. I have told you repeatedly, and put up two papers of research showing why I keep saying this, that within 15 years humanity is going to go through a civilization-altering crisis. This prediction is based … ⌘ Read more

⤋ Read More

How hard will Trump’s immigration raids hit red states?
Myah Ward,    -  Politico

_Stephan: As this article describes all those farmers and herders, most of whom voted for MAGAts, are now going to face the economic crisis that will come from that decision. For years at our property in rural Tidewater Virginia, my family raised registered purebred Angus cattle, not for meat, but like a dog breeding operation, to improve the herd genetics.  It introduced me to a world I ha … ⌘ Read more

⤋ Read More

gogen:一鍵生成 Go 項目,開發者的效率利器
在 Go 開發中,手動搭建項目結構是不是讓你覺得效率低下?有沒有想過一個工具能一鍵搞定模板生成,像 Rust 的 cargo generate 那樣簡單?我開發的 gogen 就是爲此而生——輕量、靈活,專爲 Go 開發者打造。幾秒鐘內,你就能擁有一個定製化的項目骨架。接下來,讓我帶你看看它有多實用!gogen 是一個 Go 項目生成工具,靈感源自 Rust 的 cargo generate,旨在 ⌘ Read more

⤋ Read More

twtxt is a decentralised, minimalist microblogging service for hackers.

The keyword here is microblogging. But it doesn’t feel like we’ve been (relatively speaking) doing much of that lately… maybe I go the concept of microblogging wrong.

⤋ Read More

Dow falls by almost 900 points in market rout after Trump says he won’t rule out a recession
John Towfighi and Lucy Bayly,  Reporters  -  CNN

Stephan: I warned you it was going to happen, and two months into this nightmare it is happening. And “king” Trump is admitting the reality. All the men and women who voted for this psychopath I now expect to begin whining because of what is happening to their wellbeing.

![](https://www.schw … ⌘ Read more

⤋ Read More

golang 每日一庫之 bluele-gcache
bluele/gcache 是一個 高性能、功能豐富的 Go 語言緩存庫,支持多種緩存策略,如 LRU(最近最少使用)、LFU(最少使用頻率)、ARC(自適應緩存替換)等,可以靈活選擇適合的緩存模式。1. 安裝———使用 go get 下載安裝:go get github.com/bluele/gcache然後在代碼中導入:import ”github.com/bluele/gcach ⌘ Read more

⤋ Read More

如何基於 Go 語言設計一個簡潔優雅的分佈式任務系統
在當今雲計算與微服務盛行的時代,分佈式任務系統已成爲支撐大規模業務的核心基礎設施。今天就來爲大家分享下如何基於 Go 語言從零設計和實現一個架構簡潔且擴展性強的分佈式任務系統。前置概念本文會設計並實現一個分佈式任務系統,這裏我們要先明確兩個概念。• 分佈式:在我們將要實現的分佈式任務系統中,分佈式是指我們的服務可以部署多個副本,這樣才能確保服務更加穩定。 • 任務:這裏的任務是指異步任務,可 ⌘ Read more

⤋ Read More

【GoAnalysis】大更新,Go 項目源碼褲衩子被脫光了
前提上週,我發佈了 goanalysis 工具的首個版本,並得到了廣大用戶的積極反饋與支持。隨着關注度的增加,許多用戶表達了對如何有效利用該工具的興趣和疑問。經過深入考量後,我決定對 goanalysis 進行重大升級以更好地滿足用戶需求。本文旨在詳細介紹最新版 goanalysis 的功能特性及其使用方法,並引導大家訪問體驗網站。主要功能包括:運行時性能分析:提供應用程序在實際執行過程中性能指標 ⌘ Read more

⤋ Read More

go-attention:純 Go 語言實現的注意力機制和 Transformer
go-attention[1] 是由 takara.ai[2] 的前沿研究團隊開發的,是第一個純 Go 語言實現的注意力機制和 Transformer 層的庫。它專爲高性能和易用性而設計,目前已開源且經獲得了 291 star。主要特點—-純 Go 實現:無外部依賴,適合邊緣計算和需要依賴管理的場景 完整的注意力機制:包括基本的點積注意力和多頭注意力 完整的 Transformer ⌘ Read more

⤋ Read More

Go-redis:執行 Lua 腳本
go-redis (github.com/redis/go-redis) 支持 Lua 腳本 redis.Script,本文在這裏簡單展示其在秒殺場景中使用的代碼片段。秒殺場景在秒殺場景中,一個商品的庫存對應了兩個信息,分別是總庫存量和已秒殺量。可以使用一個 Hash 類型的鍵值對來保存庫存的這兩個信息,如下所示:key: productid value: {total: N, ordered: ⌘ Read more

⤋ Read More

We had a very sunny day, peaking at 19°C. This not only decoyed me out, but also plenty motorcycle terrorists. Eh fuckwits, nobody wants to listen to your bloody engine and exhaust noise, keep it quiet for fuck’s sake! Many of your rider collegues can manage it, too, so should you.

I had some sore muscles after yesterday’s waste paper collection with the scouts. So, I only went for a short trip to my closest backyard mountain. Watching two rock climbers was interesting. That’s not something I see very often.

Image

https://lyse.isobeef.org/waldspaziergang-2025-03-09/

⤋ Read More
In-reply-to » Dang it! I ran into import cycles with shared test utilities again. :-( Either I have to copy this function to set up an in-memory test storage across packages or I have to put it in the storage package itself and guard it with a build tag that is only used in tests (otherwise I end up with this function in my production binary as well). I don't like any of the alternatives. :-(

Thanks, @xuu@txt.sour.is, great explanation. In another project I’ve structured it exactly like you wrote. The mock storage over there extends the SQLite storage and provides mechanism to return errors and such for testing purposes:

  • storage/ defines the interface
    • sqlite/ implements the storage interface
    • mock/ extends the SQLite implementation by some mocking capabilities and assertions

Here, however, there are no storage subpackages. It’s just storage, that’s it. Everything is in there. The only implementation so far is an SQLite backend that resides in storage. My RAM storage is exactly that SQLite storage, but with :memory: instead a backing file on disk. I do not have a mock storage (yet).

I have to think about it a bit more, but I probably have to do exactly that in my tt rewrite, too. Sigh. I just have the feeling that in storage/sqlite/sqlite_test.go I cannot import storage/mock for the helper because storage/mock/mock.go imports and embeds the type from storage/sqlite. But I’m too tired right now to think clearly.

⤋ Read More

Climate Change Threatens Earth’s Major Crops, Study Finds
Michael Riojas,  Reporter and Editorial Assistant  -  Eco Watch

Stephan: Climate change is going to drastically change agriculture, and that is going to cause enormous migrations both internally and internationally. This will, in turn, massively disrupt nations across Earth. And this crisis is coming very quickly. By 2040 humanity will be in crisis.

![](https://www.schwartzreport.net/wp-content/uploads/2025/0 … ⌘ Read more

⤋ Read More

[ANN] More vitamins for Monero with Carrot - part 2: History

Before I go deeper into technical details regarding important aspects of Carrot with further posts, I present you, as something like an “interlude”, a history of Monero privacy technologies. One aim is to show you how we arrived at the point where we are now with FCMP++ and Carrot.

Link: https://farside.link/libreddit/r/Monero/comments/1j745kf/

u/rbrunner7 (Gith … ⌘ Read more

⤋ Read More
In-reply-to » Dang it! I ran into import cycles with shared test utilities again. :-( Either I have to copy this function to set up an in-memory test storage across packages or I have to put it in the storage package itself and guard it with a build tag that is only used in tests (otherwise I end up with this function in my production binary as well). I don't like any of the alternatives. :-(

@lyse@lyse.isobeef.org OK. So how I have worked things like this out is to have the interface in the root package from the implementations. The interface doesn’t need to be tested since it’s just a contract. The implementations don’t need to import storage.Storage

  • storage/ defines the Storage interface (no tests!)
    • storage/sqlite for the sqlite implementation tests for sqlite directly
    • storage/ram for the ram implementation and tests for RAM directly
  • controller/ can now import both storage and the implementation as needed.

So now I am guessing you wanted the RAM test for testing queries against sqlite and have it return some query response?

For that I usually would register a driver for SQL that emulates sqlite. Then it’s just a matter of passing the connection string to open the registered driver on setup.

https://github.com/glebarez/go-sqlite?tab=readme-ov-file#connection-string-examples

⤋ Read More

Ontario will tariff electricity going to 3 US states on Monday, premier says
Ashleigh Fields,  Staff Writer  -  The Hill

_Stephan: If you live in Michigan, Minnesota, and New York expect your electric bill to go up significantly, because much of your electricity comes from Canada, and Ontario is now responding to the Trump tariffs. But as bad as that is, I think what criminal Trump is doing is far worse than anyone in media is really talking about. … ⌘ Read more

⤋ Read More

Donald Trump Approval Rating: Update for March 6 as Numbers Slide
,    -  Newsweek

_Stephan: Americans still don’t get it. They still don’t properly understand what “king” Trump, his Frankenstein Musk, and his flying monkeys in Congress are doing to their lives. The U.S. economy is headed for a recession, prices are going up not down, the nation’s reputation in the world is in the garbage; and if you need medical attention, you may not be able to get it, you … ⌘ Read more

⤋ Read More

golang 每日一庫之 gods
在 Go 語言的生態中,數據結構的選擇和實現往往直接影響程序的性能和代碼的可維護性。今天,我們就來聊聊一個備受開發者喜愛的開源項目 gods,它爲我們提供了豐富且易用的數據結構實現,極大地簡化了開發過程中 “造輪子” 的煩惱。項目背景——-gods 是由 Emir Pasic 開發並維護的一個開源庫,旨在爲 Go 語言提供各種常用數據結構和算法的實現。項目採用 MIT 許可證,鼓勵社區貢獻 ⌘ Read more

⤋ Read More
In-reply-to » Dang it! I ran into import cycles with shared test utilities again. :-( Either I have to copy this function to set up an in-memory test storage across packages or I have to put it in the storage package itself and guard it with a build tag that is only used in tests (otherwise I end up with this function in my production binary as well). I don't like any of the alternatives. :-(

@xuu@txt.sour.is My layout looks like this:

  • storage/
    • storage.go: defines a Storage interface
    • sqlite.go: implements the Storage interface
    • sqlite_test.go: originally had a function to set up a test storage to test the SQLite storage implementation itself: newRAMStorage(testing.T, $initialData) *Storage
  • controller/
    • feeds.go: uses a Storage
    • feeds_test.go: here I wanted to reuse the newRAMStorage(…) function

I then tried to relocate the newRAMStorage(…) into a

  • teststorage/
    • storage.go: moved here as NewRAMStorage(…)

so that I could just reuse it from both

  • storage/
    • sqlite_test.go: uses testutils.NewRAMStorage(…)
  • controller/
    • feeds_test.go: uses testutils.NewRamStorage(…)

But that results into an import cycle, because the teststorage package imports storage for storage.Storage and the storage package imports testutils for testutils.NewRAMStorage(…) in its test. I’m just screwed. For now, I duplicated it as newRAMStorage(…) in controller/feeds_test.go.

I could put NewRAMStorage(…) in storage/testutils.go, which could be guarded with //go:build testutils. With go test -tags testutils …, in storage/sqlite_test.go could just use NewRAMStorage(…) directly and similarly in controller/feeds_test.go I could call storage.NewRamStorage(…). But I don’t know if I would consider this really elegant.

The more I think about it, the more appealing it sounds. Because I could then also use other test-related stuff across packages without introducing other dedicated test packages. Build some assertions, converters, types etc. directly into the same package, maybe even make them methods of types.

If I went that route, I might do the opposite with the build tag and make it something like !prod instead of testing. Only when building the final binary, I would have to specify the tag to exclude all the non-prod stuff. Hmmm.

⤋ Read More

Poll on Trump’s 2025 joint address to Congress finds large majority of viewers approve
Anthony Salvanto,  Reporter  -  CBS News

Stephan: The fundamental source of the problems with America is Republican frightened, resentful, ignorant Americans. They are the ones who elected this monster, and they are also the ones who are going to be most severely impacted by his greed, corruption, and madness.

![](https://www.schwartzreport.net/wp-con … ⌘ Read more

⤋ Read More

yaegi:讓你的 Go 代碼擁有動態腳本能力
在 Go 語言的世界裏,靜態編譯是其一大特色,能夠保證性能和安全性。然而,有些場景下,我們希望像 Python 或 JavaScript 一樣,支持運行時動態執行代碼,比如插件化架構、規則引擎、腳本解釋器等。今天,我們來介紹一個強大的 Go 解釋器庫——yaegi,它能讓 Go 代碼在運行時執行動態腳本。yaegi 簡介yaegi 是一個用 Go 語言編寫的 Go 解釋器。它可以在運行時解析和執行 ⌘ Read more

⤋ Read More
In-reply-to » lang=en @xuu gotcha! From that PR #17 I think it was reverted? We could discuss about metadata later this month, as it seems that I'm the only person using it.

it seems to be confused with the subject right next to it.. it works better at the end of the twt string.
Yarn won’t display anything. but the parser does add it to the AST in a way that you can parse it out using twt.Attrs().Get("lang")

https://git.mills.io/yarnsocial/go-lextwt/src/branch/main/ast.go#L1270-L1272

https://git.mills.io/yarnsocial/go-types/src/branch/main/twt.go#L473-L478

⤋ Read More

Tariff War Risks Sinking World Into New Great Depression, International Chamber of Commerce Warns
Joshua Kirby,  Economic Reporter  -  The Wall Street Journal

_Stephan: This is from yesterday’s Murdoch owned The Wall Street Journal, hardly a Democratic or liberal publication. Since I read Project 2025 I have been predicting on SR that the United States is probably going to go into a recession. TWSJ seems to think it may be worse … ⌘ Read more

⤋ Read More

Analysis Finds Trump Tariffs Will Cost Average US Family $1,600 or More Per Year
Jessica Corbett,  Senior Editor  -  Common Dreams

_Stephan: I have seen several estimates on what the Trump MAGAt Party’s impact on the economy is going to cost each American household; this one seems the most fact-based. Maybe $1,600 this year is not that much to you, but to millions of U.S. families it is going to have a serious impact. And after the State of the U … ⌘ Read more

⤋ Read More

Go Context 實踐指南:以生產環境問題爲例
背景    Go 語言中的 context(上下文) 對於 Go 程序員來說應該是司空見慣, 很多都會不假思索的將 context 類型入參作爲函數的第一個參數.     最近因爲在生產環境處理過一個和 context 有關的問題, 因此希望可以藉助這個實際問題說說 context 使用上的注意事項. 類似 “context 應該使用參數傳遞不能作爲 struct 成員” 的八股知識不在本文討論範 ⌘ Read more

⤋ Read More

Trump Reveals Tariffs Plan to Ruin American Farmers’ Lives
Malcolm Ferguson,  Associate writer  -  The New Republic

Stephan: Thanks to the stupidity of “king” Trump, who clearly does not understand what tariffs are, Americans, like you and me, are about to see a number of farmers go broke, and the prices we pay for produce at the grocery go up by as much as 25%

Image

_C … ⌘ Read more

⤋ Read More

golang 每日一庫之 go-flags
go-flags 是一個用於處理命令行參數和標誌的 Go 庫,它提供了一種簡潔而靈活的方式來定義和解析命令行標誌(flags)和參數。這個庫對於需要處理命令行輸入的 Go 應用程序非常有用,特別是在構建 CLI(命令行工具)時。1. 安裝 go-flags首先,你需要安裝 go-flags 庫。在命令行中運行以下命令:go get github.com/jessevdk/go-flags這個命令會 ⌘ Read more

⤋ Read More

在 Go 中如何使用分佈式鎖解決併發問題?
在分佈式系統中,協調多個服務實例之間的共享資源訪問是一個經典的挑戰。傳統的單機鎖(如 sync.Mutex)無法實現跨進程工作,此時就需要用到分佈式鎖了。本文將介紹 Go 語言生態中基於 Redis 實現的分佈式鎖庫 redsync,並探討其使用方法和實現原理。分佈式鎖首先我們來探討下爲什麼需要分佈式鎖?當我們編寫的程序出現資源競爭的時候,就需要使用互斥鎖來保證併發安全。而我們的服務很有可能不會單 ⌘ Read more

⤋ Read More

Go 1-24 中改進的 Finalizer:介紹 runtime-AddCleanup
Go 1.24 通過 runtime.AddCleanup 引入了一個新的、改進的 Finalizer 機制。這個函數是對 runtime.SetFinalizer 的重大改進,提供了更多的靈活性、更好的效率和改進的安全性。Finalizer 在 Go 中扮演着關鍵角色,當對象不再可達時運行清理函數。這允許開發者自動執行諸如關閉文件、釋放內存和註銷資源等重要任務。今天我們將探討 runtime.A ⌘ Read more

⤋ Read More

Announcing the Beta Release of OpenTelemetry Go Auto-Instrumentation using eBPF
The OpenTelemetry community is excited to announce the beta release of the OpenTelemetry Go Auto-Instrumentation project! This milestone brings us closer to our mission of making observability simple, accessible, and effective for Go applications. What is… ⌘ Read more

⤋ Read More

Local and State Police are Joining Trump’s Deportation Force
Francesca D’Annunzio,  David McHam Investigative Reporting Fellow  -  Texas Observer

_Stephan: Here is the fact-based truth about what is going on with deportation. Two things stand out for me. The first is that the Trump coup is actually deporting fewer people than Biden’s presidency did. The second is that Trump is now basically militarizing local and state police exactly as Hitler did. If you track the … ⌘ Read more

⤋ Read More

Some consumers are not spending money for today’s economic blackout. Here’s what to know.
Betty Lin-Fisher,  Customer Reporter  -  USA Today

Stephan: The 28 February “Don’t Buy for 24 hours” boycott doesn’t seem to have amounted to much. What that tells me is that a large percentage of Americans don’t yet realize what is going in their country with the Trump coup. Very sad.

![Some consumers are participating in a one-day economic blacko … ⌘ Read more

⤋ Read More

Xid:Go 輕量級 ID 生成器
在分佈式系統中,唯一 ID(GUID)是必不可少的,常見的方案包括 UUID、MongoDB ObjectID 和 Twitter Snowflake。其中 UUID 雖然通用,但長度較長,而 Snowflake 需要額外的機器 / 數據中心配置。xid (github.com/rs/xid) 是一個基於 MongoDB ObjectID 算法的更輕量級、更高效的全局唯一 ID 生成庫,用於生成 ⌘ Read more

⤋ Read More

golang 每日一庫之 concurrent-map
概述orcaman/concurrent-map/v2 是一個 Go 語言的高性能併發安全哈希表實現。它通過分片鎖(shard locking)策略減少鎖競爭,適用於高併發讀寫場景。與標準庫的 sync.Map 不同,該庫針對通用鍵值類型優化,提供更靈活的 API 和更高性能。項目地址GitHub 倉庫 : https://github.com/orcaman/concurrent-Read more

⤋ Read More

Golang 程序卡死排查指南
我正在幫助某人設置我的 gokrazy/rsync 實現來同步 RPKI 數據(用於保護 BGP 路由基礎設施),當時我們發現,在特定調用方式下,我的 rsync 接收器會無限期掛起。這個問題很快就解決了,但在這個過程中,我意識到我應該記錄下這些年來我所欣賞的一些 Go 調試技巧!場景:Go 程序掛起———-如果你想跟着實驗,可以構建 gokrazy/rsync 的一個較舊版本,就在修 ⌘ Read more

⤋ Read More

使用 Golang 編寫 2D 遊戲
Ebitengine 是一款基於 Go 語言的 2D 遊戲開發引擎,提供了簡單易用的 API 和跨平臺的支持,開發者可以通過它輕鬆構建遊戲項目。核心特性——-跨平臺支持 Ebitengine 支持多個平臺,包括 Windows、macOS、Linux,以及 WebAssembly(可運行於瀏覽器中)。這使得開發者可以在不同設備上運行同一個遊戲項目,而無需編寫額外的代碼。易用的 API ⌘ Read more

⤋ Read More

golang 面試題:Goroutinue 什麼時候會被掛起?
今天我們來聊聊一個在 Go 面試中經常遇到的經典問題:Goroutine 什麼時候會被掛起?如果你是一個 Go 程序員,或者正在準備 Go 相關的面試,可能對這個問題有一些疑問。那麼,就讓我從一個資深程序員的角度,帶你們深入淺出地分析這個問題。💡什麼是 Goroutine?首先,咱們得搞清楚什麼是 Goroutine。簡而言之,Goroutine 就是 Go 中的輕量級線程。它讓我們可以用極低的成 ⌘ Read more

⤋ Read More

Cuts to National Weather Service Leave Forecasters Reeling
,    -  DNYUZ

_Stephan: The Trump coup is now destroying the National Weather Service, so your weather reports will deteriorate in accuracy. Criminal Trump is going to attempt to privatize the National Weather Service and let one of the oligarchs that bought him his job own the NWS and turn it into a profit-making system for themselves. All you Republican farmers, foresters, and fishermen, hope you love wha … ⌘ Read more

⤋ Read More

Trump admin plans to ‘permanently cripple’ climate protections in single blow: report
David Edwards,  Senior Editor  -  Raw Story

_Stephan: The Trump coup, as one of its main goals, is eliminating any preparation for climate change, or encouraging transition out of the carbon energy era. I don’t think criminal Trump is smart enough to really understand what climate change is going to mean to the United States. Or, maybe, he just figures he wi … ⌘ Read more

⤋ Read More
In-reply-to » We went up our backyard mountain again right after lunch. The sun peaked through the clouds sometimes. The 6°C felt much, much cooler with the northeast wind. We got lucky, though, it was dead calm at the summit. At least on the southwestern side, which is a few meters lower than the very top to the east. That was shielded absolutely perfectly from the wind (we were extremely surprised), so we sat down on a bench and could really enjoy the sun heating us up. Apart from the haze, the view was really nice.

@lyse@lyse.isobeef.org Looks like a nice day. 😊 I tried to go on a quick walk, but it was really cold. And everything’s wet at the moment. Bah.

Clothespins in the woods, who would have thunk? 🥴

⤋ Read More

House Republicans are betting big on pain
Hayes Brown,   Staff Writer / Editor  -  MSNBC

_Stephan: The Republican Congress members in subservience to the uber-rich who bought them their seats, and in submission to aspiring dictator Trump, is trashing the U.S. economy.  I am sure you have seen some of the video clips of townhall meetings in which the Republicans are booed and challenged. We are going from an economy that was the envy of the world as Biden’s administration ended to an … ⌘ Read more

⤋ Read More

golang 每日一庫之 gocarina-gocsv
一、爲什麼選擇 gocsv?Go 標準庫 encoding/csv 提供了基礎的 CSV 讀寫能力,但在處理複雜業務時常常需要:手動轉換字符串到具體類型 維護列索引與結構字段的映射關係 處理嵌套結構等複雜數據類型 處理可選字段和默認值 gocarina/gocsv 通過結構體標籤實現了聲明式的 CSV 解析,極大簡化了開發流程。最新統計顯示,該庫在 GitHub 已獲得 1 ⌘ Read more

⤋ Read More

Go 語言 errgroup 庫:強大的併發控制工具
errgroup 是官方 Go 庫 x 中的一個實用工具,用於併發執行多個 goroutine 並處理錯誤。它基於 sync.WaitGroup 實現了 errgroup.Group,爲併發編程提供了更強大的功能。errgroup 的優勢————與 sync.WaitGroup 相比,errgroup.Group 具有以下優勢:錯誤處理:sync.WaitGroup 只負責等待 g ⌘ Read more

⤋ Read More

Alibaba, Datadog, and Quesma Join Forces on Go Compile-Time Instrumentation
Standards are only useful if they’re widely adopted, and adoption is only effective if the available tooling facilitates it. I imagine SI units would not have been too popular when they were introduced if you had to build… ⌘ Read more

⤋ Read More
In-reply-to » Question to the twtxt veterans, are we experiencing an explosion of clients or is this a regular occurrence?

@andros@twtxt.andros.dev I wouldn’t call it regular, but cyclical. Since, with the exception of Yarn (maybe?), clients are everything when it comes to twtxt, every now and then we see an increase of interest on new development. I have seeing them come and go, only few “beside remains”. :-)

⤋ Read More
In-reply-to » Na, you're spot on, @movq! The result is an expected, terrible disaster. It just seems the absolute catastrophy is delayed for another four years.

@lyse@lyse.isobeef.org

To me it appeared that the failed attempts to ban NPD in the past actually helped them gain more supporters.

What makes AfD stronger for sure is just going “lol nah we’re not even going to try”:

https://www.tagesschau.de/inland/innenpolitik/afd-verbot-antrag-100.html

If they don’t try, then it means that “it can’t be that bad, it’s just a normal party”, right? 😡

⤋ Read More

context-Context - 構建高可用的 Go 應用
你是否有遇到過這樣的情況:意外的流量激增導致數據庫掛起 系統掛掉,用戶無法訪問 做爲開發人員,你忙於調試問題,事後還會被扣除績效和獎金 不受控制的 goroutines,長時間運行的任務,無響應的 API 這些都會對構建一個高可用的應用造成嚴重影響。這些問題通常源於缺乏適當的上下文管理。無論您是在處理 API 請求、管理數據庫操作,還是構建分佈式系統,掌握上下文都是每個 Go ⌘ Read more

⤋ Read More
In-reply-to » This document is the result of a series of discussions between Robert "Uncle Bob" Martin and John Ousterhout, held between September 2024 and February 2025. The text addresses three main topics: method length, comments, and Test Driven Development (TDD). https://github.com/johnousterhout/aposd-vs-clean-code/blob/main/README.md This is something to read and reflect on for days.

@andros@twtxt.andros.dev Just before the pandemic, we watched Uncle Bob videos once a week in the lunch break. While almost all of my old teammates agreed with his views, I partially found them to be very odd and even counterproductive.

I didn’t come across John Ousterhout or any of his work before, at least not deliberately. So, this document is my first contact.

I only finished the chapter on comments and I totally agree with John so far. This document just manifests to me how weird Bob’s view is on certain subjects.

I always disagreed with the concept of a maximum method length. Sure, generally, shorter functions are probably better, but it always depends. And I’ve certainly seen super short methods that just made the code flow even worse to follow. While “one function should only do one thing” is a nice general rule, I’m 100% in team John with the shown examples. There are cases, where this doesn’t help readability at all. Not even close.

To me, a function always has to justify its existence. Either by reusing it at least at another place or by coming up with dedicated tests for it. But if it is just called once and there are no tests, I almost always decide against it. Personally, I don’t mind longer methods. We just recently had a discussion about that and I lost against two other workmates who are more in Uncle Bob’s camp, they refactored one medium sized method into three very short ones. Luckily, we agree on most other topics.

Lol, what!? The shorter the method, the longer the variables inside? I first thought I misread or the writeup mixed it up. I’ll always do it the other way around.

I’ve been also bitten badly by outdated comments in the past, but Bob must have worked on really terrible projects to end up with such an attitude to dislike comments. Oh well. No doubt, I’ve come across by several orders of magnitude more useless comments, in my experience (autogenerated) JavaDocs fall in the category more frequently than not. So, I know that there are different types of comments. A comment doesn’t automatically mean that it is good and justified.

But I also partially agree with Bob and John and think that a good name has a proper chance to save a comment. Though, when in doubt, I go John’s route and use a shorter name with a comment rather than use a kilometer long identifier. Writing good comments typically takes some time, sometimes much longer than writing the code. It regularly takes me several minutes. It’s a hard art.

I perhaps should read up on John’s work. He seems to be more reasonable and likeminded. :-) Let me continue to complete this document.

⤋ Read More

Donald Trump Has Launched a War Against the Working Class
Michael Arria,  Staff Writer  -  truthout

_Stephan: As Trump’s fascist oligarch coup moves into its second month I confess I am surprised that Trump voters don’t yet seem to fully realize how severely Trump is going to damage the quality of their personal life, and the lives of their family. I keep seeing interviews with Trump voters, particularly White men, who just don’t seem capable of comprehending what is … ⌘ Read more

⤋ Read More

MCP 實戰:使用 Go 快速構建 MCP Server
MCP 簡介MCP 協議(Model Context Protocol,模型上下文協議)是由 Anthropic 於 2024 年 11 月底推出的一種開放標準,旨在統一大型語言模型(LLM)與外部數據源和工具之間的通信。官方地址 https://modelcontextprotocol.io 架構如下 MCP 協議的架構包含多個關鍵組件:Host(宿主程序)、MCP Client(M ⌘ Read more

⤋ Read More

Go 1-24 新特性:標準庫 os-Root 解析
背景 ——–Go 1.24 已進 release,其版本說明 [1] 中包含了多項新特性。本文將重點解析新增的標準庫 os.Root 功能,它能有效防禦目錄遍歷漏洞(Directory Traversal Vulnerabilities)。目錄遍歷漏洞是典型的安全問題,攻擊者通過提供相對路徑(如 ../../../etc/passwd)誘導程序訪問非授權文件。近期真實案例 CVE- ⌘ Read more

⤋ Read More

The Housing Loophole That Lets Wealthy Investors Raise Rents on Poor Tenants
Jesse Coburn,  Staff Writer  -  ProPublica

_Stephan: An SR reader, who describes herself as a “retired teacher” wrote to tell me she was just notified her rent in an apartment building that was sold by its owner to an investment group will be going up 25%, and she is not sure she can afford it. That prompted me to do some research to see what is going on with rents for ren … ⌘ Read more

⤋ Read More

Trump Backs House GOP Bill Slashing $1 Trillion From Medicaid and Food Stamps
Chris Walker ,  Staff Writer  -  truthout

_Stephan: I was just told today by the office of one of my physicians that telemedicine, doing a video meeting with a physician, will no longer be covered by Medicare. That, for me, is a big deal. I live on an island and going to a medical appointment on the mainland when all that is involved is a conversation, is an all-day opera … ⌘ Read more

⤋ Read More
In-reply-to » Na, you're spot on, @movq! The result is an expected, terrible disaster. It just seems the absolute catastrophy is delayed for another four years.

@lyse@lyse.isobeef.org

The big established parties are all bad traitors. I blame them and their actions to help raise AfD. They just [don’t?] give a fuck about the ordinary people, they’re only concerned about their private gain and power.

To a large degree, yes. But I think the media is also equally at fault. There was absolutely no reason to invite AfD people to every event and let them talk. This has been going on for over 10 years. When we give them a stage to spread their hate, are we really surprised that hate spreads … ?

I don’t know the answers to this desaster. I’m beginning to think that people literally just want an outlet for their frustration, nothing more. It’s not about what particular parties actually plan to do. At least I think this applies to people in their 30ies and 40ies.

⤋ Read More

Go 項目目錄結構指南
擁有一個井然有序的目錄結構非常重要,原因有幾個:層次分離:它將項目的不同部分——如業務邏輯、數據訪問和 API 處理——放在各自的文件夾中。這樣,開發人員可以專注於特定領域,而不會感到不知所措或困惑。 更好的組織: 通過整齊地整理你的代碼及其依賴項,較大的項目變得更容易導航。你總是知道在哪裏找到你需要的東西! 可重用性: 一個良好的結構讓你可以創建可以在項目不同部分使用的組件或包,從而 ⌘ Read more

⤋ Read More

golang 每日一庫 samber-lo
samber/lo 是一個非常流行的 Go 語言庫,它提供了一些常用的函數式編程風格的工具函數,使得 Go 代碼更加簡潔、優雅。該庫的設計理念是減少代碼冗餘,簡化開發過程,尤其是在處理常見的數據結構和算法時。lo 這個庫的名字來源於 “Lazily Optimized” 的縮寫,但它本身並不涉及延遲計算或優化策略。它的目標是提供一系列常見操作的簡便方法,尤其是集合類型(如切片、映射、通道等)的操作 ⌘ Read more

⤋ Read More

Go 語言之在 Gin 框架中使用 Zap 實現高效日誌管理
在現代 Web 開發中,日誌管理是確保應用程序性能、穩定性和可維護性的關鍵因素之一。Gin 作爲輕量級的 Go Web 框架,自帶了簡單的日誌功能。然而,對於追求高性能和靈活性的開發者來說,Zap 日誌庫是一個理想的選擇。本文將深入探討如何在 Gin 框架中集成 Zap 日誌庫,實現高效、分級和結構化的日誌記錄。本文介紹瞭如何在 Go 的 Gin 框架中使用 Zap 日誌庫替換默認日誌功能,提供更 ⌘ Read more

⤋ Read More

golang 每日一庫之 pressly-goose
pressly/goose 是一個用於 Go 語言的數據庫遷移工具。它提供了一種簡單且高效的方式來管理數據庫 schema 的版本控制,適用於數據庫結構變更的管理和遷移。goose 的設計目標是讓數據庫遷移更加簡便、安全,並且在多環境下可以輕鬆應用。數據庫遷移通常用於在應用程序中管理數據模式的變化(例如添加表、修改列、刪除索引等),尤其在團隊協作開發、生產環境發佈等情境下,遷移工具幫助開發者和運維 ⌘ Read more

⤋ Read More

golang 每日一庫之 iancoleman-orderedmap
github.com/iancoleman/orderedmap 是一個 Go 語言庫,提供了一個有序字典(OrderedMap)實現,區別於 Go 語言內建的 map 類型,內建的 map 是無序的。該庫的 OrderedMap 能夠保持元素的插入順序,因此適用於需要按插入順序遍歷元素的場景。主要特點:有序性:OrderedMap  保證元素的插入順序,和內建的 map 類型不同, ⌘ Read more

⤋ Read More

Go 編程實踐 - Go Context
1、context 包的引入context 包是在 Go 1.7 引入的,它爲在多個 goroutine 之間傳遞請求範圍的上下文信息和控制 goroutine 的生命週期提供了一種標準的方式。2、context 包的主要作用傳遞上下文信息:context 可用於在 goroutine 之間傳遞請求範圍的數據,如請求的認證信息、請求的截止時間、請求的 ID 等。這些信息在 goroutine 之間 ⌘ Read more

⤋ Read More

golang 每日一庫之 swaggo
Go Swagger(Swaggo)是一個用於 Go 語言的開源工具集,它幫助開發者自動生成 API 文檔。它利用 Go 的註釋和結構體信息,通過解析代碼,生成符合 OpenAPI 規範的文檔。OpenAPI(也稱爲 Swagger)是一個廣泛使用的 API 規範,它使得 API 文檔更加標準化、易於理解和交互。Swaggo 主要的功能包括:1. 自動生成 OpenAPI 文檔Swaggo 通過解 ⌘ Read more

⤋ Read More

Go 事件驅動架構:從原理到實戰,徹底掌握高併發編程
在 Go 語言的世界裏,如何優雅地處理海量併發請求?事件驅動架構(Event-Driven Architecture, EDA)或許是你需要的答案。 🔥 爲什麼你需要關注事件驅動架構? ———————-在傳統的同步編程模式下,我們通常採用阻塞調用的方式來處理請求。然而,在高併發、高吞吐的場景下,這種方式可能帶來以下問題:線程資源浪費:大量 Goroutine 在 I ⌘ Read more

⤋ Read More

I am going to start using this one more, or exclusively, from now on. I need to get used to it, as “quark” will be gone, and “bender”, well, he is kind of tired of getting bent. :-D

⤋ Read More
In-reply-to » I heard that congratulations to Germany are in order, is that right? If so, congratulations!

@bender@twtxt.net @prologic@twtxt.net The outcome was to be expected but it’s still pretty catastrophic. Here’s an overview:

Image

East Germany is dominated by AfD. Bavaria is dominated by CSU (it’s always been that way, but this is still a conservative/right party). Black is CDU, the other conservative/right party.

The guy who’s probably going to be chancellor recently insulted the millions of people who did demonstrations for peace/anti-right. “Idiots”, “they’re nuts”, stuff like that. This was before the election. He already earned the nickname “Mini Trump”.

Both the right and the left got more votes this time, but the left only gained 3.87 percentage points while the right (CDU/CSU + AfD) gained 14.72:

Image

The Green party lost, SPD (“mid-left”) lost massively (worst result in their history). FDP also lost. These three were the previous government.

This isn’t looking good at all, especially when you think about what’s going to happen in the next 4 years. What will CDU (the winner) do? Will they be able to “turn the ship around”? Highly unlikely. They are responsible for the current situation (in large parts). They will continue to do business as usual. They will do anything but help poor/ordinary people. This means that AfD will only get stronger over the next 4 years.

Our only hope would be to ban AfD altogether. So far, nobody but non-profit organizations is willing to do that (for unknown reasons).

I don’t even know if banning the AfD would help (but it’s probably our best/only option). AfD politicians are nothing but spiteful, hateful, angry, similar to Trump/MAGA. If you’ve seen these people talk and still vote for them, then you must be absolutely filled with rage and hatred. Very concerning.

Correct me if I’m wrong, @lyse@lyse.isobeef.org, @arne@uplegger.eu, @johanbove@johanbove.info.

⤋ Read More

使用 Go Convey 做 BDD 測試的入門指南
前面在「Go 代碼測試時怎麼打樁?給大家寫了幾個常用案例」中我們介紹了在單元測試中使用gomonkey爲代碼進行打樁的各種方法。今天我們介紹在 Go 單元測試中另外一個很好用的工具庫goconvey,上面說的gomonkey屬於在 Test Double 方面提供能力,也就是我們通常說的mock,用它們可以自定義一套實現來替換項目中的代碼實現。而goconvey則是一個幫助我們組織和管理測試用例的 ⌘ Read more

⤋ Read More
In-reply-to » @aelaraji Can you give me examples of hashes that you have detected wrong between Emacs client and twtxt.net? Perhaps there is some character, some space, that is creating the discrepancy.

@andros@twtxt.andros.dev yeah, sorry I couldn’t get back to you sooner. I’ve already made an account on codeberg in order to file in an issue but, I just can’t get myself to concentrate with everything going on with the family lately. I’ll do my best and get things done properly and soon

⤋ Read More

Trump orders justice department to fire all US attorneys appointed by Biden
Hugo Lowell ,  Staff Writer  -  The Guardian (U.K.)

_Stephan: The United States is no longer going to have a fair and legitimate legal system. The FBI has been corrupted into a personal internal army to pursue what “king” Trump wants pursued, and the lawyers of DOJ that are ethical men and women are resigning or, as this article describes, being fired. Like everything else T … ⌘ Read more

⤋ Read More

Trump talks of a third term amid growing concerns about a constitutional crisis
Brakkton Booker,  National Political Correspondent  -  Politico

_Stephan: Trump clearly sees himself not so much as the President as an authoritarian king with sovereignty over the United States. And he has no plan to leave office. Nothing is going to stop this but millions of Americans out non-viollently protesting every day. Here’s something you can do. I got an em … ⌘ Read more

⤋ Read More

Mass firings continue across nation’s health agencies
Adam Cancryn, Megan Messerly and David Lim,  Staff Writers  -  Politico

_Stephan: America’s already poor illness profit system is going to get much worse. I find it hard to believe that “king” Trump and the Republicans have such little concern for the people who voted them into office. It is going to be interesting, if tragic, to watch Trump voters face the reality of what they have done, as all the social systems that … ⌘ Read more

⤋ Read More

Hegseth’s proposed Pentagon cuts, firing of generals: What to know
Filip Timotija,  Staff Writer  -  The Hill

_Stephan: Having worked in the Pentagon directly with two Chiefs of Naval Operations, as well as the other Joint Chiefs, I have a very real sense of the chaos Hegseth, who is appallingly unqualified to be Secretary of Defense, is going to cause as he and “king” Trump disrupt the command order, and attempt to cut the Defense Department budget by 40% over … ⌘ Read more

⤋ Read More