Radar · Go · Archive · Week 13 · Mar 24 – 30, 2025
Goodbye core types – Hello Go
Nice to knowlanguage
- What changed
- The Go 1.25 language spec removes the notion of core types.
- Production impact
- The source does not say.
- Try it
- Read the blog post to understand how type declarations are now expressed.
- Source
- go.dev/blog/coretypes
Understand it, then run it
The Go 1.25 release removed a concept called *core types* from the language specification. Before 1.25, the spec used core types to describe how generic code should behave. Now the spec simply talks about the underlying type of a value, and adds a short paragraph that covers the generic case. This change does not affect any existing program; it only simplifies the wording in the spec.
Run it now
// This program demonstrates that the removal of core types in Go 1.25
// does not affect ordinary generic code. It uses a type constraint that
// only requires the underlying type to be []byte or string, without
// any method requirements. The function `at` indexes into the
// generic operand and returns the byte at the given position.
// The program prints the result of indexing a []byte slice and a string.
package main
import "fmt"
// Constraint allows any type whose underlying type is []byte or string.
type Constraint interface {
~[]byte | ~string
}
// at returns the byte at index i of a value that satisfies Constraint.
func at[T Constraint](s T, i int) byte {
return s[i]
}
func main() {
b := []byte{10, 20, 30}
s := "abc"
fmt.Printf("b[1] = %d\n", at(b, 1)) // 20
fmt.Printf("s[2] = %c\n", at(s, 2)) // 'c'
}
What it printed when we ran it on Go 1.27.1
b[1] = 20 s[2] = c
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