首页›发现›编程›The Go Blog

The Go Blog

Atom运行正常
go.dev·编程·英语
访问网站
文章数10
更新频率每月约 3.5 篇
最近抓取12分钟前
订阅方式Atom
订阅地址https://go.dev/blog/feed.atom

最近的文章

订阅后,这些文章和以后的新文章都会出现在你的阅读器里

Go Turns 17

AI 摘要Marking the 17th anniversary of Go's open source release, the Go team reflects on a year that included Go 1.26 and Go 1.27, delivering improvements such as generic methods, a redesigned encoding/json/v2 with up to 10× faster unmarshaling, a production goroutine leak profiler, the default Green Tea garbage collector, experimental SIMD support, and post-quantum cryptography. The team also emphasizes rapid ecosystem defense, exemplified by an urgent security release addressing the eMudhra certificate key disclosure incident within hours. Throughout, Go aims to remain grounded in simplicity, reliability, efficiency, and compatibility while adapting to modern hardware and serving both human developers and AI-assisted development.

A new Go API for JSON

AI 摘要This Go Blog post announces that the new encoding/json/v2 and encoding/json/jsontext packages are stable and generally available in Go 1.27, addressing long-standing shortcomings of the original encoding/json package, including behavioral flaws (such as accepting invalid UTF-8 and duplicate object member names), API deficiencies, and performance limitations that cannot be fixed within the Go 1 compatibility promise. The new architecture separates syntactic encoding/decoding (handled by jsontext with true streaming support) from semantic marshaling/unmarshaling (handled by json/v2), with options as first-class arguments and new streaming-oriented interfaces like MarshalJSONTo and UnmarshalJSONFrom. The v2 API is designed to fix these problems while remaining familiar enough that existing v1 usage can migrate with mostly the same behavior.

Our Response To The eMudhra Key Disclosure Incident

AI 摘要The Go security team responded to a critical PKI compromise involving eMudhra intermediate certificates whose weak private keys could be recovered in microseconds, potentially enabling attackers to impersonate any TLS server. Within roughly seven and a half hours of being notified, they shipped their first-ever URGENT track security release (Go 1.27.3 and 1.26.10) blocking trust in the compromised certificates. The team also outlined lessons learned, including plans to improve release efficiency and bring certificate revocation support parity to Linux, possibly via the upki project.

Help set Go's priorities for next year

AI 摘要The 2026 Go Developer Survey is now open through November 3, and the Go team encourages all developers to participate since their feedback directly shapes the team's priorities. Last year's survey drew 5,379 responses, with the top frustration being adherence to best practices and Go idioms, which led to a rewritten go fix in Go 1.26 and additional modernizers in Go 1.27. Results from this year's survey will be shared on the Go blog in early 2027.

Interactive refactoring in gopls

AI 摘要The Go team introduces interactive refactoring in gopls, powered by a newly proposed Language Server Protocol (LSP) capability that lets language servers ask users for input via dynamic, multi-step dialogs directly in their editors. This unlocks long-awaited refactorings such as adding or removing struct tags with custom conventions, implementing interfaces with dynamic symbol search, and moving declarations across files and packages. The feature was designed in collaboration with the Dart team as an open standard for all languages and editors, and is available in gopls v0.24.0 and the official VS Code Go extension v0.56.0.

Better HTTP/1 connection reuse

AI 摘要This Go blog post explains why HTTP/1 connection reuse fails when response bodies are left unread: since HTTP/1 responses are sent sequentially, net/http can only reuse a connection after the current response body is read to the end, so closing an unread body forced clients through Go 1.26 to pay the cost of repeatedly establishing new TCP/TLS connections. Developers traditionally worked around this by manually draining response bodies, but doing so safely requires careful limits on bytes and time spent draining. Starting in Go 1.27, net/http.Transport automatically drains unread HTTP/1 response bodies asynchronously (up to 50 ms or 256 KB), so developers can simply close bodies as usual—a benchmark against index.golang.org improved from ~710 ms to ~150 ms, nearly 5 times faster.

Arch-specific SIMD in Go

AI 摘要Go 1.27 extends the experimental SIMD support introduced in Go 1.26 beyond amd64 to arm64 and wasm, accessible via GOEXPERIMENT=simd through the low-level simd/archsimd package. The API uses sensible, unified method names (like Add and ShiftAllLeft) and relies on compiler optimizations to hide hardware details such as masked instructions and 128-bit lane boundaries, while still exposing architecture-specific operations like Galois Field affine transforms and matrix transposes. The authors cover the package's type system, naming conventions, zero-cost bit reinterpretation, and opaque mask types, and welcome feedback on usability and performance.

Platform-independent SIMD in Go

AI 摘要Go 1.26 and 1.27 introduce experimental APIs for SIMD operations, with Go 1.26 offering the architecture-dependent archsimd package for amd64 and Go 1.27 extending it to arm64 (NEON) and wasm. Because SIMD architectures vary widely in vector sizes, masking behavior, and supported instructions, Go 1.27 also introduces a fully portable, platform- and size-agnostic simd package (loosely based on C++'s Highway) that supports only operations common across platforms and efficiently emulates the rest. The simd package currently supports AVX, AVX2, and AVX512 on amd64, NEON on arm64, and wasm SIMD, and provides mechanisms to transition to and from platform-specific code when portable operations are insufficient.

Size-Specialized Memory Allocation

AI 摘要Go 1.27 introduces size-specialized memory allocation, which speeds up allocations of 80 bytes or fewer by 20-30% and makes allocation-heavy programs up to 1% faster. The runtime generates specialized mallocgc variants for each span class, enabling optimizations like compiler-generated constant-size memory clearing, skipped span class calculations, and manual inlining of helper functions. The team carefully tuned the feature to balance performance gains against executable size and instruction cache effects, so programmers automatically benefit simply by building with Go 1.27.

Goroutine Leak Profiles

AI 摘要This Go Blog post introduces the goroutine leak profiler coming in Go 1.27, a lightweight, low-false-positive mechanism for detecting goroutines permanently blocked on channels or sync package primitives, even in production systems where tools like goleak and synctest fall short. It walks through a common real-world leak caused by worker goroutines blocked forever sending on an unbuffered channel after an early return, showing how to collect and inspect the new goroutineleak profile via pprof to pinpoint the culprit. Under the hood, the profiler adapts the garbage collector's reachability marking to determine goroutine 'liveness,' while limitations include memory overreach, detection restricted to first-class Go concurrency primitives (excluding IO, syscalls, and custom locks), and non-determinism in catching flaky leaks.