Skip to content

feat(binding/go): Add ListOptions with recursive support#7605

Open
FrankYang0529 wants to merge 4 commits into
apache:mainfrom
FrankYang0529:opendal-7604
Open

feat(binding/go): Add ListOptions with recursive support#7605
FrankYang0529 wants to merge 4 commits into
apache:mainfrom
FrankYang0529:opendal-7604

Conversation

@FrankYang0529
Copy link
Copy Markdown
Member

Which issue does this PR close?

Closes #7604

Rationale for this change

The Go binding's op.List(path) had no way to perform a recursive listing. Users who needed to enumerate all objects under a prefix recursively had to implement their own traversal.

What changes are included in this PR?

Add golang binding ListWith and ListOptions.

Are there any user-facing changes?

Users can now perform recursive listings via:

opts := opendal.ListOptions{}.WithRecursive(true)
lister, err := op.ListWith("path/to/prefix/", opts)

The existing op.List(path) API is unchanged.

AI Usage Statement

This PR was developed with the assistance of OpenCode using the claude-sonnet-4.6 model.

@dosubot dosubot Bot added size:L This PR changes 100-499 lines, ignoring generated files. releases-note/feat The PR implements a new feature or has a title that begins with "feat" labels May 23, 2026
* @see opendal_list_options_set_recursive
*/
typedef struct opendal_list_options {
/**
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There're a few list options in opendal core, I'm wondering why don't expose them all?
https://opendal.incubator.apache.org/docs/rust/opendal/options/struct.ListOptions.html

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would prefer to do each function in separate PR. WDYT?

Comment thread bindings/c/include/opendal.h Outdated
Comment thread bindings/c/tests/test_suites_list.cpp Outdated
Comment thread bindings/go/lister.go Outdated
Comment thread bindings/go/types.go Outdated
Copy link
Copy Markdown
Member

@dentiny dentiny left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@yuchanns
Copy link
Copy Markdown
Member

Can we use options pattern here? So List and ListWith can be merged.

func List(path string, opts ...WithListFn)

Sorry for inaccurate description. Sent by my phone.

Signed-off-by: PoAn Yang <payang@apache.org>
Signed-off-by: PoAn Yang <payang@apache.org>
Signed-off-by: PoAn Yang <payang@apache.org>
Signed-off-by: PoAn Yang <payang@apache.org>
Comment thread bindings/go/lister.go
// WithRecursive sets the recursive flag for the list operation.
//
// When recursive is true, the list operation will descend into sub-directories.
func WithRecursive(recursive bool) WithListFn {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd prefer ListWithRecursive here.

Comment thread bindings/go/lister.go
}

func (o *listOptions) toInner() opendalListOptions {
return opendalListOptions{recursive: o.recursive}
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we use opendal_list_options_set_recursive here instead of constructing opendalListOptions directly?

I'm afraid mirroring the C struct layout in Go could introduce potential memory/layout risks if opendal_list_options changes later. IMO using the C setter opendal_list_options_set_recursive would keep the ownership and initialization details on the C side.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

releases-note/feat The PR implements a new feature or has a title that begins with "feat" size:L This PR changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

new feature: Add ListOptions with recursive support for Go binding

3 participants