Archive · Week 38 · Sep 15 – 21, 2025from 4 items
This week the Go team accepted three proposals that extend the language and standard library, and a blog post announced a new survey. The proposals add a new form of the `new` builtin, refine the `maphash` package, and introduce an error field on QUIC events.
Worth knowinglanguage
Expression to create pointer to simple types
- What changed
- The proposal is to add support for
new(expr)by amending the Allocation section to say thatnew(expr)allocates a variable of typeT, initializes it to the value ofexpr, and returns its address. - Production impact
- The source does not say.
- Try it
- Write
p := new(123)and observe that*pis123. - Source
- github.com/golang/go/issues/45624
Explain it and run it
Understand it, then run it
Go lets you create a new variable and get a pointer to it with the built‑in new. Before the change you could only write new(T) where T is a type, and the new variable would be zero‑valued. The change adds a second form: new(expr). If expr is an expression of type T, new(expr) allocates a variable of type T, stores the value of expr in it, and returns a pointer to that variable. So new(123) now gives you a pointer to an int whose value is 123, just like new(int) gives you a pointer to an int whose value is 0.
Run it now
// This program demonstrates the new `new(expr)` feature.
// It prints the value of a pointer created with new(123).
package main
import "fmt"
func main() {
// Allocate an int initialized to 123 and get its address.
p := new(123)
// Dereference the pointer to read the value.
fmt.Println(*p) // Output: 123
}
What it printed when we ran it on Go 1.27.1
123
After the change ships
go · the proposal's code; it does not compile until the change ships
// This code does not compile until the change ships in Go 1.26.
package main
import "fmt"
func main() {
p := new(123)
fmt.Println(*p)
}
Run sends this program (for Solidity, the contract and its tests) to our own sandbox, where it is compiled and run once, with no network, and what it printed or the test report comes back here. Nothing is kept. Runs are counted per visitor for the day so everyone gets a turn; the details are on the legal page.
Worth knowingstdlib
crypto/tls: add QUICEvent.Err
- What changed
- The proposal is to add an
Errfield toQUICEventand produce an event with a type ofQUICNoEventand theErrfield set when an error occurs. - Production impact
- The source does not say.
- Try it
- Create a
QUICConnand trigger a handshake error to see aQUICNoEventwithErrpopulated. - Source
- github.com/golang/go/issues/75108
Explain it and run it
Understand it, then run it
The TLS package in Go can run over QUIC, a transport that needs to know when the handshake fails. Before the change, a QUICConn could only report errors when the caller called a function that returned an error. If an error happened deeper in the handshake, there was no way to surface it. The change adds an Err field to the QUICEvent type. When an error occurs, the library will emit an event whose kind is QUICNoEvent and whose Err field contains the error. This lets code that watches for events know that the connection has failed without having to check every function return value.
Run it now
// This program demonstrates how QUICEvent.Err would be used once the change
// ships. It does not actually create a QUIC connection because that requires
// network I/O, but it shows the structure and how an error would be checked.
package main
import (
"fmt"
)
type QUICEvent struct {
// Set for QUICNoEvent
Err error
// existing fields as-is
}
const (
// QUICNoEvent indicates that there are no events available.
// QUICEvent.Err is set if the connection has encountered a fatal error.
QUICNoEvent = iota
)
func main() {
// Simulate receiving an event with an error.
event := QUICEvent{Err: fmt.Errorf("handshake failed")}
if event.Err != nil {
fmt.Println("Fatal error detected:", event.Err)
} else {
fmt.Println("No error")
}
}
What it printed when we ran it on Go 1.27.1
Fatal error detected: handshake failed
Run sends this program (for Solidity, the contract and its tests) to our own sandbox, where it is compiled and run once, with no network, and what it printed or the test report comes back here. Nothing is kept. Runs are counted per visitor for the day so everyone gets a turn; the details are on the legal page.
Nice to knowstdlib
maphash: drop purego version and establish stronger runtime boundary
- What changed
- The proposal is to hand off maintenance of a reflection-based implementation of the
maphashpackage to the GopherJS project and drop thepuregoimplementation from std. - Production impact
- The source does not say.
- Try it
- Run
go test ./...to see that themaphashpackage no longer importsreflect. - Source
- github.com/golang/go/issues/74285
Explain it and run it
Understand it, then run it
The maphash package is used by Go to create hash values for map keys. In the past it had two versions: one that worked only on the standard Go runtime and another “purego” version that could run on other implementations like TinyGo or GopherJS. The purego version was slow and pulled in many other packages, making it hard for low‑level parts of the standard library to depend on maphash. The change removes that purego version and keeps only the runtime‑specific implementation, which is now the single source of truth for hashing map keys.
Run it now
// This program demonstrates the current maphash implementation.
// In Go 1.27.1 the purego version has been removed, so we use the
// runtime‑specific implementation directly. The program hashes a
// string and prints the resulting 64‑bit value.
package main
import (
"fmt"
"hash/maphash"
)
func main() {
var h maphash.Hash
h.WriteString("hello world")
fmt.Printf("hash: %x\n", h.Sum64())
}
What it printed when we ran it on Go 1.27.1
hash: 914c36ec41c4095d
Run sends this program (for Solidity, the contract and its tests) to our own sandbox, where it is compiled and run once, with no network, and what it printed or the test report comes back here. Nothing is kept. Runs are counted per visitor for the day so everyone gets a turn; the details are on the legal page.
Nice to knowecosystem
It's survey time! How has Go been working out for you?
- What changed
- A blog post announces a new Go survey.
- Production impact
- The source does not say.
- Try it
- Visit the link and fill out the survey.
- Source
- go.dev/blog/survey2025-announce
Explain it and run it
Understand it, then run it
Go has announced a new annual survey for 2025. The survey is open until September 30th and is meant to gather feedback from developers about how they use Go and what they need. All questions are optional, and participants can choose whether their responses are shared in the public dataset. The Go team will publish aggregated results in early November and will also release the raw data for community analysis.
Run it now
// This program demonstrates how to print the URL of the 2025 Go Developer Survey.
// The survey URL is provided in the blog post and is not part of the Go language.
package main
import "fmt"
func main() {
// Survey link from the Go blog announcement
surveyURL := "https://go.dev/blog/survey2025"
fmt.Println("Take the 2025 Go Developer Survey at:", surveyURL)
}
What it printed when we ran it on Go 1.27.1
Take the 2025 Go Developer Survey at: https://go.dev/blog/survey2025
Run sends this program (for Solidity, the contract and its tests) to our own sandbox, where it is compiled and run once, with no network, and what it printed or the test report comes back here. Nothing is kept. Runs are counted per visitor for the day so everyone gets a turn; the details are on the legal page.
Exercise
Write a small program that uses the new new(expr) syntax to create a pointer to an integer initialized to 42, then prints the value pointed to.
The 60-second version
Hello, everyone. This week the Go team added a new way to use the `new` builtin: you can now write `new(expr)` to allocate a variable of the same type as the expression and initialize it with that value. They also cleaned up the `maphash` package by removing the purego implementation and handing the remaining code over to the GopherJS project, tightening the boundary between runtime‑specific and portable code. In the TLS world, the `crypto/tls` package now includes an `Err` field on QUIC events, allowing connections to report fatal errors that occur outside the usual handshake functions. Finally, a new Go survey has been announced to help shape the language’s future. Those are the highlights from this week.
Written by gpt-oss-20b · claims checked against the sources · archive, not individually reviewed