
Warm-up Time
🟥 SECURITY · Go team · 10 November 2026
Go 1.27.4 and 1.26.11 are out, with 12 security fixes. Some affect the build itself: malicious dependencies could pass dangerous instructions to native build tools. Another fixes an HTTP/1 crash when a handler reads a limited request body while writing response headers concurrently. Update the Go version in CI as well as on your machine, check any cgo flags the new version rejects, and rebuild the binaries you deploy.
🟦 PERFORMANCE · Internals for Interns · 9 November 2026
A CPU profile tells you where your program spends time. Go's compiler can use it too. This walkthrough follows a frequently called interface method as the compiler adds a direct-call fast path. Knowing the target can then allow inlining, which puts the function's code directly in its caller. The examples use Go 1.27.3 on amd64; trying this on your own service needs a profile that represents its normal traffic.
🟦 BENCHMARK · huseyinbabal.dev · 9 November 2026
Switching an endpoint from Go 1.27's v1 API to v2's MarshalWrite reduced read throughput by about 30% in this test. The investigation found many small writes where the v1 encoder had made one large write. The author traced the extra work through the HTTP response path. This was one CPU-bound endpoint returning 100 objects on two vCPUs, with three 30-second runs per build. It doesn't show that v2 is generally slower, or that buffering would recover the slowdown.
🟦 PROFILING · Gopheria · 1 November 2026 · Catch-up
The small program in this post allocates hundreds of megabytes, then drops almost all of it. Its live heap is so small that runtime bookkeeping dominates the profile. Looking at alloc_space reveals the allocation churn; inuse_space shows what remains allocated. The two example programs help you tell those questions apart, including why a tiny live heap can give you a noisy sampled profile.

Tool Time
🟩 RELEASE · go-yaml · 4 November 2026
You can keep using Marshal and Unmarshal after upgrading to go-yaml v4. The new Load and Dump APIs expose options such as strict field checking, so you can try those changes separately. One place that does need attention is custom UnmarshalYAML hooks: they must use the v4 node type. Versions 2 and 3 now receive security fixes only.
🟥 SECURITY + RELEASE · pgx · 30 October 2026 · Catch-up
pgx 5.12 fixes two security issues. One involves SQL batches in the non-default simple protocol, where a trailing SQL comment can change how the next statement is interpreted. The other closes a way for a rogue server to bypass required authentication checks; verifying the server with sslmode=verify-full limits that attack. The linked advisories explain the affected versions and conditions. There's also Batch.BeginTx, which lets the transaction start travel with the queued queries.
Community watch
🟪 EXPERIMENT · Jonathan Amsterdam · 12 November 2026
If you've been writing your own sets, there are now some experimental Go collections to try. golang.org/x/exp/collection includes sets, custom-hash maps and sets, and sorted maps and sets. The team wants feedback on missing or awkward operations while it can still change the APIs. These are explicitly not ready for production. Getting them into the standard library in Go 1.29 is a hope, not a commitment.
Deep Dive
Go JSON v2: why a nil slice becomes [] instead of null
Go's new JSON package can change an API response without changing the Go value behind it. We follow one tags field to explain why nil slices become empty arrays, when that helps, and when an existing client still needs null.
If you're trying JSON v2, reply and tell me what broke or needed changing.
Thanks for reading,
Moein
Go JSON v2: why a nil slice becomes [] instead of null
Go has a new standard-library JSON package, encoding/json/v2, now stable in Go 1.27. Like encoding/json, it converts Go values into JSON and reads JSON back into Go values. If your service returns a struct from an HTTP endpoint, this is the code that decides what your client receives.
The new package changes some of those decisions. The old API had accumulated behavior and performance problems that could not simply be fixed without breaking existing programs. A separate package lets Go introduce different defaults while keeping the original API available.
Upgrading Go does not opt your code into those defaults. Calls through encoding/json keep their existing marshaling behavior. The change matters when you start using encoding/json/v2; migration is optional.
Let’s follow one of its changes through an API: what happens when a response contains a list with no items?
The same Go response, different JSON
Suppose an endpoint returns an article’s tags. We represent them as a slice:
type Response struct {
Tags []string `json:"tags"`
}If we create Response{} without assigning Tags, the slice is nil. That is its zero value in Go, and it already works as an empty collection: its length is zero, and ranging over it visits no elements. We can also write []string{} to create a non-nil empty slice. Both contain no tags, but only the first passes a Tags == nil check.
The JSON package has to choose how to represent that difference. This complete example uses both APIs on the same response:
package main
import (
jsonv1 "encoding/json"
jsonv2 "encoding/json/v2"
"fmt"
)
type Response struct {
Tags []string `json:"tags"`
}
func main() {
reply := Response{}
oldJSON, err := jsonv1.Marshal(reply)
if err != nil {
panic(err)
}
newJSON, err := jsonv2.Marshal(reply)
if err != nil {
panic(err)
}
fmt.Println(string(oldJSON)) // {"tags":null}
fmt.Println(string(newJSON)) // {"tags":[]}
}The struct and its value are unchanged. V1 writes a nil slice as null; v2 writes it as an empty JSON array, []. For a non-nil empty slice, both already write []. These are the default rules, with no omission tags or custom marshaling methods involved. The example was checked on Go 1.27.4.
Why choose an empty array?
Our client receives JSON, not a Go slice. If the endpoint promises that tags is an array, [] is an array containing no items. null is a different JSON value. A client that requires an array can reject it.
This was a reported problem with the original package: an API contract required an empty array, but leaving a slice unset produced null. The Go team’s design explanation identifies this interoperability problem as a reason for the new default. V2 makes both ways of representing an empty Go slice produce the same JSON array.
That is helpful when “no tags” is the only state your API needs. But an existing API might deliberately use null for “tags have not loaded” and [] for “loaded, with no tags.” Those meanings come from that API’s contract. Switching packages would make the client see “loaded” in both cases, even though the service’s business logic did not change.
Where does null disappear in a round trip?
Now suppose the service receives {"tags":null}, reads it into a fresh Response, then sends that response onwards. With v2, the sequence is:
Step | Result |
|---|---|
Receive JSON |
|
Unmarshal into |
|
Marshal with v2 defaults |
|
Unmarshal still turns JSON null into a nil slice. The change happens when Marshal converts that Go value back into JSON. Reading JSON and writing it again does not guarantee the same representation.
If another Go service reads the resulting [], it gets a non-nil empty slice. A nil check there now gives a different answer from a nil check before the round trip. A length check gives zero in both places. Use the length when you only care whether there are items; use a representation that preserves the distinction when nil carries meaning in your application.
Keeping an existing API’s behavior
If your client needs null for a nil slice, tell v2 to preserve it at the point where you write the response. In the program above, replace the second Marshal call with this, keeping its error check and print statements:
newJSON, err := jsonv2.Marshal(
reply,
jsonv2.FormatNilSliceAsNull(true),
)The program now prints {"tags":null} twice. A non-nil empty slice still produces {"tags":[]}. FormatNilSliceAsNull affects marshaling for the call; it does not change unmarshaling or restore every v1 behavior. Apply it before the distinction is lost. Once another service has received [], the option cannot tell whether that array began as a nil slice.
Before switching an endpoint to v2, check what its callers expect for nil, an empty slice and a populated slice. Assert the JSON response as well as the Go value. Checking only the slice’s length would miss the change your client sees.

