Hedronite · Go Lesson · Polyglot-Dev / Go · Sun 2026-09-13
Go Cloud Storage BucketAttrs lifecycle and retention inventory — Attrs walk
Same three shelves. cloud.google.com/go/storage.
List
Buckets iterator.
Attrs
Class, lifecycle, retention.
Bound
No Bucket.Update.
Inventory reads. Update is another binary.
Same three shelves. cloud.google.com/go/storage.
§I — Frame
Mirror the Python inventory with Go. List buckets, call Bucket.Attrs, print storage class, lifecycle rules, retention, versioning. Do not update bucket attrs from this tool.
§II — Sketch
ctx := context.Background()
client, err := storage.NewClient(ctx)
if err != nil {
return err
}
defer client.Close()
it := client.Buckets(ctx, projectID)
for {
battrs, err := it.Next()
if err == iterator.Done {
break
}
if err != nil {
return err
}
// battrs.StorageClass
// battrs.VersioningEnabled
// battrs.RetentionPolicy (RetentionPeriod, IsLocked, EffectiveTime)
// battrs.Lifecycle.Rules — Action.Type, Action.StorageClass, Condition.AgeInDays
}
Use iterator.Done correctly. Treat permission errors per bucket as WARN rows when the caller asks for best-effort fleet scans.
§III — Boundaries
- No
Bucket.Updatefor lifecycle or retention from the inventory binary. - Project ID is required context; empty iteration is not org-wide truth.
- Align WARN strings with Ops/Dev so Maghrib can fold Go items into the Dev quiz (no Go
quiz.html).
§IV — Closing
Print class, rules, retention lock, versioning. Leave patching to a different program with a different review.
Related
- Ops
- Dev
- Cert