Searching We.Love.Privacy.Club

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

解讀 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

Sam Whited: Coffeeneuring 2024
Every year in October I participate in Love To Ride’s (psst, sign up using
that link so I can get some extra points when you do your first bike ride!)
Biketober competition.
The TL;DR is that for every day that you go for a ride, for every mile that you
ride, and for every new rider that you invite you get points for your team.
At the end of the month winners are announced and there are some fun prizes.
It’s not about bi … ⌘ 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

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

⤋ Read More

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

⤋ Read More
In-reply-to » (#aznhzra) @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

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

Grand Canyon Rim To Rim: 27.90 miles, 00:28:36 average pace, 13:17:46 duration
grand canyon rim-to-rim with kelly and craig. it was a blast! a lot of firsts: crazy elevation, head lamps, poles. i had a really good time and then we started to encounter some elevation. definitely could feel the altitude as soon as there was an incline. then after so many large steps up my quads started to feel it. at one point everything seized up and i fell down. luckily craig jumped in my leg and started stretching it out which helped a lot. the rest of it from there it was slow going but only once the large steps were sparse we cruised ahead. definitely would do it again.
#running #race

⤋ Read More

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

@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

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

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

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

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