Archive · Week 35 · Aug 24 – 30, 2026from 2 items
The Go team accepted a proposal to add a new HTTP method constant and announced the arrival of generic methods in Go 1.27. Both items touch on core language and standard library features that will affect how developers write and maintain code.
Worth knowingstdlib
net/http: add MethodQuery constant
- What changed
- The standard library now defines
const MethodQuery = "QUERY"innet/http/method.go. - Production impact
- The source does not say.
- Try it
- Import
net/httpand printhttp.MethodQueryto verify the new constant. - Source
- github.com/golang/go/issues/80058
Explain it and run it
Understand it, then run it
The HTTP protocol has a method called QUERY that lets a client send a large or binary request body while still keeping the request safe and idempotent. The Go standard library now defines a constant for this method: MethodQuery = "QUERY". Before this change you could not refer to the method by a predefined name; you would have to type the string yourself. With the new constant you can write http.MethodQuery instead of "QUERY".
Run it now
// This program demonstrates that http.MethodQuery is not defined in Go 1.27.1.
// It uses the literal string "QUERY" instead, which is the value that will be
// added to the standard library in a future release.
package main
import (
"fmt"
"net/http"
)
func main() {
// Use the literal method name that will become http.MethodQuery later.
req, err := http.NewRequest("QUERY", "https://example.com", nil)
if err != nil {
panic(err)
}
fmt.Println("Method:", req.Method) // prints: QUERY
}
What it printed when we ran it on Go 1.27.1
Method: QUERY
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 knowinglanguage
Generic Methods in Go 1.27
- What changed
- Go 1.27 introduces generic methods, allowing methods on types to be parameterized with type parameters.
- Production impact
- The source does not say.
- Try it
- Write a type with a generic method and compile with Go 1.27.
- Source
- go.dev/blog/generic-methods
Explain it
Understand it, then run it
Go 1.27 adds generic methods. Before this, only functions and type definitions could have type parameters. Now a method on a concrete type can also be parameterized, so you can write a method that works for any element type. For example, a linked‑list type can expose a Map method that turns a list of int into a list of string without writing a new function for each pair of types.
Exercise
Write a simple program that uses the new http.MethodQuery constant to create an HTTP request and prints the method used.
The 60-second version
Hello, and welcome to this week’s Go Radar. The Go team has just added a new constant to the HTTP package: `MethodQuery`. This constant represents the HTTP QUERY method, a safe and idempotent operation that can carry a request body, filling the gap between GET and POST. It’s a small change, but it gives developers a new tool for designing APIs that need complex queries without resorting to POST. In the language space, Go 1.27 brings generic methods. This means you can now write methods on types that are themselves parameterized by type parameters, just like generic functions. It opens up new patterns for reusable, type‑safe code. Those are the highlights for this week. Happy coding!
Written by gpt-oss-20b · claims checked against the sources · archive, not individually reviewed