Searching We Love Privacy Club

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

Fruit, veg growers say biggest customer ‘is the rubbish bin’, as millions of tonnes of food is wasted
Fresh produce growers scramble to meet “forecast” supply deals with supermarkets, but every year millions of dollars of surplus food goes to waste. So what’s going on? ⌘ Read more

⤋ Read More

4 秒處理 10 億行數據! Go 語言的 9 大代碼方案,一個比一個快
編譯 | 核子可樂、凌敏來自 | InfoQ2024 年開年,Java “十億行挑戰”(1BRC)火爆外網。該挑戰賽要求開發者編寫一個 Java 程序,從一個包含十億行信息的文本文件中檢索溫度測量值,並計算每個氣象站的最小、平均值和最高溫度。“十億行挑戰” 的目標是爲這項任務創建最快的實現,同時探索現代 Java 的優勢。這項挑戰聽起來很簡單。但十億行代碼實際是一項龐大的工程,如果以每個數字 3 ⌘ Read more

⤋ Read More

Go arena 民間庫來了,可以手動管理內存!
大家好,我是煎魚。上年我們有討論過關於 Go arena 手動管理內存的相關提案。一開始還高歌猛進,但沒想到後面由於嚴重的 API 問題(想把 arena 應用到其他的標準庫中,但會引入大問題):Go 核心團隊中途咕咕咕到現在,沒有新的推動和突破性進展,實屬尷尬。最近有社區的大佬有了新的動作,來自 Grafana 的 @Miguel Ángel Ortuño 開源了一個新的第三方庫 ortuman ⌘ Read more

⤋ Read More

slog 終極指南
在本文中,我們將探討 Go 中的結構化日誌記錄,並特別關注最近推出的 log/slog[1] 軟件包, 這個軟件包旨在爲 Go 帶來高性能、結構化和分級的日誌記錄標準庫。該軟件包起源於由 Jonathan Amsterdam 發起的 GitHub 討論 [2], 後來專門建立了一個提案 [3] 細化設計。一旦定稿,它在 Go v1.21 版本中發佈。在以下各節中,我將全面呈現 slog 的功能, ⌘ Read more

⤋ Read More

Go 爲什麼不支持從 main 包中導入函數?
大家好,我是煎魚。作爲一個維護過許多有一定歷史沉澱的 Go 項目的人,在歷史債務下和奇葩需求下,會遇到一些迫於業務需求的技術訴求。訴求上是希望引用多項目,會出現從 main 包(package)中導入相關函數的這種使用訴求。爲了將多 Go 工程合併到一個大單體中使用。問題案例—-具體的使用案例如下。我們有一個 Go 應用,目錄結構如下:demo1├── go.mod├── main.go└── ⌘ Read more

⤋ Read More

深入探究 Go log 標準庫
Go 語言標準庫中的 log 包設計簡潔明瞭,易於上手,可以輕鬆記錄程序運行時的信息、調試錯誤以及跟蹤代碼執行過程中的問題等。使用 log 包無需繁瑣的配置即可直接使用。本文旨在深入探究 log 包的使用和原理,幫助讀者更好地瞭解和掌握它。使用先來看一個 log 包的使用示例:package mainimport “log”func main() { log.Print(“Print”) ⌘ Read more

⤋ Read More

Go 併發編程 —— I-O 聚合優化(動畫講解)
背景提要在存儲系統中,在確保功能不受損的前提下,儘量的減少讀寫 I/O 的次數是優化的一個重要方向,也就是聚合 I/O 的場景。讀寫操作雖然都有聚合 I/O 的需求,但各自的重點和實現方法卻有所不同。接下來,我們將分別探討讀和寫請求的聚合優化方法。讀請求的聚合以讀操作中,緩存優化是一種常見的優化手段。具體做法是將讀取的數據存儲在內存中,並通過一個唯一的 Key 來索引這些數據。當讀請求來到時,如果 ⌘ Read more

⤋ Read More

Skyway 10km: 6.28 miles, 00:08:28 average pace, 00:53:09 duration
went in with no expectations. did not go all out but still put in a good effort. there were a lot of people (8,00 in total) and the majority were walking which is not a big deal but did mean a lot of weaving through trying to find opening. it was a great production and would do it again if i had someone who wanted to run it with me.
#running #race

⤋ Read More

獲取請求 IP,nginx 配置方案,gin 框架,2024 版,go 語言
在使用 Gin 框架時,獲取用戶請求的真實 IP 地址涉及到多種情況,尤其在使用代理服務器(如 Nginx)時。本文將詳細介紹如何使用 Gin 自帶方法和其他方式獲取用戶 IP,以及在面對 Nginx 轉發時如何準確獲取客戶端 IP,同時討論與 IP 相關的安全問題及處理方法。第一章:概述——1.1 獲取用戶真實 IP 的重要性獲取用戶的真實 IP 地址是許多應用中必不可少的功能,用於識別 ⌘ Read more

⤋ Read More

Economic hardship in Dunkley will see votes ‘spray in a myriad of directions’
Redbridge Group Director Simon Welsh says the “personal stuff” is what sticks with him in the aftermath of focus groups in the Dunkley electorate.

“It is the stories of the economic hardship – particularly that northern half of the electorate,” he told Sky News Australia.

“I think that is going to be so volatile.

“I don’t think it necessarily … ⌘ Read more

⤋ Read More

China wine tariffs expected to be gone by end of March after trade minister meets with Chinese counterpart
The ABC understands that China will lift wine tariffs it had placed on Australian at the end of March, after Trade Minister Don Farrell met with his Chinese counterpart Wang Wentao overnight. ⌘ Read more

⤋ Read More

‘I’m not taking the word of any politician’: Andrew Forrest on nuclear energy push
Fortescue Chairman Andrew Forrest has rubbished the Coalition’s push for nuclear energy.

Mr Fortescue told Sky News Australia how he spoke with General Energy about the costs of implementing nuclear energy and the timeframe required.

“If I order one, when do I get one? And they said, ‘mate, look, 15 years’,” he said.

“I’m not going to … ⌘ Read more

⤋ Read More

Thousands of academic workers at York University go on strike
Some students at Toronto’s York University are worried about falling behind on their school work after a union representing 3,000 academic workers said the university didn’t meet their demand to “address the affordability crisis” and the workers went on strike. Dozens of union members including contract faculty, teaching and graduate assistants, research assistants and part-tim … ⌘ Read more

⤋ Read More

Here’s how Toronto’s new one-fare program works
GTA commuters will now be reimbursed their single-ride TTC fare when transferring to and from GO Transit as part of the city’s one-fare program. As CBC’s Patrick Swadden reports, the province has committed to funding the new program until March 2026. ⌘ Read more

⤋ Read More

How to Recover Unsaved Word Documents on Mac with AutoRecovery
While you should get in the habit of frequently saving your documents as you work in them, including in Microsoft Word, things don’t always go as planned. Many modern Mac apps will automatically save progress as you work in them, and Microsoft Word is one of them. Thanks to a feature called AutoRecovery, which saves … [Read More](https://osxdaily.com/2024/02/26/how-to-recover-unsaved-word-documents-on-mac-wit … ⌘ Read more

⤋ Read More

Iranians urged to vote in first elections since wave of protests
Voters in Iran are being urged to go to the polls as the country gears up for its first elections since Iran was rocked by nationwide protests over the death of Iranian Kurd Mahsa Amini, 22, after her arrest for allegedly violating the strict dress code for women. Surveys showed most voters don’t intend to take part in the poll. ⌘ Read more

⤋ Read More

Concept of gender pay gap is a ‘load of nonsense’: Caleb Bond
Sky News host Caleb Bond says the concept of gender pay gap is a “load of nonsense”.

Mr Bond said it “denies the biological reality” of women going off to have children.

“Which necessarily affects their lifetime earnings, because they tend to take more time out.

“Women tend to work in what you might call caring positions.

“Like nursing or teaching, that tend to be paid less … ⌘ Read more

⤋ Read More

Albanese wants to ‘hold on’ to younger voters: PM spotted going to Taylor Swift concert
The Australian’s National Editor Dennis Shanahan says Prime Minister Anthony Albanese wants to “hold on” to younger voters after he was spotted going to a Taylor Swift concert.

Mr Shanahan joined Sky News host Peta Credlin to discuss Mr Albanese’s reputation after attending the concert.

“Well the Prime Minister is constantly … ⌘ Read more

⤋ Read More

Klopp MASTERCLASS & Chelsea Fan *RANT*
Football Today Podcast - Episode 20, Monday February 26 - Klopp MASTERCLASS & Chelsea Fan RANT.

The Football Today Podcast debates their signature Yeah/Nah’s on if VAR is ruining the game and segments of performance, bellend, save and goal of the week in the EPL over the weekend.

The panel go through EPL Matchweek 26 match with the game of the weekend Arsenal vs Newcastle, Villa dominating and Fulham creating histor … ⌘ Read more

⤋ Read More

淺聊 Go 分佈式鏈路追蹤
在現代複雜的分佈式系統環境中,對應用或系統進行性能診斷,這是一個極具挑戰性的任務。有時候,微服務的問題可能會影響到整個系統的鏈路,引發一系列難以追蹤的問題。對於使用 Go 語言的開發者來說,我們有幸的是,對於鏈路追蹤,我們有強大的工具——Go 的鏈路追蹤。什麼是鏈路追蹤?——–鏈路追蹤是一種性能優化策略,通過跟蹤和管理請求在應用環境中的路徑,我們可以更好地理解系統的行爲、性能瓶頸等問題。 ⌘ Read more

⤋ Read More

Status 2024-02-25
Status report again!

Image

Figure 1: A visitor this morning.

Sitting in front of the wood stove in my country cottage. It’s nice
and quiet. Meanwhile it seems NordicFuzzCon is going on in Malmö.
4,000 furries. I had no idea! That seems fun!

On the other hand I just read that at least 10,000 were protesting in
Malmö today against the Israel-Palestine conflict. I’ve seen the much
smaller protest … ⌘ Read more

⤋ Read More

Farmers still toiling to fix infrastructure months after Cyclone Jasper flooded the Far North
Daintree farmers have been working for two months to fix infrastructure damaged by Tropical Cyclone Jasper floods, but say there are many more months to go before they will get on top of the repairs. ⌘ Read more

⤋ Read More

Golang 數據結構性能優化實踐
僅僅通過對 struct 字段重新排序,優化內存對齊方式,就可以獲得明顯的內存和執行效率提升。原文: How to Speed Up Your Struct in Golang[1]如果你有 Golang 開發經驗,一定定義過 struct 類型。但可能你不知道,通過簡單的重新排序 struct 字段,可以極大提高 Go 程序的速度和內存使用效率!是不是難以置信?我們一起來看一下吧!簡單 De ⌘ Read more

⤋ Read More

如何正確處理 Go 項目中關於文件路徑的問題
在使用 Go 開發項目時,估計有不少人遇到過無法正確處理文件路徑的問題,特別是剛從如 PHP、python 這類動態語言轉向 Go 的朋友,已經習慣了通過相對源碼文件找到其他文件。這個問題能否合理解決,不僅關係到程序的可移植性,還直接影響到程序的穩定性和安全性。本文將嘗試從簡單到複雜,詳細介紹 Go 中獲取路徑的不同方法及應用場景。歡迎關注我的公衆號:引言首先,爲什麼要獲取文件路徑?一般來說,程序 ⌘ Read more

⤋ Read More

使用 Templ 進行 Go 模板化
使用 Templ 在 Go 項目中高效生成動態內容的指南—————————-動態內容生成是 Web 開發的一個基本方面。無論您是在構建網站、Web 應用程序還是 API,根據數據和模板生成動態內容的能力都至關重要。在 Go 編程世界中,一個名爲 “Templ” 的強大工具簡化了這一過程。在這份全面的指南中,我們將探索使用 Templ 進行 Go 模板化,它的關鍵 ⌘ Read more

⤋ Read More

Golang 泛型入門指南
Go 語言中的泛型是指一種語言特性,允許創建可以處理不同類型的函數、數據結構和接口。換句話說,泛型使得可以創建不受特定類型或數據結構限制的代碼。如果我們此前有使用 Java 或者 C++ 的經驗,那麼會很好理解。在 Go 語言引入泛型之前,開發人員必須編寫多個函數來處理不同類型的數據。這種方法通常很繁瑣,並導致代碼重複。有了泛型,開發人員可以編寫更簡潔和可重用的代碼,可以處理不同類型的數據。Go ⌘ Read more

⤋ Read More

Go 利用上下文進行併發計算
在 Go 編程中,上下文(context)是一個非常重要的概念,它包含了與請求相關的信息,如截止日期和取消信息,以及在請求處理管道中傳遞的其他數據。在併發編程中,特別是在處理請求時,正確處理上下文可以確保我們尊重和執行請求中設定的限制,如截止時間。讓我們通過一些代碼示例來探討如何在併發計算中使用上下文,以及如何在處理請求時尊重上下文所設定的截止日期和取消要求。// download 函數用於下載給 ⌘ Read more

⤋ Read More

Go Module 語義化版本規範
Go Module 的設計採用了語義化版本規範,語義化版本規範非常流行且具有指導意義,本文就來聊聊語義化版本規範的設計和在 Go 中的應用。語義化版本規範語義化版本規範(SemVer)是由 Gravatars 創辦者兼 GitHub 共同創辦者 Tom Preston-Werner 所建立,旨在解決 依賴地獄 問題。它清楚明瞭的規定了版本格式、版本號遞增規:版本格式:採用 X.Y.Z 的格式,X ⌘ Read more

⤋ Read More

Go Gin 框架與 Let’s Encrypt 集成指南
本文將深入探討如何在 Go 語言的 Gin 框架中集成 Let’s Encrypt,以實現自動化管理 SSL/TLS 證書。Let’s Encrypt 作爲一個免費、自動、開放的證書頒發機構,能讓 HTTPS 部署變得簡單便捷。通過該教程,您將瞭解到如何配置 Gin 以支持 HTTPS 服務,並自動從 Let’s Encrypt 申請和續簽證書,確保 Web 應用的安全可靠性。爲什麼需要 Let’ ⌘ Read more

⤋ Read More

Golang 如何有效限制併發數?
Go 語言目前很火熱,一部分原因在於自身帶 “高併發” 的標籤,其本身就擁有優秀的併發量和吞吐量。1 協程可以無限創建嗎?我們在日常開發中會有高併發場景,有時會用多協程併發實現。在高併發業務場景,能否可以隨意開闢 goroutine 並且放養不管呢?畢竟有強大的 GC 和優越的 GMP 調度算法。看下面的代碼:package mainimport (    ”fmt”    ”math”    ” ⌘ Read more

⤋ Read More

用 Go 語言實現劉謙春晚魔術,還原尼格買提汗流浹背的尷尬瞬間-
龍年春晚如期而至,想必大家都看(沒)完(眼)了(看)吧,今年春晚最搞笑節目,當屬劉謙的魔術:《守歲共此時》,不過笑點不是節目本身,而是本場魔術的 托兒(主持人)尼格買提。小尼:已經開始流汗了 😅。本文將帶大家一起用 Go 語言來還原下整個魔術的過程。 在開始寫代碼前,翻車畫面必須置頂 🤣:這是一個公式魔術,即有着固定的套路,從數學角度來看是一個「約瑟夫問題」(嚴格證明可以在網上搜到,如果你感興趣 ⌘ Read more

⤋ Read More

在 Golang 中 如何實現 NATS JetStream 隊列
NATS JetStream 是一個高性能、持久化、分佈式消息隊列系統,它爲發佈 / 訂閱、隊列和流式處理提供了豐富的功能。在 Go 中實現 NATS JetStream 隊列可以通過 NATS 客戶端庫來完成。一、NATS JetStream 的歷史NATS JetStream 是 NATS 消息系統的一個重要組件,旨在提供持久性消息傳遞和流處理功能。下面是 NATS JetStream 的歷史 ⌘ Read more

⤋ Read More

精心設計的 DNS Failover 策略在 Go 中竟然帶來了反效果,發生了什麼?
本期作者衛智雄嗶哩嗶哩高級運維工程師一. 背景如下配置所示,我們在 /etc/resolv.conf 中配置了兩個 nameserver,其中 server2 在災備機房 ,作爲一種 failover 策略。nameserver server1nameserver server2options timeout:1 attempts:1我們的預期是如果 server1 服務正常,則所有的 DNS 請 ⌘ Read more

⤋ Read More

Go Gin 框架定義路由日誌格式
在本文中,我們將深入探討如何在 Go 語言的 Gin 框架中自定義路由日誌的格式。Gin 是一個高性能的 HTTP web 框架,它提供了一個默認的日誌格式,但在實際的開發環境中,我們可能需要根據特定的業務需求調整日誌輸出的格式。我們將從瞭解 Gin 的默認日誌格式開始,逐步地引導你自定義和擴展路由日誌的輸出方式。文章內容將詳實介紹相關的代碼實現,以確保你能夠在自己的工作中靈活運用。Gin 框架默 ⌘ Read more

⤋ Read More

Go 更強的代碼潔癖,可以把 gofmt 給換了!
大家好,我是煎魚。我們從一開始寫 Go 代碼和應用,就會被各種官方和民間教程,甚至 IDE 教導我們必須配一個 gofmt 工具。他能夠格式化 Go 程序的代碼。會使用製表符表示縮進,空白表示對齊。這解決了程序員屆的老大難問題之一,代碼格式上的規範問題。有效的提高了 Go 代碼的閱讀的友好度和減少了同事間的 ****。非常值得認可。但有時候,還是會看到一些糟心的代碼,總會覺得 gofmt,還是格式 ⌘ Read more

⤋ Read More

Go 中最常用的數據校驗庫
項目地址: github.com/go-playground/validator/v10| 標記 | 標記說明 | 例 || — | — | — || required | 必填 | Field 或 Struct validate:“required” || omitempty | 空時忽略 | Field 或 Struct validate:“omitempty” || len ⌘ Read more

⤋ Read More

Go Gin 框架的模型綁定與驗證詳解
在 Web 開發中,模型綁定和驗證是確保數據完整性和減少安全風險的重要步驟。Go 語言的 Gin 框架提供了強大而靈活的模型綁定和驗證機制,本文將深入講解 Gin 框架中如何進行模型綁定和驗證,以及如何自定義驗證器。在 Gin 框架中,模型綁定通常指將請求的數據(例如 JSON、表單數據)綁定到指定的結構體上,而驗證則是確保綁定後的數據符合我們設置的規則。Gin 框架使用binding標籤來實現模 ⌘ Read more

⤋ Read More

Go 語言版本 1-22 的路由增強功能
Go 1.22 對 net/http包中的路由器進行了兩項增強:方式匹配和通配符。這些特性允許你將常見的路由表示爲模式,而非 Go 代碼。儘管這些功能簡單易解釋和使用,但想選擇成功模式的正確規則(當多個模式匹配一個請求時)依然是個挑戰。我們作出這些改變是爲了持續讓 Go 成爲構建生產系統的優秀語言。我們研究了許多第三方 web 框架,提取出我們認爲最常用的特性,並將它們集成進 net/http。然 ⌘ Read more

⤋ Read More

使用 Gin 框架中的 PureJSON 發送未轉義的 JSON
當我們使用 Go 的 Gin web 框架來構建 RESTful API 時,通常會遇到返回 JSON 響應的需求。Gin 框架提供了c.JSON方法來以 JSON 格式發送回覆,同時它會對特殊字符進行轉義,比如把 < 轉換爲 \u003c。但在某些情況下,我們需要發送未轉義的 JSON 數據,這時我們就可以使用 Gin 框架中的c.PureJSON方法。在 Gin 框架中,c.PureJSON方 ⌘ Read more

⤋ Read More