Archive · Week 5 · Jan 26 – Feb 1, 2026from 5 items
The Go team accepted a handful of proposals that add small convenience helpers and a minor ABI change for a rarely‑used platform. No new language features or runtime changes were introduced this week.
Worth knowingtooling
x/tools/go/ast/inspector: add (*Cursor).Valid() bool
- What changed
- The inspector package now provides a
Valid()method onCursorthat reports whether the cursor is valid. - Production impact
- The source does not say.
- Try it
- Create an
inspector.Inspector, walk the AST, and callcursor.Valid()to check validity instead of comparing to the zero value. - Source
- github.com/golang/go/issues/76361
Explain it and run it
Understand it, then run it
Run it now
// This program demonstrates how the new `Valid()` method on `Cursor` would be used.
// It defines a minimal `Cursor` type with a `Valid()` method to illustrate the API.
// In real code, you would import "golang.org/x/tools/go/ast/inspector" instead.
package main
import (
"fmt"
)
// Cursor is a stand‑in for the real inspector.Cursor type.
type Cursor struct {
inspector *int // nil means the cursor is invalid
}
// Valid reports whether the cursor is valid.
func (c Cursor) Valid() bool {
return c.inspector != nil
}
func main() {
// An invalid cursor: inspector field is nil.
var bad Cursor
fmt.Println("bad cursor valid?", bad.Valid()) // false
// A valid cursor: inspector field points to something.
x := 1
good := Cursor{inspector: &x}
fmt.Println("good cursor valid?", good.Valid()) // true
}
What it printed when we ran it on Go 1.27.1
bad cursor valid? false good cursor valid? true
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
testing/synctest: add convenience function for Sleep then Wait
- What changed
- The
synctestpackage now includes aSleep(d time.Duration)helper that callstime.Sleep(d)followed bysynctest.Wait(). - Production impact
- The source does not say.
- Try it
- In a
synctesttest, replacetime.Sleep(d); synctest.Wait()withsynctest.Sleep(d). - Source
- github.com/golang/go/issues/77169
Explain it and run it
Understand it, then run it
Run it now
// This program demonstrates that the proposed synctest.Sleep helper is not
// available in Go 1.27.1. It simply prints a message explaining the situation.
package main
import "fmt"
func main() {
fmt.Println("synctest.Sleep is not part of the standard library in Go 1.27.1.")
}
What it printed when we ran it on Go 1.27.1
synctest.Sleep is not part of the standard library 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.
Worth knowingstdlib
go/scanner: add (*Scanner).End()
- What changed
- The
go/scannerpackage now has anEnd()method that returns the position immediately after the last scanned token, ortoken.NoPosifScanhas not been called. - Production impact
- The source does not say.
- Try it
- Initialize a
scanner.Scanner, callScan()a few times, then calls.End()to get the end position. - Source
- github.com/golang/go/issues/74958
Explain it and run it
Understand it, then run it
Run it now
// This program demonstrates the new (*Scanner).End() method.
// It scans a simple Go source string and prints the position after the last token.
package main
import (
"fmt"
"go/scanner"
"go/token"
)
func main() {
src := []byte("package main\nfunc main() {}")
fset := token.NewFileSet()
file := fset.AddFile("", fset.Base(), len(src))
var s scanner.Scanner
s.Init(file, src, nil, scanner.ScanComments)
// Scan all tokens.
for {
pos, tok, lit := s.Scan()
if tok == token.EOF {
break
}
fmt.Printf("token: %s, pos: %v, lit: %q\n", tok, pos, lit)
}
// After scanning, End() gives the position after the last token.
endPos := s.End()
fmt.Printf("End position: %v (offset %d)\n", endPos, file.Offset(endPos))
}
What it printed when we ran it on Go 1.27.1
token: package, pos: 1, lit: "package"
token: IDENT, pos: 9, lit: "main"
token: ;, pos: 13, lit: "\n"
token: func, pos: 14, lit: "func"
token: IDENT, pos: 19, lit: "main"
token: (, pos: 23, lit: ""
token: ), pos: 24, lit: ""
token: {, pos: 26, lit: ""
token: }, pos: 27, lit: ""
token: ;, pos: 28, lit: "\n"
End position: 28 (offset 27)
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
Transition ppc64/linux (big‑endian) from ELFv1 to ELFv2 in Go 1.27
- What changed
- The Go team will switch the linux/ppc64 big‑endian port from the ELFv1 ABI to the ELFv2 ABI starting in Go 1.27, with a pre‑announcement in Go 1.26. The change is expected to be transparent because the target does not currently support linking against other ELF objects.
- Production impact
- The source does not say.
- Try it
- None applicable for most users; this is a background change for maintainers of the ppc64/linux port.
- Source
- github.com/golang/go/issues/76244
Explain it and run it
Understand it, then run it
Run it now
// This program demonstrates that the Go compiler for ppc64/linux
// (big‑endian) still builds and runs on Go 1.27.1, which uses ELFv2.
// It prints a simple message; the ABI switch is transparent to Go code.
package main
import "fmt"
func main() {
// Print a greeting to show the binary runs.
fmt.Println("Hello from ppc64/linux big‑endian!")
}
What it printed when we ran it on Go 1.27.1
Hello from ppc64/linux big‑endian!
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 parses a snippet of HTML and prints each node’s type as a string using the new String() method.
The 60-second version
This week the Go team added a few small convenience helpers that make working with the standard library a little smoother. In the inspector package, a `Valid()` method on the cursor lets you check whether a cursor is usable without having to compare it to a zero value. The HTML parser now has a `String()` method on its node type enum, so you can print node kinds directly for debugging. In the testing package, a new `Sleep` helper runs a virtual sleep and then waits for all goroutines to settle, helping avoid subtle race conditions in tests. The scanner package now exposes an `End()` method that returns the position just after the last token scanned, making it easier to track token boundaries. Finally, the rarely‑used big‑endian ppc64 Linux port will switch from the older ELFv1 ABI to ELFv2 in Go 1.27, a change that should be transparent to users but is important for maintainers of that platform. These updates are all small, non‑breaking, and aimed at improving ergonomics and clarity for developers working with Go’s tooling and libraries.
Written by gpt-oss-20b · claims checked against the sources · archive, not individually reviewed