()
| 479 | } |
| 480 | |
| 481 | func ExampleListOptions() { |
| 482 | // This example is specific to the gcsblob implementation; it demonstrates |
| 483 | // access to the underlying cloud.google.com/go/storage.Query type. |
| 484 | // The types exposed for As by gcsblob are documented in |
| 485 | // https://godoc.org/gocloud.dev/blob/gcsblob#hdr-As |
| 486 | |
| 487 | ctx := context.Background() |
| 488 | |
| 489 | b, err := blob.OpenBucket(ctx, "gs://my-bucket") |
| 490 | if err != nil { |
| 491 | log.Fatal(err) |
| 492 | } |
| 493 | defer b.Close() |
| 494 | |
| 495 | beforeList := func(as func(any) bool) error { |
| 496 | // Access storage.Query via q here. |
| 497 | var q *storage.Query |
| 498 | if as(&q) { |
| 499 | _ = q.Delimiter |
| 500 | } |
| 501 | return nil |
| 502 | } |
| 503 | |
| 504 | iter := b.List(&blob.ListOptions{Prefix: "", Delimiter: "/", BeforeList: beforeList}) |
| 505 | for { |
| 506 | obj, err := iter.Next(ctx) |
| 507 | if err == io.EOF { |
| 508 | break |
| 509 | } |
| 510 | if err != nil { |
| 511 | log.Fatal(err) |
| 512 | } |
| 513 | _ = obj |
| 514 | } |
| 515 | } |
| 516 | |
| 517 | func ExamplePrefixedBucket() { |
| 518 | // PRAGMA: This example is used on gocloud.dev; PRAGMA comments adjust how it is shown and can be ignored. |
nothing calls this directly
no test coverage detected