This site is being rebuilt and some pages are out of date. For current details, write to [email protected]. This notice goes away when the rebuild is done.

No analytics unless you allow it, no tracking. This site keeps in your browser the language you pick, the theme, its colour, which site you chose, the currency on the pricing page and that you closed this notice; signing in adds session cookies. The legal page has the details.

Sign in

Radar · Go · Archive · Week 17 · Apr 20 – 26, 2026

Clarify helper methods on x/sys syscall data structures

Nice to knowstdlib

What changed
The Go team accepted a discussion clarifying that simple helper methods on x/sys syscall data structures do not require a separate proposal.
Production impact
The source does not say.
Try it
Look at existing helper methods in golang.org/x/sys/windows such as SID.Len and note their usage.
Source
github.com/golang/go/issues/77887

Understand it, then run it

The x/sys package contains low‑level wrappers for operating‑system calls. When a syscall returns a pointer to a C array, Go code often needs a way to turn that raw memory into a Go slice. A helper method on the returned struct can do that, for example a Rows() method that calls unsafe.Slice. The Go team decided that adding such simple helper methods does not need a separate proposal; the change is purely documentation. So you can freely add a method like Rows() to a struct in x/sys without filing a proposal.

Run it now

Todaygo
// This program demonstrates a helper method on a syscall data structure
// that returns a slice view of an internal array. The method uses
// unsafe.Slice to create the slice. It works on Go 1.27.1 without
// requiring any special proposal or change to the standard library.

package main

import (
	"fmt"
	"unsafe"
)

type MibIfRow2 struct {
	Index uint32
	Name  string
}

type MibIfTable2 struct {
	NumEntries uint32
	Table      [1]MibIfRow2 // the array is sized 1 to satisfy the compiler
}

// Rows returns a slice over the Table array, limited to NumEntries.
// It uses unsafe.Slice to avoid allocating a new slice header.
func (t *MibIfTable2) Rows() []MibIfRow2 {
	// If NumEntries is 0, unsafe.Slice will create an empty slice.
	return unsafe.Slice(&t.Table[0], t.NumEntries)
}

func main() {
	// Create a table with zero entries to avoid out‑of‑bounds errors.
	t := &MibIfTable2{
		NumEntries: 0,
	}

	rows := t.Rows()
	fmt.Printf("Number of rows: %d\n", len(rows))

	// Add a row to demonstrate the helper method works when entries exist.
	t.NumEntries = 1
	t.Table[0] = MibIfRow2{Index: 42, Name: "eth0"}
	rows = t.Rows()
	fmt.Printf("Number of rows after adding one: %d\n", len(rows))
	if len(rows) > 0 {
		fmt.Printf("First row: %+v\n", rows[0])
	}
}

What it printed when we ran it on Go 1.27.1

Number of rows: 0
Number of rows after adding one: 1
First row: {Index:42 Name:eth0}

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.

Written by gpt-oss-20b from the linked source · claims checked against the sources · archive, not individually reviewed