mirror of
https://github.com/rclone/rclone.git
synced 2024-11-22 11:21:10 +08:00
build: fix linting issues reported by running golangci-lint with different GOOS
This commit is contained in:
parent
159e274921
commit
7ee22fcdf9
|
@ -3,4 +3,5 @@
|
||||||
|
|
||||||
//go:build plan9 || solaris || js
|
//go:build plan9 || solaris || js
|
||||||
|
|
||||||
|
// Package azureblob provides an interface to the Microsoft Azure blob object storage system
|
||||||
package azureblob
|
package azureblob
|
||||||
|
|
|
@ -3,4 +3,5 @@
|
||||||
|
|
||||||
//go:build plan9 || js
|
//go:build plan9 || js
|
||||||
|
|
||||||
|
// Package azurefiles provides an interface to Microsoft Azure Files
|
||||||
package azurefiles
|
package azurefiles
|
||||||
|
|
1
backend/cache/cache_unsupported.go
vendored
1
backend/cache/cache_unsupported.go
vendored
|
@ -3,4 +3,5 @@
|
||||||
|
|
||||||
//go:build plan9 || js
|
//go:build plan9 || js
|
||||||
|
|
||||||
|
// Package cache implements a virtual provider to cache existing remotes.
|
||||||
package cache
|
package cache
|
||||||
|
|
3
backend/cache/utils_test.go
vendored
3
backend/cache/utils_test.go
vendored
|
@ -1,3 +1,6 @@
|
||||||
|
//go:build !plan9 && !js
|
||||||
|
// +build !plan9,!js
|
||||||
|
|
||||||
package cache
|
package cache
|
||||||
|
|
||||||
import bolt "go.etcd.io/bbolt"
|
import bolt "go.etcd.io/bbolt"
|
||||||
|
|
|
@ -3,4 +3,5 @@
|
||||||
|
|
||||||
//go:build plan9
|
//go:build plan9
|
||||||
|
|
||||||
|
// Package hdfs provides an interface to the HDFS storage system.
|
||||||
package hdfs
|
package hdfs
|
||||||
|
|
|
@ -23,9 +23,9 @@ func (f *Fs) About(ctx context.Context) (*fs.Usage, error) {
|
||||||
}
|
}
|
||||||
bs := int64(s.Bsize) // nolint: unconvert
|
bs := int64(s.Bsize) // nolint: unconvert
|
||||||
usage := &fs.Usage{
|
usage := &fs.Usage{
|
||||||
Total: fs.NewUsageValue(bs * int64(s.Blocks)), // quota of bytes that can be used
|
Total: fs.NewUsageValue(bs * int64(s.Blocks)), //nolint: unconvert // quota of bytes that can be used
|
||||||
Used: fs.NewUsageValue(bs * int64(s.Blocks-s.Bfree)), // bytes in use
|
Used: fs.NewUsageValue(bs * int64(s.Blocks-s.Bfree)), //nolint: unconvert // bytes in use
|
||||||
Free: fs.NewUsageValue(bs * int64(s.Bavail)), // bytes which can be uploaded before reaching the quota
|
Free: fs.NewUsageValue(bs * int64(s.Bavail)), //nolint: unconvert // bytes which can be uploaded before reaching the quota
|
||||||
}
|
}
|
||||||
return usage, nil
|
return usage, nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
//go:build plan9 || js
|
//go:build dragonfly || plan9 || js
|
||||||
|
|
||||||
package local
|
package local
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
|
// The pkg/xattr module doesn't compile for openbsd or plan9
|
||||||
|
|
||||||
//go:build openbsd || plan9
|
//go:build openbsd || plan9
|
||||||
|
|
||||||
// The pkg/xattr module doesn't compile for openbsd or plan9
|
|
||||||
package local
|
package local
|
||||||
|
|
||||||
import "github.com/rclone/rclone/fs"
|
import "github.com/rclone/rclone/fs"
|
||||||
|
|
|
@ -3,4 +3,5 @@
|
||||||
|
|
||||||
//go:build plan9 || solaris || js
|
//go:build plan9 || solaris || js
|
||||||
|
|
||||||
|
// Package oracleobjectstorage provides an interface to the OCI object storage system.
|
||||||
package oracleobjectstorage
|
package oracleobjectstorage
|
||||||
|
|
|
@ -3,4 +3,6 @@
|
||||||
|
|
||||||
//go:build plan9 || js
|
//go:build plan9 || js
|
||||||
|
|
||||||
|
// Package qingstor provides an interface to QingStor object storage
|
||||||
|
// Home: https://www.qingcloud.com/
|
||||||
package qingstor
|
package qingstor
|
||||||
|
|
|
@ -3,4 +3,5 @@
|
||||||
|
|
||||||
//go:build plan9
|
//go:build plan9
|
||||||
|
|
||||||
|
// Package sftp provides a filesystem interface using github.com/pkg/sftp
|
||||||
package sftp
|
package sftp
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
//go:build plan9
|
//go:build plan9
|
||||||
|
|
||||||
|
// Package storj provides an interface to Storj decentralized object storage.
|
||||||
package storj
|
package storj
|
||||||
|
|
|
@ -3,4 +3,5 @@
|
||||||
|
|
||||||
//go:build plan9 || js
|
//go:build plan9 || js
|
||||||
|
|
||||||
|
// Package cachestats provides the cachestats command.
|
||||||
package cachestats
|
package cachestats
|
||||||
|
|
|
@ -3,4 +3,5 @@
|
||||||
|
|
||||||
//go:build plan9 || js
|
//go:build plan9 || js
|
||||||
|
|
||||||
|
// Package ncdu implements a text based user interface for exploring a remote
|
||||||
package ncdu
|
package ncdu
|
||||||
|
|
|
@ -3,9 +3,10 @@
|
||||||
|
|
||||||
//go:build plan9
|
//go:build plan9
|
||||||
|
|
||||||
|
// Package ftp implements an FTP server for rclone
|
||||||
package ftp
|
package ftp
|
||||||
|
|
||||||
import "github.com/spf13/cobra"
|
import "github.com/spf13/cobra"
|
||||||
|
|
||||||
// Command definition is nil to show not implemented
|
// Command definition is nil to show not implemented
|
||||||
var Command *cobra.Command = nil
|
var Command *cobra.Command
|
||||||
|
|
|
@ -3,9 +3,10 @@
|
||||||
|
|
||||||
//go:build plan9
|
//go:build plan9
|
||||||
|
|
||||||
|
// Package sftp implements an SFTP server to serve an rclone VFS
|
||||||
package sftp
|
package sftp
|
||||||
|
|
||||||
import "github.com/spf13/cobra"
|
import "github.com/spf13/cobra"
|
||||||
|
|
||||||
// Command definition is nil to show not implemented
|
// Command definition is nil to show not implemented
|
||||||
var Command *cobra.Command = nil
|
var Command *cobra.Command
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
package fserrors
|
package fserrors
|
||||||
|
|
||||||
// IsErrNoSpace() on plan9 returns false because
|
// IsErrNoSpace on plan9 returns false because
|
||||||
// plan9 does not support syscall.ENOSPC error.
|
// plan9 does not support syscall.ENOSPC error.
|
||||||
func IsErrNoSpace(cause error) (isNoSpc bool) {
|
func IsErrNoSpace(cause error) (isNoSpc bool) {
|
||||||
isNoSpc = false
|
isNoSpc = false
|
||||||
|
|
74
fs/fserrors/error_syscall_test.go
Normal file
74
fs/fserrors/error_syscall_test.go
Normal file
|
@ -0,0 +1,74 @@
|
||||||
|
//go:build !plan9
|
||||||
|
// +build !plan9
|
||||||
|
|
||||||
|
package fserrors
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"net"
|
||||||
|
"net/url"
|
||||||
|
"os"
|
||||||
|
"syscall"
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
"github.com/stretchr/testify/assert"
|
||||||
|
)
|
||||||
|
|
||||||
|
// make a plausible network error with the underlying errno
|
||||||
|
func makeNetErr(errno syscall.Errno) error {
|
||||||
|
return &net.OpError{
|
||||||
|
Op: "write",
|
||||||
|
Net: "tcp",
|
||||||
|
Source: &net.TCPAddr{IP: net.ParseIP("127.0.0.1"), Port: 123},
|
||||||
|
Addr: &net.TCPAddr{IP: net.ParseIP("127.0.0.1"), Port: 8080},
|
||||||
|
Err: &os.SyscallError{
|
||||||
|
Syscall: "write",
|
||||||
|
Err: errno,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestWithSyscallCause(t *testing.T) {
|
||||||
|
for i, test := range []struct {
|
||||||
|
err error
|
||||||
|
wantRetriable bool
|
||||||
|
wantErr error
|
||||||
|
}{
|
||||||
|
{makeNetErr(syscall.EAGAIN), true, syscall.EAGAIN},
|
||||||
|
{makeNetErr(syscall.Errno(123123123)), false, syscall.Errno(123123123)},
|
||||||
|
} {
|
||||||
|
gotRetriable, gotErr := Cause(test.err)
|
||||||
|
what := fmt.Sprintf("test #%d: %v", i, test.err)
|
||||||
|
assert.Equal(t, test.wantErr, gotErr, what)
|
||||||
|
assert.Equal(t, test.wantRetriable, gotRetriable, what)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestWithSyscallShouldRetry(t *testing.T) {
|
||||||
|
for i, test := range []struct {
|
||||||
|
err error
|
||||||
|
want bool
|
||||||
|
}{
|
||||||
|
{makeNetErr(syscall.EAGAIN), true},
|
||||||
|
{makeNetErr(syscall.Errno(123123123)), false},
|
||||||
|
{
|
||||||
|
wrap(&url.Error{
|
||||||
|
Op: "post",
|
||||||
|
URL: "http://localhost/",
|
||||||
|
Err: makeNetErr(syscall.EPIPE),
|
||||||
|
}, "potato error"),
|
||||||
|
true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
wrap(&url.Error{
|
||||||
|
Op: "post",
|
||||||
|
URL: "http://localhost/",
|
||||||
|
Err: makeNetErr(syscall.Errno(123123123)),
|
||||||
|
}, "listing error"),
|
||||||
|
false,
|
||||||
|
},
|
||||||
|
} {
|
||||||
|
got := ShouldRetry(test.err)
|
||||||
|
assert.Equal(t, test.want, got, fmt.Sprintf("test #%d: %v", i, test.err))
|
||||||
|
}
|
||||||
|
}
|
|
@ -5,10 +5,7 @@ import (
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"net"
|
|
||||||
"net/url"
|
"net/url"
|
||||||
"os"
|
|
||||||
"syscall"
|
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
@ -41,20 +38,6 @@ func wrap(err error, message string) error {
|
||||||
|
|
||||||
var errUseOfClosedNetworkConnection = errors.New("use of closed network connection")
|
var errUseOfClosedNetworkConnection = errors.New("use of closed network connection")
|
||||||
|
|
||||||
// make a plausible network error with the underlying errno
|
|
||||||
func makeNetErr(errno syscall.Errno) error {
|
|
||||||
return &net.OpError{
|
|
||||||
Op: "write",
|
|
||||||
Net: "tcp",
|
|
||||||
Source: &net.TCPAddr{IP: net.ParseIP("127.0.0.1"), Port: 123},
|
|
||||||
Addr: &net.TCPAddr{IP: net.ParseIP("127.0.0.1"), Port: 8080},
|
|
||||||
Err: &os.SyscallError{
|
|
||||||
Syscall: "write",
|
|
||||||
Err: errno,
|
|
||||||
},
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
type myError1 struct {
|
type myError1 struct {
|
||||||
Err error
|
Err error
|
||||||
}
|
}
|
||||||
|
@ -121,8 +104,6 @@ func TestCause(t *testing.T) {
|
||||||
{fmt.Errorf("potato: %w", errPotato), false, errPotato},
|
{fmt.Errorf("potato: %w", errPotato), false, errPotato},
|
||||||
{fmt.Errorf("potato2: %w", wrap(errPotato, "potato")), false, errPotato},
|
{fmt.Errorf("potato2: %w", wrap(errPotato, "potato")), false, errPotato},
|
||||||
{errUseOfClosedNetworkConnection, false, errUseOfClosedNetworkConnection},
|
{errUseOfClosedNetworkConnection, false, errUseOfClosedNetworkConnection},
|
||||||
{makeNetErr(syscall.EAGAIN), true, syscall.EAGAIN},
|
|
||||||
{makeNetErr(syscall.Errno(123123123)), false, syscall.Errno(123123123)},
|
|
||||||
{eNil1, false, eNil1},
|
{eNil1, false, eNil1},
|
||||||
{eNil2, false, eNil2.Err},
|
{eNil2, false, eNil2.Err},
|
||||||
{myError1{io.EOF}, false, io.EOF},
|
{myError1{io.EOF}, false, io.EOF},
|
||||||
|
@ -151,27 +132,9 @@ func TestShouldRetry(t *testing.T) {
|
||||||
{fmt.Errorf("connection: %w", errUseOfClosedNetworkConnection), true},
|
{fmt.Errorf("connection: %w", errUseOfClosedNetworkConnection), true},
|
||||||
{io.EOF, true},
|
{io.EOF, true},
|
||||||
{io.ErrUnexpectedEOF, true},
|
{io.ErrUnexpectedEOF, true},
|
||||||
{makeNetErr(syscall.EAGAIN), true},
|
|
||||||
{makeNetErr(syscall.Errno(123123123)), false},
|
|
||||||
{&url.Error{Op: "post", URL: "/", Err: io.EOF}, true},
|
{&url.Error{Op: "post", URL: "/", Err: io.EOF}, true},
|
||||||
{&url.Error{Op: "post", URL: "/", Err: errUseOfClosedNetworkConnection}, true},
|
{&url.Error{Op: "post", URL: "/", Err: errUseOfClosedNetworkConnection}, true},
|
||||||
{&url.Error{Op: "post", URL: "/", Err: fmt.Errorf("net/http: HTTP/1.x transport connection broken: %v", fmt.Errorf("http: ContentLength=%d with Body length %d", 100663336, 99590598))}, true},
|
{&url.Error{Op: "post", URL: "/", Err: fmt.Errorf("net/http: HTTP/1.x transport connection broken: %v", fmt.Errorf("http: ContentLength=%d with Body length %d", 100663336, 99590598))}, true},
|
||||||
{
|
|
||||||
wrap(&url.Error{
|
|
||||||
Op: "post",
|
|
||||||
URL: "http://localhost/",
|
|
||||||
Err: makeNetErr(syscall.EPIPE),
|
|
||||||
}, "potato error"),
|
|
||||||
true,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
wrap(&url.Error{
|
|
||||||
Op: "post",
|
|
||||||
URL: "http://localhost/",
|
|
||||||
Err: makeNetErr(syscall.Errno(123123123)),
|
|
||||||
}, "listing error"),
|
|
||||||
false,
|
|
||||||
},
|
|
||||||
} {
|
} {
|
||||||
got := ShouldRetry(test.err)
|
got := ShouldRetry(test.err)
|
||||||
assert.Equal(t, test.want, got, fmt.Sprintf("test #%d: %v", i, test.err))
|
assert.Equal(t, test.want, got, fmt.Sprintf("test #%d: %v", i, test.err))
|
||||||
|
|
|
@ -1,3 +1,6 @@
|
||||||
|
//go:build !plan9
|
||||||
|
// +build !plan9
|
||||||
|
|
||||||
package logger_test
|
package logger_test
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
//go:build plan9 || js
|
//go:build plan9 || js
|
||||||
|
|
||||||
|
// Package kv provides key/value database.
|
||||||
package kv
|
package kv
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
|
20
vfs/vfstest/write_other.go
Normal file
20
vfs/vfstest/write_other.go
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
//go:build !linux && !darwin && !freebsd && !windows
|
||||||
|
// +build !linux,!darwin,!freebsd,!windows
|
||||||
|
|
||||||
|
package vfstest
|
||||||
|
|
||||||
|
import (
|
||||||
|
"errors"
|
||||||
|
"runtime"
|
||||||
|
"testing"
|
||||||
|
)
|
||||||
|
|
||||||
|
// TestWriteFileDoubleClose tests double close on write
|
||||||
|
func TestWriteFileDoubleClose(t *testing.T) {
|
||||||
|
t.Skip("not supported on " + runtime.GOOS)
|
||||||
|
}
|
||||||
|
|
||||||
|
// writeTestDup performs the platform-specific implementation of the dup() unix
|
||||||
|
func writeTestDup(oldfd uintptr) (uintptr, error) {
|
||||||
|
return 0, errors.New("not supported on " + runtime.GOOS)
|
||||||
|
}
|
|
@ -1,4 +1,4 @@
|
||||||
//go:build !linux && !darwin && !freebsd
|
//go:build windows
|
||||||
|
|
||||||
package vfstest
|
package vfstest
|
||||||
|
|
Loading…
Reference in New Issue
Block a user