staticcheck: use result of type assertion to simplify cases

This commit is contained in:
albertony 2022-06-24 16:01:19 +02:00
parent 060c8dfff0
commit 0772cae314
3 changed files with 9 additions and 9 deletions

View File

@ -85,16 +85,16 @@ func (f *Fs) wrapEntries(entries ...upstream.Entry) (entry, error) {
if err != nil { if err != nil {
return nil, err return nil, err
} }
switch e.(type) { switch e := e.(type) {
case *upstream.Object: case *upstream.Object:
return &Object{ return &Object{
Object: e.(*upstream.Object), Object: e,
fs: f, fs: f,
co: entries, co: entries,
}, nil }, nil
case *upstream.Directory: case *upstream.Directory:
return &Directory{ return &Directory{
Directory: e.(*upstream.Directory), Directory: e,
cd: entries, cd: entries,
}, nil }, nil
default: default:

View File

@ -129,11 +129,11 @@ func (f *Fs) WrapObject(o fs.Object) *Object {
// WrapEntry wraps an fs.DirEntry to include the info // WrapEntry wraps an fs.DirEntry to include the info
// of the upstream Fs // of the upstream Fs
func (f *Fs) WrapEntry(e fs.DirEntry) (Entry, error) { func (f *Fs) WrapEntry(e fs.DirEntry) (Entry, error) {
switch e.(type) { switch e := e.(type) {
case fs.Object: case fs.Object:
return f.WrapObject(e.(fs.Object)), nil return f.WrapObject(e), nil
case fs.Directory: case fs.Directory:
return f.WrapDirectory(e.(fs.Directory)), nil return f.WrapDirectory(e), nil
default: default:
return nil, fmt.Errorf("unknown object type %T", e) return nil, fmt.Errorf("unknown object type %T", e)
} }

View File

@ -59,11 +59,11 @@ func (h *ReOpen) open() error {
var hashOption *fs.HashesOption var hashOption *fs.HashesOption
var rangeOption *fs.RangeOption var rangeOption *fs.RangeOption
for _, option := range h.options { for _, option := range h.options {
switch option.(type) { switch option := option.(type) {
case *fs.HashesOption: case *fs.HashesOption:
hashOption = option.(*fs.HashesOption) hashOption = option
case *fs.RangeOption: case *fs.RangeOption:
rangeOption = option.(*fs.RangeOption) rangeOption = option
case *fs.HTTPOption: case *fs.HTTPOption:
opts = append(opts, option) opts = append(opts, option)
default: default: