The Go Programming Language Blog
1,615 FOLLOWERS
The Official blog page of Go Programming Language. Get the latest update, news, libraries and much more.
The Go Programming Language Blog
1w ago
The Go Blog Go Developer Survey 2024 H1 Results
Alice Merrick and Todd Kulesza
9 April 2024
Background
This post shares the results of our most recent Go Developer Survey, conducted in January and February 2024. Along with capturing sentiments and challenges around using Go and Go tooling, our primary focus areas for this survey were about how developers are starting to use Go (or other languages) for AI-related use cases, and particular challenges for those who are learning Go or looking to expand their Go skill set.
We recruited participants from the Go blog and through randomized prompts in ..read more
The Go Programming Language Blog
1M ago
The Go Blog More powerful Go execution traces
Michael Knyszek
14 March 2024
The runtime/trace package contains a powerful tool for understanding and troubleshooting Go programs. The functionality within allows one to produce a trace of each goroutine’s execution over some time period. With the go tool trace command (or the excellent open source gotraceui tool), one may then visualize and explore the data within these traces.
The magic of a trace is that it can easily reveal things about a program that are hard to see in other ways. For example, a concurrency bottleneck where lots of goroutine ..read more
The Go Programming Language Blog
2M ago
The Go Blog Robust generic functions on slices
Valentin Deleplace
22 February 2024
The slices package provides functions that work for slices of any type. In this blog post we’ll discuss how you can use these functions more effectively by understanding how slices are represented in memory and how that affects the garbage collector, and we’ll cover how we recently adjusted these functions to make them less surprising.
With Type parameters we can write functions like slices.Index once for all types of slices of comparable elements:
// Index returns the index of the first occurrence of v in s ..read more
The Go Programming Language Blog
2M ago
The Go Blog Routing Enhancements for Go 1.22
Jonathan Amsterdam, on behalf of the Go team
13 February 2024
Go 1.22 brings two enhancements to the net/http package’s router: method matching and wildcards. These features let you express common routes as patterns instead of Go code. Although they are simple to explain and use, it was a challenge to come up with the right rules for selecting the winning pattern when several match a request.
We made these changes as part of our continuing effort to make Go a great language for building production systems. We studied many third-party web frameworks ..read more
The Go Programming Language Blog
2M ago
The Go Blog Go 1.22 is released!
Eli Bendersky, on behalf of the Go team
6 February 2024
Today the Go team is thrilled to release Go 1.22, which you can get by visiting the download page.
Go 1.22 comes with several important new features and improvements. Here are some of the notable changes; for the full list, refer to the release notes.
Language changes
The long-standing “for” loop gotcha with accidental sharing of loop variables between iterations is now resolved. Starting with Go 1.22, the following code will print “a”, “b”, and “c” in some order:
func main() {
done := make(chan bool ..read more
The Go Programming Language Blog
4M ago
The Go Blog Finding unreachable functions with deadcode
Alan Donovan
12 December 2023
Functions that are part of your project’s source code but can never be reached in any execution are called “dead code”, and they exert a drag on codebase maintenance efforts. Today we’re pleased to share a tool named deadcode to help you identify them.
$ go install golang.org/x/tools/cmd/deadcode@latest
$ deadcode -help
The deadcode command reports unreachable functions in Go programs.
Usage: deadcode [flags] package...
Example
Over the last year or so, we’ve been making a lot of changes to the structure ..read more
The Go Programming Language Blog
5M ago
The Go Blog Go Developer Survey 2023 H2 Results
Todd Kulesza
5 December 2023
Background
In August 2023, the Go team at Google conducted our bi-annual survey of Go developers. We recruited participants via a public post on the Go blog and a randomized prompt in VS Code, resulting in 4,005 responses. We primarily focused survey questions around a few topics: general sentiment and feedback about developing with Go, technology stacks used alongside Go, how developers start new Go projects, recent experiences with toolchain error messages, and understanding developer interest around ML/AI.
Thank yo ..read more
The Go Programming Language Blog
5M ago
The Go Blog Fourteen Years of Go
Russ Cox, for the Go team
10 November 2023
Today we celebrate the fourteenth birthday of the Go open source release! Go has had a great year, with two feature-filled releases and other important milestones.
We released Go 1.20 in February and Go 1.21 in August, focusing more on implementation improvements than new language changes.
Profile-guided optimization (PGO), previewed in Go 1.20 and released in Go 1.21, allows the Go compiler to read a profile of your program and then spend more time optimizing the parts of your program that run most often. In Go 1.21 ..read more
The Go Programming Language Blog
7M ago
The Go Blog Everything You Always Wanted to Know About Type Inference - And a Little Bit More
Robert Griesemer
9 October 2023
This is the blog version of my talk on type inference at GopherCon 2023 in San Diego, slightly expanded and edited for clarity.
What is type inference?
Wikipedia defines type inference as follows:
Type inference is the ability to automatically deduce, either partially or fully, the type of an expression at compile time. The compiler is often able to infer the type of a variable or the type signature of a function, without explicit type annotations having been given.
T ..read more
The Go Programming Language Blog
7M ago
The Go Blog Deconstructing Type Parameters
Ian Lance Taylor
26 September 2023
slices package function signatures
The slices.Clone function is pretty simple: it makes a copy of a slice of any type.
func Clone[S ~[]E, E any](s S) S {
return append(s[:0:0], s...)
}
This works because appending to a slice with zero capacity will allocate a new backing array. The function body winds up being shorter than the function signature, which is in part because the body is short, but also because the signature is long. In this blog post we’ll explain why the signature is written the way that it is.
S ..read more