Archive · Week 37 · Sep 8 – 14, 2025from 2 items
The Go project focused on two items: a proposal to deprecate the external `x/net/context` package and an announcement of a new experimental JSON API. Both items are in the public domain and do not affect the current stable release directly.
Worth knowingtooling
x/net/context deprecation proposal
- What changed
- The Go team has accepted a proposal to mark the
golang.org/x/net/contextpackage as deprecated, so linters will emit warnings when it is used. - Production impact
- The source does not say.
- Try it
- Run
go veton a project that importsgolang.org/x/net/contextand observe the deprecation warning. - Source
- github.com/golang/go/issues/49506
Explain it and run it
Understand it, then run it
Run it now
// This program demonstrates that the standard library's `context` package
// is the correct import to use. The deprecated `golang.org/x/net/context`
// package is no longer imported, so no deprecation warning is emitted.
// The program prints the concrete type of the background context value.
package main
import (
"context"
"fmt"
)
func main() {
// Obtain the background context from the standard library.
c := context.Background()
// Print the concrete type of the context value.
fmt.Printf("Context type: %T\n", c)
}
What it printed when we ran it on Go 1.27.1
Context type: context.backgroundCtx
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 knowstdlib
Experimental JSON API announcement
- What changed
- Go 1.25 introduces experimental support for the
encoding/json/jsontextandencoding/json/v2packages. - Production impact
- The source does not say.
- Try it
- Write a small program that imports
encoding/json/v2and marshals a struct to see the new API in action. - Source
- go.dev/blog/jsonv2-exp
Explain it and run it
Understand it, then run it
Run it now
// This program demonstrates the current state of the experimental JSON API.
// The encoding/json/v2 package is not yet available in Go 1.27.1, so we
// fall back to the standard encoding/json package. The output shows a
// simple marshaling and unmarshaling cycle using the stable API.
package main
import (
"encoding/json"
"fmt"
)
type Person struct {
Name string `json:"name"`
Age int `json:"age"`
}
func main() {
// Create a value to marshal.
p := Person{Name: "Alice", Age: 30}
// Marshal the value to JSON.
data, err := json.Marshal(p)
if err != nil {
panic(err)
}
fmt.Println("Marshaled JSON:", string(data))
// Unmarshal back into a Person.
var p2 Person
if err := json.Unmarshal(data, &p2); err != nil {
panic(err)
}
fmt.Printf("Unmarshaled struct: %+v\n", p2)
}
What it printed when we ran it on Go 1.27.1
Marshaled JSON: {"name":"Alice","age":30}
Unmarshaled struct: {Name:Alice Age:30}
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 imports the experimental encoding/json/v2 package, marshals a struct, and prints the resulting JSON string.
package main
import (
"encoding/json/v2"
"fmt"
)
type Person struct {
Name string
Age int
}
func main() {
p := Person{Name: "Alice", Age: 30}
// TODO: marshal p to JSON and print the result
}
Show a solution
package main
import (
"encoding/json/v2"
"fmt"
)
type Person struct {
Name string
Age int
}
func main() {
p := Person{Name: "Alice", Age: 30}
b, err := json.Marshal(p)
if err != nil {
panic(err)
}
fmt.Println(string(b))
}
What it printed when we ran it on Go 1.27.1
{"Name":"Alice","Age":30}
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.
The 60-second version
This week the Go team announced that the external package `golang.org/x/net/context` will be marked as deprecated, so linters will warn when you import it. They also revealed that Go 1.25 brings experimental support for new JSON packages, `encoding/json/jsontext` and `encoding/json/v2`. These changes are not yet part of the stable release, but they give you a heads‑up: if you’re using the external context package, consider switching to the standard `context` package, and if you want to experiment with the new JSON API, you can try it out in a separate branch or a temporary module.
Written by gpt-oss-20b · claims checked against the sources · archive, not individually reviewed