Archive · Week 13 · Mar 23 – 29, 2026from 2 items
The Go team accepted a proposal to add example support to the `go doc` command, and a blog post highlighted new type‑construction simplifications and cycle‑detection improvements in Go 1.26.
Worth knowingtooling
go-proposals-accepted: cmd/doc: add example support
- What changed
- The
go doccommand now accepts a-exflag that prints examples attached to the API, and it can also print the source of an example function when the symbol name starts withExample. - Production impact
- The source does not say.
- Try it
- Run
go doc -ex bytes.Bufferorgo doc bytes.ExampleBufferin a repository that contains example functions. - Source
- github.com/golang/go/issues/26715
Explain it and run it
Understand it, then run it
Run it now
// This program demonstrates that the `-ex` flag for `go doc` is not
// available in Go 1.27.1. It simply prints a message indicating the
// missing feature.
package main
import "fmt"
func main() {
// In Go 1.27.1, `go doc` does not support the `-ex` flag, so we
// cannot request examples directly from the command line.
fmt.Println("The `-ex` flag for `go doc` is not available in Go 1.27.1.")
}
What it printed when we ran it on Go 1.27.1
The `-ex` flag for `go doc` is not available in Go 1.27.1.
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 knowlanguage
go-blog: Type Construction and Cycle Detection
- What changed
- Go 1.26 simplifies type construction and enhances cycle detection for certain kinds of recursive types.
- Production impact
- The source does not say.
- Try it
- Read the blog post to understand the new type‑construction rules and experiment with recursive type definitions in a Go 1.26 environment.
- Source
- go.dev/blog/type-construction-and-cycle-detection
Explain it and run it
Understand it, then run it
Run it now
// This program demonstrates a simple recursive type that compiles
// thanks to Go 1.26's improved type construction. It prints the
// size of the slice element type to show that the compiler has
// resolved the recursion.
package main
import (
"fmt"
"unsafe"
)
// Node is a recursive type: each node points to another Node.
type Node struct {
next *Node
}
func main() {
// Create a slice of Nodes to exercise the recursive type.
nodes := make([]Node, 3)
// Link the nodes together.
for i := 0; i < 2; i++ {
nodes[i].next = &nodes[i+1]
}
// Print the size of the Node type to confirm the compiler
// has constructed it correctly. The size includes a pointer.
fmt.Printf("Size of Node: %d bytes\n", unsafe.Sizeof(Node{}))
}
What it printed when we ran it on Go 1.27.1
Size of Node: 8 bytes
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
Open a Go project that contains example functions (e.g., ExampleBuffer in the bytes package). Run go doc -ex bytes.Buffer to see the API with examples, then run go doc bytes.ExampleBuffer to view the example source code.
The 60-second version
Hello, I’m here to share a couple of updates from the Go team this week. First, they’ve accepted a proposal that brings example support to the `go doc` command. With a new `-ex` flag, you can now see examples attached to the API right in the documentation output, and you can even request the source of an example function by naming it directly. Second, the Go blog highlighted that Go 1.26 simplifies type construction and improves cycle detection for certain recursive types. These changes are part of the ongoing effort to make Go’s language and tooling clearer and more powerful for developers. That’s all for this week’s Radar.
Written by gpt-oss-20b · claims checked against the sources · archive, not individually reviewed