Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

all: rename interface{} to any #3515

Merged
merged 1 commit into from
Dec 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion aws/aws.go
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ func V2ConfigFromURLParams(ctx context.Context, q url.Values) (awsv2.Config, err
}
if endpoint != "" {
customResolver := awsv2.EndpointResolverWithOptionsFunc(
func(service, region string, options ...interface{}) (awsv2.Endpoint, error) {
func(service, region string, options ...any) (awsv2.Endpoint, error) {
return awsv2.Endpoint{
PartitionID: "aws",
URL: endpoint,
Expand Down
22 changes: 11 additions & 11 deletions blob/azureblob/azureblob.go
Original file line number Diff line number Diff line change
Expand Up @@ -468,7 +468,7 @@
srcBlobClient := b.client.NewBlobClient(srcKey)
copyOptions := &azblobblob.StartCopyFromURLOptions{}
if opts.BeforeCopy != nil {
asFunc := func(i interface{}) bool {
asFunc := func(i any) bool {
switch v := i.(type) {
case **azblobblob.StartCopyFromURLOptions:
*v = copyOptions
Expand Down Expand Up @@ -533,7 +533,7 @@
return &r.attrs
}

func (r *reader) As(i interface{}) bool {
func (r *reader) As(i any) bool {
p, ok := i.(*azblobblob.DownloadStreamResponse)
if !ok {
return false
Expand All @@ -554,7 +554,7 @@
downloadOpts.Range.Count = length
}
if opts.BeforeRead != nil {
asFunc := func(i interface{}) bool {
asFunc := func(i any) bool {
if p, ok := i.(**azblobblob.DownloadStreamOptions); ok {
*p = &downloadOpts
return true
Expand Down Expand Up @@ -608,7 +608,7 @@
}

// As implements driver.As.
func (b *bucket) As(i interface{}) bool {
func (b *bucket) As(i any) bool {
p, ok := i.(**container.Client)
if !ok {
return false
Expand All @@ -618,7 +618,7 @@
}

// As implements driver.ErrorAs.
func (b *bucket) ErrorAs(err error, i interface{}) bool {
func (b *bucket) ErrorAs(err error, i any) bool {

Check warning on line 621 in blob/azureblob/azureblob.go

View check run for this annotation

Codecov / codecov/patch

blob/azureblob/azureblob.go#L621

Added line #L621 was not covered by tests
switch v := err.(type) {
case *azcore.ResponseError:
if p, ok := i.(**azcore.ResponseError); ok {
Expand Down Expand Up @@ -687,7 +687,7 @@
MD5: blobPropertiesResponse.ContentMD5,
ETag: eTag,
Metadata: md,
AsFunc: func(i interface{}) bool {
AsFunc: func(i any) bool {
p, ok := i.(*azblobblob.GetPropertiesResponse)
if !ok {
return false
Expand Down Expand Up @@ -719,7 +719,7 @@
Marker: marker,
}
if opts.BeforeList != nil {
asFunc := func(i interface{}) bool {
asFunc := func(i any) bool {
p, ok := i.(**container.ListBlobsHierarchyOptions)
if !ok {
return false
Expand All @@ -745,7 +745,7 @@
Key: unescapeKey(to.String(blobPrefix.Name)),
Size: 0,
IsDir: true,
AsFunc: func(i interface{}) bool {
AsFunc: func(i any) bool {
v, ok := i.(*container.BlobPrefix)
if ok {
*v = *blobPrefix
Expand All @@ -762,7 +762,7 @@
Size: *blobInfo.Properties.ContentLength,
MD5: blobInfo.Properties.ContentMD5,
IsDir: false,
AsFunc: func(i interface{}) bool {
AsFunc: func(i any) bool {
v, ok := i.(*container.BlobItem)
if ok {
*v = *blobInfo
Expand Down Expand Up @@ -804,7 +804,7 @@
}

if opts.BeforeSign != nil {
asFunc := func(i interface{}) bool {
asFunc := func(i any) bool {
v, ok := i.(**sas.BlobPermissions)
if ok {
*v = &perms
Expand Down Expand Up @@ -914,7 +914,7 @@
},
}
if opts.BeforeWrite != nil {
asFunc := func(i interface{}) bool {
asFunc := func(i any) bool {
p, ok := i.(**azblob.UploadStreamOptions)
if !ok {
return false
Expand Down
10 changes: 5 additions & 5 deletions blob/azureblob/azureblob_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -184,15 +184,15 @@ func (verifyContentLanguage) ErrorCheck(b *blob.Bucket, err error) error {
return nil
}

func (verifyContentLanguage) BeforeRead(as func(interface{}) bool) error {
func (verifyContentLanguage) BeforeRead(as func(any) bool) error {
var u *azblob.DownloadStreamOptions
if !as(&u) {
return fmt.Errorf("BeforeRead As failed to get %T", u)
}
return nil
}

func (verifyContentLanguage) BeforeWrite(as func(interface{}) bool) error {
func (verifyContentLanguage) BeforeWrite(as func(any) bool) error {
var azOpts *azblob.UploadStreamOptions
if !as(&azOpts) {
return errors.New("Writer.As failed")
Expand All @@ -201,23 +201,23 @@ func (verifyContentLanguage) BeforeWrite(as func(interface{}) bool) error {
return nil
}

func (verifyContentLanguage) BeforeCopy(as func(interface{}) bool) error {
func (verifyContentLanguage) BeforeCopy(as func(any) bool) error {
var co *azblobblob.StartCopyFromURLOptions
if !as(&co) {
return errors.New("BeforeCopy.As failed")
}
return nil
}

func (verifyContentLanguage) BeforeList(as func(interface{}) bool) error {
func (verifyContentLanguage) BeforeList(as func(any) bool) error {
var azOpts *container.ListBlobsHierarchyOptions
if !as(&azOpts) {
return errors.New("BeforeList.As failed")
}
return nil
}

func (verifyContentLanguage) BeforeSign(as func(interface{}) bool) error {
func (verifyContentLanguage) BeforeSign(as func(any) bool) error {
var azOpts *sas.BlobPermissions
if !as(&azOpts) {
return errors.New("BeforeSign.As failed")
Expand Down
24 changes: 12 additions & 12 deletions blob/blob.go
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ func (r *Reader) Size() int64 {
// See https://gocloud.dev/concepts/as/ for background information, the "As"
// examples in this package for examples, and the driver package
// documentation for the specific types supported for that driver.
func (r *Reader) As(i interface{}) bool {
func (r *Reader) As(i any) bool {
return r.r.As(i)
}

Expand Down Expand Up @@ -339,14 +339,14 @@ type Attributes struct {
// ETag for the blob; see https://en.wikipedia.org/wiki/HTTP_ETag.
ETag string

asFunc func(interface{}) bool
asFunc func(any) bool
}

// As converts i to driver-specific types.
// See https://gocloud.dev/concepts/as/ for background information, the "As"
// examples in this package for examples, and the driver package
// documentation for the specific types supported for that driver.
func (a *Attributes) As(i interface{}) bool {
func (a *Attributes) As(i any) bool {
if a.asFunc == nil {
return false
}
Expand Down Expand Up @@ -556,7 +556,7 @@ type ListOptions struct {
// the underlying service's list functionality.
// asFunc converts its argument to driver-specific types.
// See https://gocloud.dev/concepts/as/ for background information.
BeforeList func(asFunc func(interface{}) bool) error
BeforeList func(asFunc func(any) bool) error
}

// ListIterator iterates over List results.
Expand Down Expand Up @@ -623,14 +623,14 @@ type ListObject struct {
// Fields other than Key and IsDir will not be set if IsDir is true.
IsDir bool

asFunc func(interface{}) bool
asFunc func(any) bool
}

// As converts i to driver-specific types.
// See https://gocloud.dev/concepts/as/ for background information, the "As"
// examples in this package for examples, and the driver package
// documentation for the specific types supported for that driver.
func (o *ListObject) As(i interface{}) bool {
func (o *ListObject) As(i any) bool {
if o.asFunc == nil {
return false
}
Expand Down Expand Up @@ -707,7 +707,7 @@ func newBucket(b driver.Bucket) *Bucket {
// See https://gocloud.dev/concepts/as/ for background information, the "As"
// examples in this package for examples, and the driver package
// documentation for the specific types supported for that driver.
func (b *Bucket) As(i interface{}) bool {
func (b *Bucket) As(i any) bool {
if i == nil {
return false
}
Expand All @@ -718,7 +718,7 @@ func (b *Bucket) As(i interface{}) bool {
// ErrorAs panics if i is nil or not a pointer.
// ErrorAs returns false if err == nil.
// See https://gocloud.dev/concepts/as/ for background information.
func (b *Bucket) ErrorAs(err error, i interface{}) bool {
func (b *Bucket) ErrorAs(err error, i any) bool {
return gcerr.ErrorAs(err, i, b.b.ErrorAs)
}

Expand Down Expand Up @@ -1330,7 +1330,7 @@ type SignedURLOptions struct {
// the underlying service's sign functionality.
// asFunc converts its argument to driver-specific types.
// See https://gocloud.dev/concepts/as/ for background information.
BeforeSign func(asFunc func(interface{}) bool) error
BeforeSign func(asFunc func(any) bool) error
}

// ReaderOptions sets options for NewReader and NewRangeReader.
Expand All @@ -1344,7 +1344,7 @@ type ReaderOptions struct {
//
// asFunc converts its argument to driver-specific types.
// See https://gocloud.dev/concepts/as/ for background information.
BeforeRead func(asFunc func(interface{}) bool) error
BeforeRead func(asFunc func(any) bool) error
}

// WriterOptions sets options for NewWriter.
Expand Down Expand Up @@ -1421,7 +1421,7 @@ type WriterOptions struct {
//
// asFunc converts its argument to driver-specific types.
// See https://gocloud.dev/concepts/as/ for background information.
BeforeWrite func(asFunc func(interface{}) bool) error
BeforeWrite func(asFunc func(any) bool) error
}

// CopyOptions sets options for Copy.
Expand All @@ -1431,7 +1431,7 @@ type CopyOptions struct {
//
// asFunc converts its argument to driver-specific types.
// See https://gocloud.dev/concepts/as/ for background information.
BeforeCopy func(asFunc func(interface{}) bool) error
BeforeCopy func(asFunc func(any) bool) error
}

// BucketURLOpener represents types that can open buckets based on a URL.
Expand Down
6 changes: 3 additions & 3 deletions blob/blob_fs.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
func (f *iofsFileInfo) Mode() fs.FileMode { return fs.ModeIrregular }
func (f *iofsFileInfo) ModTime() time.Time { return f.lo.ModTime }
func (f *iofsFileInfo) IsDir() bool { return false }
func (f *iofsFileInfo) Sys() interface{} { return f.lo }
func (f *iofsFileInfo) Sys() any { return f.lo }

Check warning on line 47 in blob/blob_fs.go

View check run for this annotation

Codecov / codecov/patch

blob/blob_fs.go#L47

Added line #L47 was not covered by tests
func (f *iofsFileInfo) Info() (fs.FileInfo, error) { return f, nil }
func (f *iofsFileInfo) Type() fs.FileMode { return fs.ModeIrregular }

Expand All @@ -58,7 +58,7 @@
func (f *iofsOpenFile) Name() string { return f.name }
func (f *iofsOpenFile) Mode() fs.FileMode { return fs.ModeIrregular }
func (f *iofsOpenFile) IsDir() bool { return false }
func (f *iofsOpenFile) Sys() interface{} { return f.r }
func (f *iofsOpenFile) Sys() any { return f.r }

Check warning on line 61 in blob/blob_fs.go

View check run for this annotation

Codecov / codecov/patch

blob/blob_fs.go#L61

Added line #L61 was not covered by tests
func (f *iofsOpenFile) Stat() (fs.FileInfo, error) { return f, nil }

// iofsDir describes a single directory in an io/fs.FS.
Expand All @@ -83,7 +83,7 @@
func (d *iofsDir) Type() fs.FileMode { return fs.ModeDir }
func (d *iofsDir) ModTime() time.Time { return time.Time{} }
func (d *iofsDir) IsDir() bool { return true }
func (d *iofsDir) Sys() interface{} { return d }
func (d *iofsDir) Sys() any { return d }

Check warning on line 86 in blob/blob_fs.go

View check run for this annotation

Codecov / codecov/patch

blob/blob_fs.go#L86

Added line #L86 was not covered by tests
func (d *iofsDir) Info() (fs.FileInfo, error) { return d, nil }
func (d *iofsDir) Stat() (fs.FileInfo, error) { return d, nil }
func (d *iofsDir) Read([]byte) (int, error) {
Expand Down
28 changes: 14 additions & 14 deletions blob/driver/driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
// which case it should not be called at all.
// asFunc allows drivers to expose driver-specific types;
// see Bucket.As for more details.
BeforeRead func(asFunc func(interface{}) bool) error
BeforeRead func(asFunc func(any) bool) error
}

// Reader reads an object from the blob.
Expand All @@ -47,7 +47,7 @@

// As allows drivers to expose driver-specific types;
// see Bucket.As for more details.
As(interface{}) bool
As(any) bool
}

// Downloader has an optional extra method for readers.
Expand Down Expand Up @@ -109,15 +109,15 @@
// which case it should not be called.
// asFunc allows drivers to expose driver-specific types;
// see Bucket.As for more details.
BeforeWrite func(asFunc func(interface{}) bool) error
BeforeWrite func(asFunc func(any) bool) error
}

// CopyOptions controls options for Copy.
type CopyOptions struct {
// BeforeCopy is a callback that must be called before initiating the Copy.
// asFunc allows drivers to expose driver-specific types;
// see Bucket.As for more details.
BeforeCopy func(asFunc func(interface{}) bool) error
BeforeCopy func(asFunc func(any) bool) error
}

// ReaderAttributes contains a subset of attributes about a blob that are
Expand Down Expand Up @@ -171,7 +171,7 @@
// AsFunc allows drivers to expose driver-specific types;
// see Bucket.As for more details.
// If not set, no driver-specific types are supported.
AsFunc func(interface{}) bool
AsFunc func(any) bool
}

// ListOptions sets options for listing objects in the bucket.
Expand Down Expand Up @@ -202,7 +202,7 @@
// before the underlying service's list is executed.
// asFunc allows drivers to expose driver-specific types;
// see Bucket.As for more details.
BeforeList func(asFunc func(interface{}) bool) error
BeforeList func(asFunc func(any) bool) error
}

// ListObject represents a specific blob object returned from ListPaged.
Expand All @@ -223,7 +223,7 @@
// AsFunc allows drivers to expose driver-specific types;
// see Bucket.As for more details.
// If not set, no driver-specific types are supported.
AsFunc func(interface{}) bool
AsFunc func(any) bool
}

// ListPage represents a page of results return from ListPaged.
Expand Down Expand Up @@ -252,12 +252,12 @@

// As converts i to driver-specific types.
// See https://gocloud.dev/concepts/as/ for background information.
As(i interface{}) bool
As(i any) bool

// ErrorAs allows drivers to expose driver-specific types for returned
// errors.
// See https://gocloud.dev/concepts/as/ for background information.
ErrorAs(error, interface{}) bool
ErrorAs(error, any) bool

// Attributes returns attributes for the blob. If the specified object does
// not exist, Attributes must return an error for which ErrorCode returns
Expand Down Expand Up @@ -368,7 +368,7 @@
// the underlying service's sign functionality.
// asFunc converts its argument to driver-specific types.
// See https://gocloud.dev/concepts/as/ for background information.
BeforeSign func(asFunc func(interface{}) bool) error
BeforeSign func(asFunc func(any) bool) error
}

// prefixedBucket implements Bucket by prepending prefix to all keys.
Expand All @@ -384,8 +384,8 @@
}

func (b *prefixedBucket) ErrorCode(err error) gcerrors.ErrorCode { return b.base.ErrorCode(err) }
func (b *prefixedBucket) As(i interface{}) bool { return b.base.As(i) }
func (b *prefixedBucket) ErrorAs(err error, i interface{}) bool { return b.base.ErrorAs(err, i) }
func (b *prefixedBucket) As(i any) bool { return b.base.As(i) }
func (b *prefixedBucket) ErrorAs(err error, i any) bool { return b.base.ErrorAs(err, i) }
func (b *prefixedBucket) Attributes(ctx context.Context, key string) (*Attributes, error) {
return b.base.Attributes(ctx, b.prefix+key)
}
Expand Down Expand Up @@ -442,8 +442,8 @@
}

func (b *singleKeyBucket) ErrorCode(err error) gcerrors.ErrorCode { return b.base.ErrorCode(err) }
func (b *singleKeyBucket) As(i interface{}) bool { return b.base.As(i) }
func (b *singleKeyBucket) ErrorAs(err error, i interface{}) bool { return b.base.ErrorAs(err, i) }
func (b *singleKeyBucket) As(i any) bool { return b.base.As(i) }
func (b *singleKeyBucket) ErrorAs(err error, i any) bool { return b.base.ErrorAs(err, i) }

Check warning on line 446 in blob/driver/driver.go

View check run for this annotation

Codecov / codecov/patch

blob/driver/driver.go#L445-L446

Added lines #L445 - L446 were not covered by tests
func (b *singleKeyBucket) Attributes(ctx context.Context, _ string) (*Attributes, error) {
return b.base.Attributes(ctx, b.key)
}
Expand Down
Loading
Loading