You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
datastore: modernize codebase using Go 1.21–1.26 standard library idioms #20666
Now that cloud.google.com/go/datastore targets Go 1.26+, several legacy patterns across the module can be updated to use modern Go 1.21–1.26 standard library APIs for cleaner code and fewer heap allocations.
Replace reflect.TypeOf(...) initializers in load.go, prop.go, and tests with reflect.TypeFor[T]() (Go 1.22).
Replace for i := 0; i < t.NumField(); i++ in prop.go (validateChildType) with for f := range t.Fields() (Go 1.26).
Replace for _, s := range strings.Split(name, ".") in prop.go (validPropertyName) with zero-allocation strings.SplitSeq(name, ".") (Go 1.24).
Replace for i := 0; i < n; i++ loops in transaction.go and tests with for range n (Go 1.22), and use min built-in where applicable (Go 1.21).
Follow-up Hot-Path String & Slice Modernizations:
Replace bytes.Buffer with strings.Builder in Key.marshal / Key.string (key.go), which is called on every key during Client.GetMulti and Client.DeleteMulti deduplication, eliminating the extra []byte -> string copy allocation.
Replace append([]string(nil), fieldNames...) in Query.Project (query.go) with slices.Clone.
Activity
chore(datastore): modernize code using Go 1.21-1.26 stdlib idioms (#2…
perf(datastore): use strings.Builder in Key.string and slices.Clone i…