Searching txt.sour.is

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

Golang 解釋器:Yaegi 內部實現
Yaegi[2]  是一個用 Go 語言編寫的 Go 語言解釋器。這個項目最初是在 Traefik-Labs 啓動的, 目的是爲 traefik 反向代理提供一個簡單實用的嵌入式插件引擎。現在, 社區貢獻的 200 多個插件已經列在  plugins.traefik.io[3]  的公共目錄中。Yaegi 的使用也擴展到其他領域, 例如 數據庫 [4] 、 可觀察性 [5] 、 容器安全 [6] ⌘ Read more

⤋ Read More

完全用 Go 編寫的 JS 引擎
背景介紹隨着互聯網技術的迅猛發展,JavaScript 已經成爲幾乎所有現代網頁和應用開發中不可或缺的組成部分。但是,JavaScript 的執行環境通常侷限於瀏覽器或者 Node.js,這爲那些希望在不同環境下運行 JavaScript 代碼的開發者帶來了限制。特別是在 Go 語言環境中,開發者面臨着將 JavaScript 與 Go 通信的挑戰,因爲二者運行時不一致可能導致性能下降和開發效率降 ⌘ Read more

⤋ Read More

萬字長文講透 Go 程序性能優化
性能分析和優化是所有軟件開發人員必備的技能,也是後臺大佬們口中津津樂道的話題。Golang 作爲一門 “現代化” 的語言,原生就包含了強大的性能分析工具 pprof 和 trace。pprof 工具常用於分析資源的使用情況,可以採集程序運行時的多種不同類型的數據(例如 CPU 佔用、內存消耗和協程數量等),並對數據進行分析聚合生成的報告。trace 工具則關注程序運行時的事件(例如協程狀態切換,G ⌘ Read more

⤋ Read More

Go 中祕而不宣的數據結構 BitVec:位向量 125MB 存儲 10 億個數據
位圖 (bitmap) 是一種優雅而高效的數據結構, 它巧妙地利用了計算機最底層的位運算能力。你可以把它想象成一個巨大的開關陣列, 每個開關只有打開和關閉兩種狀態 —— 這就是位圖的本質。每一位都可以獨立控制, 卻又可以通過位運算實現羣體操作。在實際應用中, 位圖的威力令人驚歎。設想你需要在海量數據中查找重複的數字, 傳統的哈希表或數組都會佔用大量內存。而位圖卻能巧妙地用一個比特位標記一個數字的 ⌘ Read more

⤋ Read More

一個比較 tricky 的 Golang 問題: 最大協程數量
在 Go 語言面試中, 關於 “可以產生的最大協程數量” 這個問題有時會讓候選人措手不及。答案並不是簡單地給出一個具體數字。面試官通常用這個問題來評估你對 Go 併發模型、內存管理以及協程實踐經驗的理解。理解 Go 的併發模型和協程效率首先需要明確以下幾點:協程是由 Go 運行時管理的輕量級用戶空間線程, 比傳統的操作系統線程更高效 Go 並沒有對協程數量設置嚴格限制, 在合適的條件下, 你可以同 ⌘ Read more

⤋ Read More

5 Helpful Uses for Apple Intelligence on Mac, iPhone, & iPad
Apple Intelligence is here on Mac, iPhone, and iPad, and while the system requirements are strict, the Apple devices that are new and powerful enough to use the AI tools now gain some really fantastic features. We’re going to show you six helpful Apple Intelligence features and uses that you’ll find beneficial to your workflow, … [Read More](https://osxdaily.com/2024/11/04/5-helpful-uses-for-apple-intelligence-o … ⌘ Read more

⤋ Read More

10 個最佳 Golang 庫
10 個最佳 Golang 庫—————在 Golang 中,我們可以找到垃圾回收、可接受的庫和標準的類型系統。Golang 適用於系統編程,也被稱爲包。Go 語言被稱爲 Golang 是因爲它在編程語言 GO 中收集了一些可重用的代碼組件。在 Go 語言中,包在組織和結構化代碼方面起着重要作用,還提高了可讀性、代碼可重用性和可維護性。這裏爲你介紹十個最佳 Golang 庫。這 ⌘ Read more

⤋ Read More

一個小例子,給你講透 Go 配置管理,輕鬆將其融入到項目中
在軟件開發中,配置管理是一個不可或缺的部分。無論是開發環境、測試環境還是生產環境,我們都需要一種方法來存儲和讀取配置信息。在 Golang 項目中,Viper 是一個非常流行且功能強大的庫,用於處理配置文件。下面我會寫一些例子,幫助大家快速上手。什麼是 Viper?———-不賣關子,直接上 GitHub 地址:https://github.com/spf13/viper 大家可以直接去 ⌘ Read more

⤋ Read More

Monero Tech meeting scheduled for 18 November 2024 1800 UTC
The next Monero Tech meeting is scheduled to take place on Monday, November 18 2024 at 18:00 UTC, in the #no-wallet-left-behind 1 IRC-Libera/Matrix channels:

Based on the opinions given here2 I decided to go back to the No Wallet Left Behind Matrix room and IRC channel for the next i.e. coming Monday’s meeting, and to not contiune to hold meetings like the last one in the -dev Matrix room and IRC channel.

This meeting’s c … ⌘ Read more

⤋ Read More

Kubectl logs tail: a guide to tailing Kubernetes logs
Member post originally published on Middleware’s blog In the world of cloud-native applications, Kubernetes stands as the go-to platform for container orchestration (the automated process of managing, scaling, and maintaining containerized applications across multiple hosts). As applications grow… ⌘ Read more

⤋ Read More

Golang 隨機公平庫 satmihir-fair
FAIR 是一個 Go 庫, 旨在確保資源受限環境中的公平性。它有助於在資源短缺時將有限的資源 (例如數據庫 / blob 存儲吞吐量、作業執行資源等) 均勻分配給多個客戶端, 防止基於客戶端行爲的過度分配和飢餓。 簡介–FAIR 的核心算法基於 隨機公平 BLUE[1] , 這種算法通常用於網絡擁塞控制, 但做了一些修改。FAIR 的理念是隻在真正資源短缺時進行限制, 而不是像令牌桶或漏桶等 ⌘ Read more

⤋ Read More

構建無密碼認證:passkey 入門與 Go 實現
傳統的密碼認證一直以來都是數字時代的主流身份驗證方式。然而,用戶常常選擇易記的弱密碼並重復使用,導致賬號易受攻擊。密碼泄露、釣魚攻擊等安全問題層出不窮,超過 80% 的數據泄露與密碼相關。與此同時,頻繁的密碼管理和忘記密碼情況嚴重影響用戶體驗。服務商在安全保存用戶密碼方面的責任也增加了系統建設和維護的成本。爲了應對這些問題,科技行業開始積極探索無密碼認證的方法。無密碼認證利用設備生物識別、硬件加密 ⌘ Read more

⤋ Read More

SwarmGo:一個用於構建可擴展 AI Agent 工作流的 Go 模塊化框架
AI 領域正在快速發展,新的應用層出不窮。然而,創建能夠有效協調多個 AI 任務或 Agent(每個 Agent 處理複雜工作流的一部分)的系統仍然具有挑戰性。SwarmGo 應運而生,這是一個功能強大且輕量級的 Go 包,旨在使 AI 應用中的 Agent 編排更易於訪問和擴展。本文將深入探討 SwarmGo 的特性、優勢和結構,並展示如何使用它輕鬆創建智能的模塊化 AI 工作流。什麼是 Swa ⌘ Read more

⤋ Read More

解密 Go runtime-SetFinalizer 的使用
如果我們想在對象 GC 之前釋放一些資源,可以使用 returns.SetFinalizer。這就像在函數返回前執行 defer 來釋放資源一樣。例如:1:使用 runtime.SetFinalizertype MyStruct struct {       Name  string       Other MyStruct   }  func main() {       x := MyStru ⌘ Read more

⤋ Read More

使用 Go 構建分佈式系統:基於 gRPC 的主從節點架構
在現代軟件開發領域,分佈式系統已經變得至關重要。它們使服務能夠擴展、處理大量數據並提供高可用性。本文將指導您使用 Golang 構建一個簡單的分佈式系統,該系統利用主節點和單個工作節點,並使用 gRPC 協議進行通信。這種架構非常適合數據處理、並行計算和大規模處理工作負載等分佈式任務。我們將介紹如何設置主從結構、建立基於 gRPC 的通信,以及實現簡單的任務分配和執行流程。系統概述—-我們的分 ⌘ Read more

⤋ Read More

Golang 常用的五種創建型設計模式
在 Go 中,創建設計模式有助於管理對象的創建,並控制對象的實例化方式。這些模式在對象創建過程複雜或需要特殊處理時特別有用。以下是 Go 中常用的主要創建模式:單例模式單例模式確保一個類只有一個實例,並提供一個全局訪問點。如何實現定義一個結構,並將其作爲單個實例。 爲該結構創建一個全局變量,但不要立即將其初始化。 使用 sync.Once 確保實例只創建一次,即使在多線程情況下也是如此 ⌘ Read more

⤋ Read More

For .onion gophersites you can install Orbot App on android for VPN, than go by lynx or overbite app to gopher://magical.fish, then you can open the .onion site of magical.fish.

⤋ Read More

Go 中祕而不宣的數據結構 Treap:平衡樹不一定就用紅黑樹
treap 是一棵二叉樹,它同時維護二叉搜索樹 (BST) 和堆的屬性, 所以由此得名 (tree + heap   ⇒  treap)。從形式上講,treap (tree + heap) 是一棵二叉樹,其節點包含兩個值,一個  key  和一個  priority,這樣 key 保持 BST 屬性,priority 是一個保持 heap 屬性的隨機值(至於是最大堆還是最小堆並不重要)。相對於其 ⌘ Read more

⤋ Read More

Go 語言的組合之道
在軟件開發領域,”組合優於繼承” 的原則常常被奉爲圭臬,因爲它能夠帶來更靈活、更易維護的代碼。Go 語言以其獨特的面對對象設計理念,堅定地選擇了組合而非繼承。本文將深入探討 Go 語言爲何偏愛組合,並闡述其在實際應用中的優勢。繼承的弊端與組合的優勢———–傳統的面對對象編程語言通常依賴繼承機制,允許一個類繼承另一個類的行爲和屬性。然而,這種方式容易導致代碼結構僵化,難以應對需求變化。 ⌘ Read more

⤋ Read More

Monero Tech meeting scheduled for 4 November 2024 1800 UTC
The next Monero Tech meeting is scheduled to take place on Monday, November 4 2024 at 18:00 UTC, in the #no-wallet-left-behind 1 IRC-Libera/Matrix channels:

Based on the opinions given here2 I decided to go back to the No Wallet Left Behind Matrix room and IRC channel for the next i.e. coming Monday’s meeting, and to not contiune to hold meetings like the last one in the -dev Matrix room and IRC channel.

This meeting’s chai … ⌘ Read more

⤋ Read More

After the behaviour of a clearly very angry feed author over the past few days, I’m very tempted to give up on Twtxt and allow it to go back to being dead. What really is the point of building and supporting a way to exchange little pieces of text with one another in a completely decentralized way, if you’re just going to keep bumping up against such hostility? I don’t know why I do this anymore.

⤋ Read More

依賴注入:讓 Go 語言更加優雅
依賴注入:讓 Go 語言更加優雅—————-在軟件工程中,依賴注入(Dependency Injection,簡稱 DI)是一種設計模式,它允許我們在不修改類的代碼的情況下向類中注入依賴。這種方式有助於降低代碼間的耦合度,使得各個組件更容易獨立開發和測試。雖然 Go 語言以其簡潔和高效的特性著稱,但在構建大規模應用時,手動管理依賴關係可能會變得複雜和難以維護。這就是 Pa ⌘ Read more

⤋ Read More

從 Go channel 中如何批量讀取數據 ?
在 Go 語言中,我們可以利用 channel 作爲數據的傳輸通道,通過定期批量讀取 channel 中的數據,並將這些數據批量發送到 Kafka 或者進行網絡寫入。這樣可以提高系統的性能,減少單個請求的網絡開銷。批量處理的主要邏輯是:從 channel 中接收數據,積累到一定數量或者達到時間限制後,將數據批量處理(例如發送到 Kafka 或者寫入網絡)。下面我將展示一個從 Go channel ⌘ Read more

⤋ Read More

解析 Golang sync-Once 用法和原理
Once is an object that will perform exactly one action.sync.Once 是 Go 標準庫提供的使函數只執行一次的實現,常應用於單例模式,例如初始化配置、保持數據庫連接等。它可以在代碼的任意位置初始化和調用,因此可以延遲到使用時再執行,併發場景下是線程安全的。對外接口Once 對外僅暴露了唯一的方法 Do(f func()),f 爲需要執行的 ⌘ Read more

⤋ Read More

Go 語言的 RSA 加密與解密:方法與最佳實踐
一般對接過支付業務的都知道,RSA 算法。RSA 是一種廣泛應用於安全通信領域的非對稱加密算法。它使用一對密鑰(公鑰和私鑰)來加密和解密數據,在互聯網通信、數字簽名等場景中具有重要作用。咱們一起看一下,在 Go 語言中,如何使用 RSA 算法。一、RSA 加密與解密的基礎知識1. 非對稱加密RSA 屬於非對稱加密算法,主要特點是密鑰成對使用:一個用於加密(公鑰),另一個用於解密(私鑰)。使用公鑰加 ⌘ Read more

⤋ Read More

Go 邏輯分支優化實戰
TL;DR通過函數式編程和 map 結構可以優化複雜的 if-else 邏輯 提前返回可以避免不必要的資源消耗,防止全表掃描等問題 避免在循環中使用 defer 語句,可能導致資源泄露 使用 for 循環對相同邏輯進行壓縮,提高代碼的簡潔性和可擴展性 代碼的世界,將自然語言的需求轉換成執行的邏輯。如何轉化成代碼之後仍然儘可能接近自然語言的可理解性,是我們一直探求的內容。 ⌘ Read more

⤋ Read More

探索 Go slog 標準庫:設計與應用
本文主要介紹了 Go 語言新引入的 log/slog 標準庫的設計理念、使用方法以及如何進行定製化開發,以提高日誌操作的性能和靈活性。原文: Explore the Go slog Standard Library: Design and Usage[1]在 Go1.21[2] 中引入的 log/slog[3] 軟件包試圖彌補原有日誌軟件包的不足,即日誌缺乏結構化和級別特性。正如提案 [4] ⌘ Read more

⤋ Read More

揭祕 Go sync-Map 設計與實現
什麼是 sync.Map————我們都知道在 Go 語言中,普通的 Map 是非併發安全,併發讀寫時會 panic,sync.Map 則是官方庫提供的一種特殊的併發安全的映射類型,能保較高的性能的同時,還能保證併發安全。sync.Map 有以下幾個特點:sync.Map 特點併發安全: sync.Map 無需額外的鎖機制即可在多個 goroutine 中安全地進行讀寫操作。這對於高 ⌘ Read more

⤋ Read More

Go 項目使用 Makefile 構建版本信息完整教程
目錄結構我們以最小目錄結構爲例進行說明,如下這是我們此次示例的目錄結構。$ tree -L 3.├── main.go├── Makefile├── pkg│   └── version│       └── version.go├── README.md代碼內容主要有兩部分代碼,分別爲 main.go,內容如下:package mainimport (    ”eastMoney/pkg/ver ⌘ Read more

⤋ Read More

Go 語言實現高性能文本壓縮算法 Brotli
在信息爆炸的時代,數據如同洪流般湧現,如何高效地存儲和傳輸這些數據成爲了一項至關重要的技術挑戰。壓縮技術應運而生,它如同一位技藝精湛的魔術師,能夠將龐大的數據文件 “化繁爲簡”,在不損失信息或損失極少信息的情況下將其壓縮成更小的體積,從而節省存儲空間、提高傳輸效率。壓縮技術主要分爲兩大類:無損壓縮和有損壓縮。無損壓縮:顧名思義,這種壓縮方式能夠在解壓縮後完全恢復原始數據,不會造成任何信息損失。常見 ⌘ Read more

⤋ Read More

Apple Seeds watchOS 11.1 Release Candidate
Apple today seeded the release candidate version of an upcoming watchOS 11.1 update to developers and public beta testers for testing purposes. The new software comes approximately week after Apple released the fifth beta.

Image

watchOS 11.1 can be installed by going to the Apple Watch … ⌘ Read more

⤋ Read More

Go 中祕而不宣的數據結構 runq- 難怪運行時調度那麼好
首先,讓我們先來回顧 Go 運行時的 GPM 模型。這方面的介紹網上的資料都非常非常多了,但是我們也不妨回顧一下: GPM 模型中的 G 代表 goroutine。每個 goroutine 只佔用幾 KB 的內存, 可以輕鬆創建成千上萬個。G 包含了 goroutine 的棧、指令指針和其他信息, 如阻塞 channel 的等待隊列等。 P 代表 processor, 可以理解爲一個抽 ⌘ Read more

⤋ Read More

解讀 Golang 標準庫裏的 varint 實現
最近發現 Golang 標準庫竟然自帶了 varint 的實現,代碼位置在 encoding/binary/varint.go。剛好藉助 golang 標準庫的 varint 源碼,我們來系統地學習和梳理下 varint。熟悉 protobuf 的人肯定對 varint 不陌生,protobuf 裏面除了帶 fix (如 fixed32、fixed64) 之外的整數類型, 都是 varint 編碼 ⌘ Read more

⤋ Read More

Monero Tech meeting scheduled for 28 October 2024 1800 UTC
The next Monero Tech meeting is scheduled to take place on Monday, October 28 2024 at 18:00 UTC, in the #no-wallet-left-behind 1 IRC-Libera/Matrix channels:

Based on the opinions given here2 I decided to go back to the No Wallet Left Behind Matrix room and IRC channel for the next i.e. coming Monday’s meeting, and to not contiune to hold meetings like the last one in the -dev Matrix room and IRC channel.

This meeting’s chai … ⌘ Read more

⤋ Read More

How to Re-Enable Slow Motion Effects on MacOS
If you’re a long time Mac user, you might recall the Slow Motion effect that could be applied by holding the Shift key while minimizing and maximizing windows, as well as for other animations like opening Launchpad or using Mission Control. Some of the fun eye-candy effects on Mac go way the early days of … Read MoreRead more

⤋ Read More

Go 信號處理:優雅地關閉你的應用
在構建健壯且可靠的應用程序時,優雅地處理系統信號至關重要。系統信號,如 SIGINT(中斷信號,通常由 Ctrl+C 觸發)和 SIGTERM(終止信號),允許我們以可控的方式關閉應用程序,執行必要的清理操作,例如關閉連接、釋放資源和保存狀態。本文將深入探討在 Go 語言中如何處理系統信號。我們將涵蓋以下主題:理解系統信號 使用 os/signal 包捕獲信號 實現優雅的關閉機制 ⌘ Read more

⤋ Read More

Go 每日一題:併發下載與合併
答案–實現思路:文件分割: 將目標文件分割成多個大小相等的塊(例如 10MB / 塊)。 併發下載: 爲每個文件塊創建一個 goroutine,每個 goroutine 負責下載對應塊的內容並保存到臨時文件中。 同步與合併: 使用 channel 來同步所有 goroutine 的下載進度,並在所有塊下載完成後,按順序合併所有臨時文件,最終得到完整的原始文件。 代碼示例:pac ⌘ Read more

⤋ Read More

一文掌握 Go 語言 I-O 操作中的 io-Reader 和 io-Writer
在 Go 語言中,io.Reader 和 io.Writer 是兩個至關重要的接口,它們爲處理輸入輸出操作提供了強大且靈活的抽象。本文將深入探討這兩個接口的機制、常見用例、潛在陷阱以及一些高級應用,幫助你更好地掌握 Go 語言的 I/O 操作。io.Reader 接口:數據讀取的基礎———————-io.Reader 接口定義了讀取數據的通用方法:type Reader ⌘ Read more

⤋ Read More

** Sleepy garden beds **
This afternoon I put the garden to sleep for the fall; in the past we’ve had some fall and winter vegetables going, but this year that didn’t happen, so, I emptied out the rain barrels, cleaned them out, trundled them to a place where they wouldn’t get blown around by any winds, mulched some of the beds, weeded and generally plotzed around like a garden goblin.

I’ve fallen into the habit of making a big thing of rice over the weekend — I always intend to do something with this rice, but instead I use it for s … ⌘ Read more

⤋ Read More

Go 中祕而不宣的數據結構 spmc- 10 倍性能於 channel
Go 標準庫和運行中中,有一些專門針對特定場景優化的數據結構,這些數據結構並沒有暴露出來,這個系列就是逐一介紹這些數據結構。這一次給大家介紹的就是一個 lock-free、高性能的單生產者多消費者的隊列:PoolDequeue 和 PoolChain。 到底是一個還是兩個呢? 主要是 PoolDequeue, 它是一個固定尺寸,使用 ringbuffer (環形隊列) 方式實現的隊列。PoolCh ⌘ Read more

⤋ Read More

深入理解 Go 語言的棧
本期深入研究 Go 堆棧的工作原理以及作爲程序員爲什麼要關心它。本篇內容是根據 2023 年 3 月份#288 A deep dive into Go’s stack[1] 音頻錄製內容的整理與翻譯過程中爲符合中文慣用表達有適當刪改, 版權歸原作者所有. Mat Ryer: 大家好,歡迎收聽 Go Time。我是 Mat Ryer[2]。今天我們要討論的是 Go 的棧。究竟什麼是棧?它的作用 ⌘ Read more

⤋ Read More

溫故知新——Golang GMP 萬字洗髓經
0 前言—-我在 23 年初曾發佈過一篇——golang gmp 原理解析,當時剛開始接觸 go 底層源碼,視野廣度和理解深度都有所不足,對一些核心環節的思考和挖掘有所欠缺,對其中某些局部細節又過分拘泥,整體內容質量上還是有所不足.隨着近期嘗試接觸了 golang 以外的語言,通過橫向對比後,對於 golang 中 gmp 的精妙設計也產生了一些新的感悟. 於是就藉着這個契機開啓一個重置篇,對 ⌘ Read more

⤋ Read More

Monero Tech meeting scheduled for 21 October 2024 1800 UTC
The next Monero Tech meeting is scheduled to take place on Monday, October 21 2024 at 18:00 UTC, in the #no-wallet-left-behind 1 IRC-Libera/Matrix channels:

Based on the opinions given here2 I decided to go back to the No Wallet Left Behind Matrix room and IRC channel for the next i.e. coming Monday’s meeting, and to not contiune to hold meetings like the last one in the -dev Matrix room and IRC channel.

This meeting’s chai … ⌘ Read more

⤋ Read More

深入理解 go unsafe
Go 是支持指針的語言,但是爲了保持簡潔、安全,Go 的指針有很多限制,但是一些場景又需要繞過這些安全限制,因此提供了 unsafe 包,unsafe 可以繞過:指針運算、不同的指針類型不能轉換、任意類型指針等限制,進而可以實現更高級的功能。下面通過對比可以更直觀的瞭解 unsafe 的特點:支持指針運算——Go 的指針是不支持指針運算的,指針運算在直接操作內存有很大作用,例如:通過指針運 ⌘ Read more

⤋ Read More

揭祕 Go 併發利器 WaitGroup
在 Go 語言的併發編程世界中,WaitGroup 是一個至關重要的工具,它爲開發者提供了一種簡單而有效的方式來管理和同步多個協程的執行。本文將深入揭祕 WaitGroup 的實現原理、注意事項、使用示例。什麼是 WaitGroup————-WaitGroup 是 Go 標準庫中 sync 包提供的一種同步原語,用於等待一組(可能是併發的)操作完成。它的主要作用是讓主協程(即調用 ⌘ Read more

⤋ Read More

7 個實用技巧幫助你更好地玩轉 Go Structs
在本文中,我們將探討使用結構體的 7 個技巧,掌握它們能夠幫助開發者寫出更高效、更可維護的 Go 代碼。Go 中的結構體是一種複合數據類型,它將變量集中在一個名稱下。它們是許多 Go 程序的支柱,是創建複雜數據結構和實現面向對象設計模式的基礎。但結構體的功能遠不止簡單的數據分組。1. EmbeddingEmbedding 是 Go 的一項強大功能,它允許將一個結構包含在另一個結構中,提供了一種合成 ⌘ Read more

⤋ Read More

golang 是如何防範 SQL 注入、CSRF、XSS 攻擊 的
在 Go 語言的 Web 開發中,常見的安全問題包括 SQL 注入、CSRF(跨站請求僞造)、和 XSS(跨站腳本攻擊)。Go 提供了多種機制與工具庫來防範這些攻擊。以下是針對每種攻擊的防範措施:防範 SQL 注入————SQL 注入 是一種通過修改 SQL 查詢的輸入,使攻擊者能夠執行未授權 SQL 語句的攻擊手段。防範 SQL 注入的關鍵是避免直接拼接 SQL 字符串,而是使用 ⌘ Read more

⤋ Read More
In-reply-to » @prologic would you please check my web interface? is that a normal thing or am I missing something?

Web interface is deleted in https://git.mills.io/saltyim/saltyim/commit/376de2702319686c902ec03b8ca1e17b020fc639 but seems incorrectly (in source i see git lfs metadata). Can be builded if you grab https://git.mills.io/saltyim/saltyim/src/commit/15a64de82829/internal/web/app.wasm and place it in source (go directory has cached source) and rebuild

⤋ Read More

Go 語言中的 os-Stat– 與 os-Lstat–
文件操作是系統編程中至關重要的一部分,而 Go 語言提供了通過其 os 包訪問文件元數據的直觀方法。兩個常用的函數,os.Stat() 和 os.Lstat(),允許您收集有關文件和符號鏈接的信息,但它們的作用不同。本文將解釋這兩個函數之間的關鍵區別,說明它們的實際應用,並深入探討一些高級注意事項,例如錯誤處理和性能。Go 中的文件信息———Go 語言中的 os.FileInfo 接口 ⌘ Read more

⤋ Read More

Apple Card High-Yield Savings Account Getting Yet Another Interest Rate Cut
Apple is once again planning to cut the interest rate of its Apple Card high-yield savings account, with the new rate set to go live on Friday, October 11.

Image

The ‌Apple Card‌ savings account’s annual percentage yield (APR) will drop to 4.10 percent, down from 4.25 percent. This is the … ⌘ Read more

⤋ Read More

在兩個大文件中找出相同的記錄,用 golang 如何寫?
在 Go 語言中找出兩個大文件中相同的記錄,可以採用以下策略:思路讀文件:按行逐行讀取兩個文件中的記錄,假設每個文件的每一行代表一條記錄。 使用哈希集合(Set):因爲哈希集合能夠快速判斷某個記錄是否存在,所以我們可以將第一個文件中的記錄放入集合中,之後讀取第二個文件時逐行判斷該記錄是否也存在於集合中。如果存在則是相同的記錄。 性能優化: 如果文件非常大,避免一次性全部加載到內存 ⌘ Read more

⤋ Read More
In-reply-to » @doesnm Agree. salty.im should allow the user to post multiple brokers on their webfinger so the client can find a working path.

Honestly… not much. Have abandon two projects (both private) on Golang and one related to cryptography. My mostly languages are Python and Javascript (also can PHP). After writing code on Go i spend same time on fixing dumb errors

⤋ Read More

什麼是 WebSocket?Go_WebSocket 編程來了!
爲什麼要有 WebSocket?—————-已經有了 HTTP 了爲什麼還要有 WebSocket 呢?因爲,HTTP 的請求只能由客戶端發起,服務器接收。但是,現在想要讓服務器端也可以主動發起請求。那麼使用 HTTP 是無法滿足的。其次,還有一種就是,如果想要監聽服務端發送的請求。那麼,可以讓客戶端始終處於一種輪詢狀態。客戶端每隔一段就發起一個詢問,看一下服務端有沒有請求信息 ⌘ Read more

⤋ Read More

MacBook Pro With M4 Chip May Support Up to Two External Displays
Apple’s upcoming entry-level M4 14-inch MacBook Pro may be capable of supporting up to two external displays, up from one display supported in the current M3 model, if recent leaks are anything to go by.

Image

Apple’s existing M3 14-inch MacBook Pro comes with two Thunderbolt 3 USB-C ports, not three Thunderbolt 4 … ⌘ Read more

⤋ Read More

Monero Tech meeting scheduled for 14 October 2024 1800 UTC
The next Monero Tech meeting is scheduled to take place on Monday, October 14 2024 at 18:00 UTC, in the #no-wallet-left-behind 1 IRC-Libera/Matrix channels:

Based on the opinions given here2 I decided to go back to the No Wallet Left Behind Matrix room and IRC channel for the next i.e. coming Monday’s meeting, and to not contiune to hold meetings like the last one in the -dev Matrix room and IRC channel.

This meeting’s chai … ⌘ Read more

⤋ Read More

Spotify Launches Offline Backup Feature for Premium Users
Spotify has announced a new feature called Offline Backup, designed to give Premium subscribers an additional way to listen to music offline without manually downloading playlists. Rolling out globally this week, the feature aims to address situations where users find themselves without an internet connection and haven’t … ⌘ Read more

⤋ Read More
In-reply-to » @prologic I wanted to wait for things to settle down. It’s still unclear to me in which direction we’re going – and if that new/different stuff is even possible to implement in jenny. That said, I’ve been really busy with private stuff these last few days, I’ve lost track of most of what you’re discussing. 🥴

I share I did write up an algorithm for it at some point I think it is lost in a git comment someplace. I’ll put together a pseudo/go code this week.

Super simple:

Making a reply:

  1. If yarn has one use that. (Maybe do collision check?)
  2. Make hash of twt raw no truncation.
  3. Check local cache for shortest without collision
    • in SQL: select len(subject) where head_full_hash like subject || '%'

Threading:

  1. Get full hash of head twt
  2. Search for twts
    • in SQL: head_full_hash like subject || '%' and created_on > head_timestamp

The assumption being replies will be for the most recent head. If replying to an older one it will use a longer hash.

⤋ Read More
In-reply-to » @movq I'd love it if you write up a page for jenny 🙏 at https://twtxt.dev 🤞

@prologic@twtxt.net I wanted to wait for things to settle down. It’s still unclear to me in which direction we’re going – and if that new/different stuff is even possible to implement in jenny. That said, I’ve been really busy with private stuff these last few days, I’ve lost track of most of what you’re discussing. 🥴

⤋ Read More
In-reply-to » There we go!

@prologic@twtxt.net Regarding the new way of generating twt-hashes, to me it makes more sense to use tabs as separator instead of spaces, since the you can just copy/past a line directly from a twtxt-file that already go a tab between timestamp and message. But tabs might be hard to “type” when you are in a terminal, since it will activate autocomplete…🤔

Another thing, it seems that you sugget we only use the domain in the hash-creation and not the full path to the twtxt.txt

$ echo -e "https://example.com 2024-09-29T13:30:00Z Hello World!" | sha256sum - | awk '{ print $1 }' | base64 | head -c 12

⤋ Read More

RavenTree:輕量級的 Go HTTP 請求庫,內置重試機制和錯誤處理
RavenTree 是一個輕量級的 Go 庫,旨在通過提供易於使用的接口、內置對各種 HTTP 方法的支持、接受重試處理等功能來簡化 HTTP 請求。它爲開發者提供了一種高效便捷的方式與網絡服務進行交互。RavenTree 的核心功能—————易於使用的接口:  RavenTree 提供了一個簡單直觀的 API,可以方便地創建和發送 HTTP 請求。 內置支持各種 HTT ⌘ Read more

⤋ Read More

Golang 中你應該知道的 noCopy 策略
在 Go 開發中,我們經常遇到 noCopy 這種結構體,並伴隨一個常見的註釋 “must not be copied after first use”。本文將深入探討 noCopy 的作用,以及 Go Vet 如何幫助我們避免潛在的錯誤。sync.noCopy 的作用—————–sync.noCopy 結構體通常與 sync.WaitGroup 等同步原語一起出現,例如:t ⌘ Read more

⤋ Read More
In-reply-to » This is only first draft quality, but I made some notes on the #twtxt v2 proposal. http://a.9srv.net/b/2024-09-25

@anth@a.9srv.net you wrote:

“Edits and Deletions should go; see also Section 6. This is probably the worst example of this document pushing a text document to do more protocol-like things.”

Edit and deletions are precisely what brought us here. Currently, if one replies to a twtxt, and the original gets later edited, it breaks replies, and potentially drastically changes context.

⤋ Read More

Go 語言與 SQL 數據庫的交互方式
Go 語言作爲一門簡潔高效的語言,在與關係型數據庫交互方面也擁有着豐富的選擇。本文將深入探討 Go 語言中幾種常見的與 SQL 數據庫交互方式,並通過示例代碼、優缺點分析和擴展知識點,幫助你更好地理解和選擇適合你的方案。Go 語言與 SQL 數據庫交互的常見方式———————Go 語言標準庫提供了database/sql包,它是一個基礎的 SQL 數據庫驅動接口,爲各種 ⌘ Read more

⤋ Read More

Golang 實用技巧:使用 go-nanoid 高效生成唯一隨機 ID
作爲一名程序員,我們經常會遇到需要生成唯一標識符(ID)的場景。不管是創建用戶 ID、訂單號還是其他需要唯一性的數據,生成隨機且唯一的 ID 是保證系統健壯性的基礎之一。在 Go 語言中,有很多方法可以實現這一功能,今天我想和大家聊聊如何使用 go-nanoid 這個庫來生成隨機的唯一 ID。go-nanoid 是一個 Go 語言庫,用來高效地生成唯一的隨機 ID(類似於 UUID),並且生成的 ⌘ Read more

⤋ Read More

Starting a couple of new projects (geez where do I find the time?!):

HomeTunnel:

HomeTunnel is a self-hosted solution that combines secure tunneling, proxying, and automation to create your own private cloud. Utilizing Wireguard for VPN, Caddy for reverse proxying, and Traefik for service routing, HomeTunnel allows you to securely expose your home network services (such as Gitea, Poste.io, etc.) to the Internet. With seamless automation and on-demand TLS, HomeTunnel gives you the power to manage your own cloud-like environment with the control and privacy of self-hosting.

CraneOps:

craneops is an open-source operator framework, written in Go, that allows self-hosters to automate the deployment and management of infrastructure and applications. Inspired by Kubernetes operators, CraneOps uses declarative YAML Custom Resource Definitions (CRDs) to manage Docker Swarm deployments on Proxmox VE clusters.

⤋ Read More
In-reply-to » Some more arguments for a local-based treading model over a content-based one:

And finally the legibility of feeds when viewing them in their raw form are worsened as you go from a Twt Subject of (#abcdefg12345) to something like (https://twtxt.net/user/prologic/twtxt.txt 2024-09-22T07:51:16Z).

⤋ Read More
In-reply-to » Some more arguments for a local-based treading model over a content-based one:

There is also a ~5x increase cost in memory utilization for any implementations or implementors that use or wish to use in-memory storage (yarnd does for example) and equally a 5x increase in on-disk storage as well. This is based on the Twt Hash going from a 13 bytes (content-addressing) to 63 bytes (on average for location-based addressing). There is roughly a ~20-150% increase in the size of individual feeds as well that needs to be taken into consideration (on the average case).

⤋ Read More
In-reply-to » Some more arguments for a local-based treading model over a content-based one:

So really your argument is just that switching to a location-based addressing “just makes sense”. Why? Without concrete pros/cons of each approach this isn’t really a strong argument I’m afraid. In fact I probably need to just sit down and detail the properties of both approaches and the pros/cons of both.

I also don’t really buy the argument of simplicity either personally, because I don’t technically see it much more difficult to take a echo -e "<url>\t<timestamp>\t<content>" | sha256sum | base64 as the Twt Subject or concatenating the <url> <timestamp> – The “effort” is the same. If we’re going to argue that SHA256 or cryptographic hashes are “too complicated” then I’m not really sure how to support that argument.

⤋ Read More

Gorm 自定義數據類型
在處理數據庫交互時,我們經常會遇到將數據在 Go 結構體和數據庫關係之間來回轉換的需求。今天,我們將深入探討 Gorm 中的自定義數據類型,這是一種強大的工具,可以幫助我們實現靈活的數據映射和自定義邏輯。使用場景:處理軍官等級———–爲了更好地理解自定義數據類型的用途,我們以一個現實的例子來說明:構建一個軟件來存儲和讀取美軍軍官的等級信息。這個例子中,我們定義了兩個結構體:Go 結構 ⌘ Read more

⤋ Read More

Go 語言併發編程之互斥鎖 sync-Mutex
大家好,我是 frank。「Golang 語言開發棧」公衆號作者。01 介紹Go 標準庫 sync 提供互斥鎖 Mutex。它的零值是未鎖定的 Mutex,即未被任何 goroutine 所持有,它在被首次使用後,不可以複製。我們可以使用 Mutex 限定同一時間只允許一個 goroutine 訪問和修改臨界區。02 使用在介紹怎麼使用 Mutex 之前,我們先閱讀 sync.Mutex 源碼 ⌘ Read more

⤋ Read More

👋 Reminder folks of the upcoming Yarn.social monthly online meetup:

I hope to see @david@collantes.us @movq@www.uninformativ.de @lyse@lyse.isobeef.org @xuu@txt.sour.is @sorenpeter@darch.dk and hopefully others too @aelaraji@aelaraji.com @falsifian@www.falsifian.org and anyone else that sees this! 🙏 We’re hopefully going to primarily discuss the future of Twtxt and the last few weeks of discussions 🤣

  • Event: Yarn.social Online Meetup
  • When: 28th September 2024 at 12:00pm UTC (midday)
  • Where: Mills Meet : Yarn.social
  • Cadence: 4th Saturday of every Month

Agenda:

  • Let’s talk about the upcoming changes to the Twtxt spec(s)

#Yarn.social #Meetup

⤋ Read More

Halfbrick+ Lets You Play Popular iOS Games Like Fruit Ninja, Jetpack Joyride and Mega Jump for $2.99/Month
Halfbrick Studios is a game company best known for super popular iOS titles like Fruit Ninja and Jetpack Joyride, which have historically been freemium titles. Starting last year, Halfbrick decided to go with a different monetization model, offering all of its games for a low monthly fee.

Image

[Halfb … ⌘ Read more

⤋ Read More

go:embed 在 Go 開發中的應用與最佳實踐
背景–在使用 Go 開發命令行工具或桌面軟件時,將配置文件、模板,甚至整個前端應用直接嵌入到 Go 二進制文件中是一種提高應用部署效率和簡化操作的有效方法。這種方法可以減少外部依賴,讓應用在沒有額外資源文件的情況下也能獨立運行,特別適合需要便捷分發和部署的場景。自 Go 1.16 版本起,Go 語言官方引入了 //go:embed 指令,使得嵌入靜態資源變得異常簡單而直接。這一新特性大大簡化了 ⌘ Read more

⤋ Read More

基於反射的輕量級 Go 依賴注入框架
在軟件開發領域,依賴注入(DI)是一種強大的設計模式,它可以幫助我們編寫鬆散耦合、易於測試和維護的代碼。雖然在 Go 語言中,依賴注入的使用不如其他語言(如 Java 或 C#)那麼普遍,但在構建大型、複雜的應用程序時,它仍然可以發揮重要作用。Parsley 就是爲此而生的。它是一個易於使用、基於反射的 Go 依賴注入包,可以無縫地集成到任何 Go 應用程序中。Parsley——-Pars ⌘ Read more

⤋ Read More

構建 Go RESTful API 的終極指南:Fiber、GORM 和 PostgreSQL
本文將帶你一步步構建一個基於 Go、Fiber 和 GORM 的 RESTful API,並使用 PostgreSQL 作爲數據庫。我們將涵蓋從項目搭建、數據庫配置到 API 路由、認證、授權、錯誤處理等關鍵環節,並附有完整代碼示例和詳細解釋,幫助你快速上手 Go RESTful API 開發。項目搭建—-首先,我們需要創建一個新的 Go 項目並安裝必要的依賴包。 初始化 Go 模塊go mo ⌘ Read more

⤋ Read More

I wrote some code to try out non-hash reply subjects formatted as (replyto ), while keeping the ability to use the existing hash style.

I don’t think we need to decide all at once. If clients add support for a new method then people can use it if they like. The downside of course is that this costs developer time, so I decided to invest a few hours of my own time into a proof of concept.

With apologies to @movq@www.uninformativ.de for corrupting jenny’s beautiful code. I don’t write this expecting you to incorporate the patch, because it does complicate things and might not be a direction you want to go in. But if you like any part of this approach feel free to use bits of it; I release the patch under jenny’s current LICENCE.

Supporting both kinds of reply in jenny was complicated because each email can only have one Message-Id, and because it’s possible the target twt will not be seen until after the twt referencing it. The following patch uses an sqlite database to keep track of known (url, timestamp) pairs, as well as a separate table of (url, timestamp) pairs that haven’t been seen yet but are wanted. When one of those “wanted” twts is finally seen, the mail file gets rewritten to include the appropriate In-Reply-To header.

Patch based on jenny commit 73a5ea81.

https://www.falsifian.org/a/oDtr/patch0.txt

Not implemented:

  • Composing twts using the (replyto …) format.
  • Probably other important things I’m forgetting.

⤋ Read More
In-reply-to » I setup and switched to Headscale last night. It was relatively simple, I spent more time installing a web GUI to manage it to be honest, the actual server is simple enough. The native Tailscale Android app even works with it thankfully.

@eldersnake@we.loveprivacy.club I wanted to ask you, are you running Headscale and WireGuard on the same VPS? I want to test Headscale, but currently run a small container with WireGuard, and I wonder if I need to stop (and eventually get rid of) the container to get Headscale going. Did you use the provided .deb to install Headscale, or some other method?

⤋ Read More
In-reply-to » Apple A16 SoC Now Manufactured In Arizona "Apple has begun manufacturing its A16 SoC at the newly-opened TSCM Fab 21 in Arizona," writes Slashdot reader NoMoreACs. AppleInsider reports: According to sources of Tim Culpan, Phase 1 of TSMC's Fab 21 in Arizona is making the A16 SoC of the iPhone 14 Pro in "small, but significant, numbers. The production is largely a test for the facility at this stage, but more production is expected ... ⌘ Read more

@eldersnake@we.loveprivacy.club there has to be less reliance on a single point of failure. It is not so much about creating jobs in the US (which come with it, anyway), but about the ability to produce what’s needed at home too. What’s the trade off? Is it going to be a little bit more expensive to manufacture, perhaps?

⤋ Read More

Golang 實現 IP 地址掃描
你是否想過哪些設備連接到了家裏的 Wi-Fi 網絡?無論是出於安全目的還是單純的好奇心,我們都可以去了解一下家庭網絡中的設備情況。在本文中,我們將介紹如何使用 Go 構建一個簡單的 IP 地址掃描器,它可以掃描家庭網絡並列出所有活動設備。爲什麼要構建 Ip scanner市面上有很多網絡掃描工具,但自己構建網絡掃描工具能讓我們靈活地理解和修改代碼,以滿足需求。此外,這還是學習 Go 網絡編程的好方 ⌘ Read more

⤋ Read More

如何用 Go 來構建 LLM 應用
隨着大型語言模型(LLM)及其相關工具(如嵌入模型)在過去一年中能力顯著提升,越來越多的開發者考慮將 LLM 集成到他們的應用程序中。由於 LLM 通常需要專用硬件和大量計算資源,它們通常作爲網絡服務打包,提供 API 供訪問。這就是 OpenAI 和 Google Gemini 等領先 LLM 的 API 工作方式;即使是像 Ollama 這樣的自託管 LLM 工具,也將 LLM 封裝在 RES ⌘ Read more

⤋ Read More

Golang 使用 upx 減少可執行文件的大小
衆所周知,Golang 的編譯速度是非常之快的。在設計 Go 時,編譯速度是一個重要的考慮因素。但是,你是否關注過 Go 編譯代碼後生成的二進制可執行文件的大小?讓我們來看一個簡單的 HTTP 服務的應用示例:import (       ”fmt”       ”net/http” )   func main() {       // create a http server and creat ⌘ Read more

⤋ Read More

I have configured my twtxt.txt as simple as possible. I have setup a publish_command on jenny. Hopefully all works fine, and I am good to go. Next will be setting the announce_me to true. Here we go!

⤋ Read More
In-reply-to » I’m not advocating in either direction, btw. I haven’t made up my mind yet. 😅 Just braindumping here.

@movq@www.uninformativ.de going a little sideways on this, “*If twtxt/Yarn was to grow bigger, then this would become a concern again. But even Mastodon allows editing, so how much of a problem can it really be? 😅*”, wouldn’t it preparing for a potential (even if very, very, veeeeery remote) growth be a good thing? Mastodon signs all messages, keeps a history of edits, and it doesn’t break threads. It isn’t a problem there.😉 It is here.

I think keeping hashes is a must. If anything for that “feels good” feeling.

⤋ Read More

Regarding jenny development: There have been enough changes in the last few weeks, imo. I want to let things settle for a while (potential bugfixes aside) and then I’m going to cut a new release.

And I guess the release after that is going to include all the threading/hashing stuff – if we can decide on one of the proposals. 😂

⤋ Read More

Go 開發人員開發 WebRTC 的福音
Pion 是 WebRTC API 的純 Golang 實現。開發 WebRTC 應用可以使用該庫,提高開發效率。你可以使用 Pion 去創造一些很棒的東西,以下是一些可以讓你創意源源不斷的想法:發送一個視頻文件到多個瀏覽器,以實現完美同步的電影觀看。 將嵌入式設備上的網絡攝像頭內容發送到瀏覽器,無需額外的服務器。 不需要訂閱發佈,就可以在兩臺服務器之間安全地發送數據。 ⌘ Read more

⤋ Read More