Searching We.Love.Privacy.Club

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

在 Go 中如何使用反射實現簡易版 encoding-json
在使用 Go 語言開發過程中,我們經常需要實現結構體到 JSON 字符串的序列化(Marshalling)或 JSON 字符串到結構體的反序列化(Unmarshalling)操作。Go 爲我們提供了 encoding/json 庫可以很方便的實現這一需求。在本文中,我們將探索如何使用 Go 的反射機制自己來實現一個簡易版的 encoding/json 庫。這個過程不僅能幫助我們理解序列化和反序列化 ⌘ Read more

⤋ Read More

Go 還是 TinyGo?
什麼是 TinyGo?TinyGo 與 Go 有何不同? TinyGo 與 Go 相比性能如何?什麼是 TinyGo?———–TinyGo 不是另一種編程語言。它只是 Go 語言的一個編譯器。關鍵區別在於 TinyGo 編譯器創建的二進制文件更小, 主要用於嵌入式系統和 WASM。而 Go 編譯器則用於編譯完整的服務器端應用程序和通用程序。TinyGo 使用 LLVM 作爲後端, 與 ⌘ Read more

⤋ Read More

你是如何用 Go 語言 配置高性能 sql-DB 的?
配置高性能的 sql.DB 是 Go 應用程序開發中一個重要的環節,特別是在需要處理大量數據庫查詢的情況下。以下是一些最佳實踐和配置建議:1. 數據庫連接池的配置Go 的 database/sql 包提供了連接池的功能,您可以通過設置最大空閒連接、最大打開連接數和連接的最大生命週期來優化連接池。db, err := sql.Open(“mysql”, ”user:password@tcp(127. ⌘ Read more

⤋ 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.

@prologic@twtxt.net Yes I suppose that is true. There is an article on Tailscale’s site that explains it all quite a bit: https://tailscale.com/blog/how-nat-traversal-works

To me, with CGNAT, it’s a small miracle that a direct connection can be made between peers (as opposed to going through a relay constantly) but it does indeed work. I guess to host it at home you would need to have it WAN accessible, and if you’ve already gone to the trouble of port forwarding etc… well 😅
Not that I could personally do that, but for those with static IPs etc.

⤋ Read More

Lambda-Go:將函數式編程引入 Go
函數式編程是編程範式當中的一種,喜歡的人愛之如命,不喜歡的人嗤之以鼻,以簡單高效著稱的 Go 天然在函數式編程上有自己的優勢。Lambda-Go[1] 是一個旨在將受 Haskell 啓發的函數式編程技術引入 Go 生態系統的庫。在本文中,我們將探討 Lambda-Go 的功能,以及它如何增強你的 Go 編程體驗。Lambda-Go 簡介Lambda-Go 是一個 Go 庫,它通過函數式編程結構擴 ⌘ Read more

⤋ Read More

Go 異步編程小技巧
我們通過一個簡單的例子看一下 Goroutine 的使用func main() {    go func() {        fmt.Println(“Goroutine started”)        // do some work        fmt.Println(“Goroutine finished”)    }()    // wait for Goroutine to fini ⌘ Read more

⤋ Read More
In-reply-to » Hack of the day: running watch -n 60 rm -rf /tmp/yarn-avatar-* in a tmux because all of a sudden, without warning, yarnd started throwing hundreds of gigabytes of files with names like yarn-avatar-62582554 into /tmp, which filled up the entire disk and started crashing other services.

@prologic@twtxt.net I’m still getting this crap:

abucci@buc:~/yarnd/yarn$ ls -lh /tmp/yarnd-avatar-*
-rw------- 1 abucci abucci 863M Jul 25 14:19 /tmp/yarnd-avatar-1594499680
-rw------- 1 abucci abucci 7.8G Jul 25 14:19 /tmp/yarnd-avatar-2144295337
-rw------- 1 abucci abucci 9.8G Jul 25 14:19 /tmp/yarnd-avatar-2334738193
-rw------- 1 abucci abucci  10G Jul 25 14:14 /tmp/yarnd-avatar-2494107777
-rw------- 1 abucci abucci 9.5G Jul 25 13:59 /tmp/yarnd-avatar-2619243454
-rw------- 1 abucci abucci  11G Jul 25 14:04 /tmp/yarnd-avatar-2922187513
-rw------- 1 abucci abucci 7.5G Jul 25 14:14 /tmp/yarnd-avatar-349775570
-rw------- 1 abucci abucci  10G Jul 25 14:09 /tmp/yarnd-avatar-3640724243
-rw------- 1 abucci abucci 901M Jul 25 14:19 /tmp/yarnd-avatar-3921595598
-rw------- 1 abucci abucci 9.5G Jul 25 13:59 /tmp/yarnd-avatar-609094539
-rw------- 1 abucci abucci 9.3G Jul 25 14:04 /tmp/yarnd-avatar-755173392
-rw------- 1 abucci abucci 7.9G Jul 25 14:09 /tmp/yarnd-avatar-984061000

Something like 100 Gbytes of this junk has accumulated since I updated and re-started the server. I’m now running the latest version of yarnd, so the update did not fix the problem. Something else is going wrong.

How are temporary files growing to 10 Gbytes in size? The name of the file is “yarn-avatar”, but why would avatars be so large?

⤋ Read More
In-reply-to » Hack of the day: running watch -n 60 rm -rf /tmp/yarn-avatar-* in a tmux because all of a sudden, without warning, yarnd started throwing hundreds of gigabytes of files with names like yarn-avatar-62582554 into /tmp, which filled up the entire disk and started crashing other services.

@prologic@twtxt.net

abucci@buc:~/yarnd/yarn$ make preflight
Checking Go version ...                 [ ERR ]
Go 1.16+ is required, found go1.22.5
FATAL: 🙁 preflight failed
make: *** [Makefile:33: preflight] Error 1

🤔

⤋ Read More

This is completely insane!

abucci@buc:/tmp$ du -sh /tmp/yarnd-avatar-*
564M    /tmp/yarnd-avatar-3024946878
7.2G    /tmp/yarnd-avatar-3122347915
11G     /tmp/yarnd-avatar-3533381443
445M    /tmp/yarnd-avatar-441914658

I’m going to have to shut down my server soon. This looks like some kind of DDoS. Whether intentional or not it’s filling up the disk at an unsustainable rate.

⤋ Read More

There are also a bunch of log messages scrolling by. I’ve never seen this much activity in the log:

Jul 25 01:37:39 buc.ci yarnd[829]: [yarnd] 2024/07/25 01:37:39 (149.71.56.69) "GET /external?nick=lovetocode999&uri=https://pagez.co.uk/services/your-own-100-fully-owned-online-vi>
Jul 25 01:37:39 buc.ci yarnd[829]: [yarnd] 2024/07/25 01:37:39 (162.211.155.2) "GET /twt/112135496802692324 HTTP/1.1" 400 12 826.65µs
Jul 25 01:37:40 buc.ci yarnd[829]: [yarnd] 2024/07/25 01:37:40 (51.222.253.14) "GET /conv/muttriq HTTP/1.1" 200 36881 20.448309ms
Jul 25 01:37:40 buc.ci yarnd[829]: [yarnd] 2024/07/25 01:37:40 (162.211.155.2) "GET /twt/112730114943543514 HTTP/1.1" 400 12 663.493µs
Jul 25 01:37:40 buc.ci yarnd[829]: [yarnd] 2024/07/25 01:37:40 (27.75.213.253) "GET /external?nick=lovetocode999&uri=http%3A%2F%2Falfarah.jo%2FHome%2FChangeCulture%3FlangCode%3Den>
Jul 25 01:37:40 buc.ci yarnd[829]: time="2024-07-25T01:37:40Z" level=error msg="http://bynet.com.br/log_envio.asp?cod=335&email=%21%2AEMAIL%2A%21&url=https%3A%2F%2Fwww.almanacar.c>
Jul 25 01:37:40 buc.ci yarnd[829]: [yarnd] 2024/07/25 01:37:40 (162.211.155.2) "GET /twt/111674756400660911 HTTP/1.1" 400 12 545.106µs
Jul 25 01:37:40 buc.ci yarnd[829]: time="2024-07-25T01:37:40Z" level=warning msg="feed FetchFeedRequest: @<lovetocode999 http://alfarah.jo/Home/ChangeCulture?langCode=en&returnUrl>
Jul 25 01:37:41 buc.ci yarnd[829]: [yarnd] 2024/07/25 01:37:41 (162.211.155.2) "GET /twt/112507964696096567 HTTP/1.1" 400 12 838.946µs

Something really weird is going on?

⤋ Read More

Go 語言定時任務 time-Sleep 和 time-Tick 的優劣對比分析
golang 寫循環執行的定時任務,常見的有以下三種實現方式 1、time.Sleep 方法:for {   time.Sleep(time.Second)   fmt.Println(“我在定時執行任務”)}2、time.Tick 函數:t1:=time.Tick(3time.Second)for {   select {   case <-t1:      fmt.Println(“t1定時 ⌘ Read more

⤋ Read More

Golang - range 迭代器揭祕
簡介我們正在使用 Go 語言編寫 Dolt[1] ,這是世界上第一個版本控制的 SQL 數據庫。像大多數大型 Go 代碼庫一樣,我們有很多需要迭代的集合類型。 Go 1.23 的新特性 [2] 中,你現在可以使用 range 關鍵字來迭代自定義集合類型。這是如何工作的? 這是個好主意嗎? 讓我們深入探討一下。如果你想運行本教程中的任何代碼,你需要 安裝 Go 1.23 發佈候選版 [3] ,或者在 ⌘ Read more

⤋ Read More

使用 Go 語言創建你的第一個 2D 遊戲
Pixel 是一個用 Go 語言編寫的 2D 遊戲開發庫, 它爲開發者提供了一套簡潔而強大的工具, 讓創建像素風格的遊戲變得輕而易舉。本文將深入探討 Pixel 庫的核心特性, 並通過豐富的示例來展示如何使用它來構建引人入勝的 2D 遊戲。Pixel 的誕生與理念————Pixel 誕生於開發者對簡單而高效的 2D 遊戲開發工具的渴望。它的設計理念是 “手工打造”, 這意味着庫的每 ⌘ Read more

⤋ Read More

Genkit:新一代基於 Go 的 AI 應用開發框架
Google 推出了 Genkit for Go,這是一個開源框架,用來以 Go 語言原生構建 AI 應用與雲服務。該項目是 Google Firebase 和 Go 團隊聯手合作的最新成果。Genkit for Go 於 7 月 17 日正式推出,目前版本處於 alpha 階段。Gophers 能夠通過它將 Go 的性能和併發優勢與 Genkit 的庫和工具相結合,從而來構建生成式 AI 應用程 ⌘ Read more

⤋ Read More
In-reply-to » (#smnew7a) I admit I've always compromised on this way too much myself, always to this day having Facebook Messenger just to communicate in my families group chats. Sure I run it in a Work profile on my GrapheneOS phone that I can switch off at any time, I can completely cut it off from network access any time as well, I can have a lot of rudimentary control over it, I use it as sparingly as possible, but it doesn't change the fact everytime I use it we're funneling private convos through bloody Meta's servers and trackers etc.

@movq@www.uninformativ.de

(I don’t really trust Android, though, and I suspect that apps can still install background services that are always active. Pure speculation and paranoid on my part, but still.)

Which is fair, but I would say the GrapheneOS devs in particular are also quite paranoid about this stuff and go to great pains to make sure this stuff can be controlled by the user.

⤋ Read More

@movq@www.uninformativ.de This outage did affect me, though not much, via the university where my wife teaches and where I teach sometimes. They actually sent out an alert in their emergency alert system (the one they use to alert people of extreme weather events and bomb threats, mostly), telling people that all IT systems were down.

A friend of mine elsewhere pointed out that they pushed this change on a Friday, which of course no software developer with any experience would ever, ever, ever do. I have to assume there’s some toxic management at CrowdStrike, but who knows. Even more reasons to sympathize with the poor folks who are probably going to be working nights and weekends to clean up this mess.

⤋ Read More

Go 語言的 Lodash 風格庫
在 JavaScript 的世界裏,Lodash 是一個家喻戶曉的工具庫,它提供了豐富的函數,方便開發者操作數組、對象、字符串等等。Lodash 極大地提高了 JavaScript 開發者的效率,也讓代碼更加簡潔易讀。在 Go 語言 1.18 版本之前,由於缺乏泛型,我們很難實現像 Lodash 這樣功能強大且類型安全的工具庫。然而,隨着 Go 1.18 泛型的引入,這一切都發生了改變。sambe ⌘ Read more

⤋ Read More

在 Go 中如何使用 go:embed 指令嵌入靜態文件
有時候,將配置文件、模板甚至整個前端應用直接嵌入到 Go 二進制文件中,是一種提高應用部署效率和簡化操作的有效方法。自從 Go 1.16 版本起,Go 語言官方引入了 //go:embed 指令,這使得嵌入靜態資源變得異常簡單而直接。本文將詳細介紹如何在你的 Go 應用中使用這一強大的特性。什麼是 go:embed//go:embed 在 Go 1.16 版本中被加入,這也是我接觸 Go 語言的第 ⌘ Read more

⤋ Read More

理解並使用 Golang 的 “omitempty” 特性
在使用 Go (Golang) 並將數據編碼爲 JSON 時,您可能會遇到這樣的情況:如果某些字段的值爲空,則需要從編碼輸出中省略這些字段。這就是 Golang 的 omitempty 功能發揮作用的地方。struct 字段標記中的 omitempty 選項會告訴編碼器,如果字段爲空值,則跳過該字段。什麼是  “Empty Value”?在 Go 中,Empty Value 的定義是:布爾類型爲 ⌘ Read more

⤋ Read More

Kubestronaut in Orbit: Eleni Grosdouli
Get to know Eleni This week’s Kubstronaut in Orbit, Eleni Grosdouli, brings diverse experiences to her role as a DevOps Consulting Engineer at Cisco Systems. She’s the go-to person for DevOps and Kubernetes Automation, with a passion for… ⌘ Read more

⤋ Read More

通過實例理解 Go 訪問和操作數據庫的幾種方式
關係數據庫操作是 Go 應用開發中的重要一環,尤其是 Go Web 應用、微服務等。作爲 Gopher,我們需要了解幾種主流的數據庫訪問和操作方法,以便在項目中做出適當的選擇。我個人在日常開發中較少涉及 CRUD 類應用,因此使用 Go 訪問和操作數據庫的機會並不多,在這方面也算是有一些 “短板”。通過在這篇文章中對數據庫訪問方式進行全面的梳理,我也算是補全一下技能樹,同時也能爲讀者小夥伴提供一些 ⌘ Read more

⤋ Read More

Go 語言的 Web 開發利器:Templ - HTMX 打造交互式體驗
在 Web 開發領域,Go 語言以其簡潔、高效和強大的併發能力著稱。Templ 和 HTMX 則是與 Go 完美契合的工具,它們分別負責頁面的渲染和交互邏輯,共同打造出現代化的 Web 應用。本文將深入探討 Templ 和 HTMX 的核心概念、使用方法以及如何結合 Go 語言構建出色的 Web 應用。Templ:Go 語言的模板引擎—————-Templ 是 Go 語言自帶的 ⌘ Read more

⤋ Read More

在 Go 項目中使用 Redis 的幾個實用建議
今天來聊一聊 Redis,主要是聊一些在 Go 項目中使用 go-redis 代碼上的一些建議。在上代碼之前我還是要廢話幾句,在大家開發需求用到 Redis 時一定要多想個兩分鐘 “我是不是把 Redis 當數據庫用了?” 因爲數據在數據庫和 Redis 裏存兩份就就得考慮它們的一致性怎麼維護,賊麻煩,而這個一致性不做上線後還經常會出 BUG,所以不是必要我一般不用 Redis。需要過期的數據肯定 ⌘ Read more

⤋ Read More

Long run: 9.33 miles, 00:10:21 average pace, 01:36:32 duration
easy run on the treadmill today since we have a lot going on and i had to watch the kiddos. split into three 5kms with first and last at about 10:55 pace, and the middle 5km at about a 9:14 pace. nothing crazy, felt good, kept it in the blue and finished it strong.
#running #treadmill

⤋ Read More

全面掌握 Go 語言 errors 標準庫:使用指南與源碼深度解析
前言–在 Go 語言中,錯誤處理是一個重要的部分。Go 官方提供了一個輕量級的 errors 標準庫,用於創建和處理錯誤。本文將介紹如何使用 Go 的 errors 標準庫,並深入解析其源碼實現。準備好了嗎?準備一杯你最喜歡的咖啡或茶,隨着本文一探究竟吧。 Go 版本:1.22.0error 接口——–下面的內容會提到 error 接口,因此我們有必要先了解一下 error 接口的相 ⌘ Read more

⤋ Read More

Go 語言實現 Base64、Base58 編碼與解碼,很簡單
在 Go 語言中,實現 Base64 和 Base58 編碼與解碼是非常常見的任務。Go 標準庫中已經包含了 Base64 的編碼與解碼函數,而 Base58 需要使用第三方庫來實現。下面分別介紹 Base64 和 Base58 編碼與解碼的實現方法。Base64 編碼與解碼Go 標準庫的encoding/base64包提供了 Base64 編碼與解碼的功能。示例代碼package mainimp ⌘ Read more

⤋ Read More

Go 1-23 的 os-CopyFS:告別第三方庫,輕鬆複製目錄
在 Go 1.23 版本中,標準庫 os 包引入了一個名爲 CopyFS 的新函數,它提供了一種僅使用標準庫函數即可複製目錄的便捷方法。從此,開發者無需再依賴第三方庫來完成這項常見任務。本文將深入探討 os.CopyFS 函數的功能、用法以及其帶來的優勢。告別第三方庫——在 os.CopyFS 出現之前,Go 開發者通常需要藉助第三方庫(如 github.com/otiai10/copy) ⌘ Read more

⤋ Read More

Gaby - Golang 社區機器人
Gaby 是一個實驗性的新機器人, 在 Go 問題跟蹤器中以 @gabyhelp[1] 的身份運行, 試圖自動化各種機器可以合理完成的瑣碎事務, 同時也試圖發現機器可以合理完成的新事物。gaby 這個名字是 “Go AI Bot” 的縮寫, 因爲這個實驗的目的之一是瞭解 LLM 可以有效用於哪些方面, 包括識別它們不應該用於哪些方面。一些 gaby 功能將涉及 LLM; 其他功能則不會。指導原則是 ⌘ Read more

⤋ Read More

「Go 開源」freeze:一個能將源代碼轉換成圖片的工具
大家好,我是漁夫子。今天給大家推薦的開源工具是 freeze,該工具可以將源代碼或終端中的輸出內容轉換成對應的圖片。如下圖效果:比如,我們想把一個 go 語言編寫的源代碼 main.go 轉換成圖片,則可以按如下方式操作:freeze main.go –output main.png生成的效果如下:你看,就把對應的代碼按照高亮的形式生成了圖片。實現原理那這個 freeze 的實現原理是什麼呢?通 ⌘ Read more

⤋ Read More

一款用於實時監控 PostgreSQL 數據變化的 Go 語言庫
在現代應用開發中,實時數據處理扮演着至關重要的角色。實時監控數據庫變化,並對這些變化做出迅速響應,是許多應用場景(如實時數據分析、緩存更新、事件驅動架構等)的核心需求。Flash 正是這樣一款應運而生的 Go 語言庫,它爲開發者提供了便捷高效的方式來管理 PostgreSQL 數據庫的實時變化。Flash 簡介——–Flash 是一款輕量級的 Go 語言庫,它利用事件管理機制,實現了對 ⌘ Read more

⤋ Read More

Go 性能度量利器,完全替代 io-Reader 和 io-Writer!
在 Go 語言的世界裏,io.Reader 和 io.Writer 接口是數據流處理的基石。然而,標準庫並沒有提供一種便捷的方式來追蹤通過這些接口傳輸的字節數。metered-io 庫應運而生,它提供了 io.Reader 和 io.Writer 的替代品,並能夠方便地獲取傳輸的字節總數,爲性能度量和監控提供了強大的支持。metered-io 庫簡介————–metered-io ⌘ Read more

⤋ Read More

Slurm: An HPC workload manager
Member post originally published on SuperOrbital’s blog by Sean Kane In this article, we are going to explore Slurm, a popular open-source high-performance computing (HPC1) workload manager, and discover what it is, why people use it, and how it… ⌘ Read more

⤋ Read More

聊聊 go 語言對於 socket 的抽象
寫在文章開頭——go語言對於網絡抽象做了非常通用且高性能的封裝,所以就從net包源碼入手介紹一下go語言對於socket的抽象。Hi,我是 sharkChili ,是個不斷在硬核技術上作死的 java coder ,是 CSDN 的博客專家 ,也是開源項目 Java Guide 的維護者之一,熟悉 Java 也會一點 Go ,偶爾也會在 C 源碼 邊緣徘徊。寫過很多有意思的技術博客,也還在 ⌘ Read more

⤋ Read More

PolarisMesh 源碼系列 –Polaris-Go 註冊發現流程
導語北極星是騰訊開源的一款服務治理平臺,用來解決分佈式和微服務架構中的服務管理、流量管理、配置管理、故障容錯和可觀測性問題。在分佈式和微服務架構的治理領域,目前國內比較流行的還包括 Spring Cloud,Apache Dubbo 等。在 Kubernetes 的技術領域,也有以 Istio 爲代表的 ServiceMesh 技術。本篇 Blog 主要分析北極星的優勢,及其服務註冊發現的技術實現 ⌘ Read more

⤋ Read More

以 Go 語言爲例解釋什麼是僞共享以及如何解決
本文翻譯自:What’s false sharing and how to solve it (using Golang as example)譯文在解釋僞共享(false sharing)之前,有必要簡要介紹一下 CPU 架構中緩存是如何工作的。CPU 緩存中的最小單位是緩存行(cache line)(如今,CPU 中常見的緩存行大小爲 64 字節)。因此,當 CPU 從內存讀取一個變量時, ⌘ Read more

⤋ Read More

Golang 編寫範型集合,官方文檔未提及的訣竅
引言–Go 的泛型功能在 Go 1.18 版本中發佈, 至今已有兩年多了。我們正在使用 Go 開發 Dolt[1] , 這是世界上第一個支持版本控制的 SQL 數據庫。儘管我們有數十萬行 Go 代碼, 但我們並沒有大量使用泛型。我們在一些地方使用泛型 來加速代碼中的高流量部分 [2] , 但總的來說, 除了 slices[3] 和 maps[4] 包中的一些有用的庫方法外, 我們還沒有找到使用泛 ⌘ Read more

⤋ Read More

Go 語言的 CI-CD 實踐
CI/CD 是現代軟件開發流程中的關鍵實踐,它代表着持續集成(Continuous Integration)和持續部署(Continuous Deployment)或持續交付(Continuous Delivery)的組合。這些實踐旨在幫助軟件開發團隊更快、更頻繁地交付高質量的軟件產品。持續集成(CI): 持續集成是一種軟件開發實踐,開發團隊成員經常將他們的代碼變更集成到共享的代碼倉庫中。這通常每 ⌘ Read more

⤋ Read More