How to wrap/extend a SDK

I am trying to make some simplified functions related to AWS services. Is this a good way to do things or not?

Based on the title of your post, I guess your question is about this approach to wrap s3iface.S3API:

type FFS3 struct {
	s3iface.S3API
}

// FetchAll retrieves all items from a bucket
func (ffs3 *FFS3) FetchAll(bucket, prefix, delimiter string) ([]*s3.Object, error) {

Basically I see no obvious issues. You only need to remember that the embedded field s3iface.S3API is an interface. It declares functions but implements none of them. Hence you have to ensure that something that implements S3API gets assigned to the field; otherwise, calls like ffs3.ListObjectsV2Pages() will panic at runtime.

1 Like

Yea, I mean embedding the interface and of course I did it intentionaly in order to make this code testable. Thank you for the review :blush:

1 Like