Searching We.Love.Privacy.Club

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

Go 語言的雙向鏈表、list 操作和雙向循環鏈表- 這些誰認識?
雙向鏈表1)雙向鏈表的結構雙向鏈表結構中元素在內存中不是緊鄰空間,而是每個元素中存放上一個元素和後一個元素的地址第一個元素稱爲(頭)元素,前連接(前置指針域)爲 nil 最後一個元素稱爲 尾(foot)元素,後連接(後置指針域)尾 nil 雙向鏈表的優點在執行新增元素或刪除元素時效率高,獲取任意一個元素,可以方便的在這個元素前後插入元素 充分利用內存空間,實現內存靈活管理 ⌘ Read more

⤋ Read More

更強大的 Go 執行跟蹤能力
runtime/trace 包 1] 包含了一個強大的工具, 可用於理解和調試 Go 程序。該功能允許我們在一段時間內對每個 goroutine 的執行進行跟蹤。使用 go tool trace 命令 [2), 我們就可以可視化和探索這些跟蹤數據。跟蹤的魔力在於, 它可以輕鬆揭示程序中一些通過其他方式很難發現的問題。例如, 大量 goroutine 在同一個 channel 上阻塞導致的併發瓶頸, ⌘ Read more

⤋ Read More

使用 mapstructure 高效解析 Go 語言中的動態數據結構
在處理數據流(如 JSON、Gob 等)過程中,我們可能不知道底層數據的結構,這時mapstructure庫就能大顯身手了。這款 Go 語言庫可以將通用 map 值解碼爲 Go 本地結構,也可執行反向操作,並提供有用的錯誤處理功能。今天,我們就深入瞭解這個庫,並列舉一些豐富的示例來幫助你掌握它的使用方法。簡介–mapstructure是一款 Go 庫,允許開發者將map[string]inter ⌘ Read more

⤋ Read More

Go 錯誤處理:用 select-case 來解決這個歷史難題?
大家好,我是煎魚。日常看 Go 社區的一些新動態,發現大家對於錯誤處理的新提案是很積極。上次分享了一篇想要用 switch-case 來解決現狀的新提案,不少同學認爲不可行。沒想到 Go 社區的同學腦洞還是很大的,這幾天又整出來個 select-case 的新提案的方式來解決錯誤處理。今天基於此給大家分享一下社區裏的新腦洞。快速背景—-本節的背景主要是給不瞭解的同學拉通一下。如果已經知道的可以 ⌘ Read more

⤋ Read More

Go 中的高速數據包處理: 從 net-Dial 到 AF_XDP
推進 Go 的極限: 從 net.Dial 到系統調用、AFPACKET 和極速 AFXDP。數據包發送性能的基準測試。最近, 我編寫了一個 Go 程序, 向數百萬個 IP 地址發送 ICMP ping 消息 [1]。顯然, 我希望這個過程能儘可能快速高效地完成。因此, 這促使我研究各種與網絡棧交互和快速發送數據包的各種方法。這是一個有趣的旅程, 所以在本文中, 我將分享一些學習成果, 並記錄 ⌘ Read more

⤋ Read More

寶藏級 Go 語言開源項目——教你自己動手開發互聯網搜索引擎
DIYSearchEngine 是一個能夠高速採集海量互聯網數據的開源搜索引擎,採用 Go 語言開發。Github 地址: https://github.com/johnlui/DIYSearchEngine 運行方法 首先,給自己準備一杯咖啡。把本項目下載到本地 編譯:go build -o ese *.go 修改配置文件:cp .env.example .env,然後把裏面的 ⌘ Read more

⤋ Read More

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