build: apply gofmt from go1.13 to change case of number literals

This commit is contained in:
Nick Craig-Wood 2019-09-05 13:59:06 +01:00
parent 7b0966880e
commit ffa1dac10b
16 changed files with 37 additions and 37 deletions

View File

@ -1115,7 +1115,7 @@ func (o *Object) parseTimeString(timeString string) (err error) {
fs.Debugf(o, "Failed to parse mod time string %q: %v", timeString, err) fs.Debugf(o, "Failed to parse mod time string %q: %v", timeString, err)
return err return err
} }
o.modTime = time.Unix(unixMilliseconds/1E3, (unixMilliseconds%1E3)*1E6).UTC() o.modTime = time.Unix(unixMilliseconds/1e3, (unixMilliseconds%1e3)*1e6).UTC()
return nil return nil
} }

View File

@ -50,7 +50,7 @@ type Timestamp time.Time
// MarshalJSON turns a Timestamp into JSON (in UTC) // MarshalJSON turns a Timestamp into JSON (in UTC)
func (t *Timestamp) MarshalJSON() (out []byte, err error) { func (t *Timestamp) MarshalJSON() (out []byte, err error) {
timestamp := (*time.Time)(t).UTC().UnixNano() timestamp := (*time.Time)(t).UTC().UnixNano()
return []byte(strconv.FormatInt(timestamp/1E6, 10)), nil return []byte(strconv.FormatInt(timestamp/1e6, 10)), nil
} }
// UnmarshalJSON turns JSON into a Timestamp // UnmarshalJSON turns JSON into a Timestamp
@ -59,7 +59,7 @@ func (t *Timestamp) UnmarshalJSON(data []byte) error {
if err != nil { if err != nil {
return err return err
} }
*t = Timestamp(time.Unix(timestamp/1E3, (timestamp%1E3)*1E6).UTC()) *t = Timestamp(time.Unix(timestamp/1e3, (timestamp%1e3)*1e6).UTC())
return nil return nil
} }

View File

@ -1453,7 +1453,7 @@ func (o *Object) readMetaData(ctx context.Context) (err error) {
// timeString returns modTime as the number of milliseconds // timeString returns modTime as the number of milliseconds
// elapsed since January 1, 1970 UTC as a decimal string. // elapsed since January 1, 1970 UTC as a decimal string.
func timeString(modTime time.Time) string { func timeString(modTime time.Time) string {
return strconv.FormatInt(modTime.UnixNano()/1E6, 10) return strconv.FormatInt(modTime.UnixNano()/1e6, 10)
} }
// parseTimeString converts a decimal string number of milliseconds // parseTimeString converts a decimal string number of milliseconds
@ -1468,7 +1468,7 @@ func (o *Object) parseTimeString(timeString string) (err error) {
fs.Debugf(o, "Failed to parse mod time string %q: %v", timeString, err) fs.Debugf(o, "Failed to parse mod time string %q: %v", timeString, err)
return nil return nil
} }
o.modTime = time.Unix(unixMilliseconds/1E3, (unixMilliseconds%1E3)*1E6).UTC() o.modTime = time.Unix(unixMilliseconds/1e3, (unixMilliseconds%1e3)*1e6).UTC()
return nil return nil
} }

View File

@ -705,16 +705,16 @@ var (
// Test test infrastructure first! // Test test infrastructure first!
func TestRandomSource(t *testing.T) { func TestRandomSource(t *testing.T) {
source := newRandomSource(1E8) source := newRandomSource(1e8)
sink := newRandomSource(1E8) sink := newRandomSource(1e8)
n, err := io.Copy(sink, source) n, err := io.Copy(sink, source)
assert.NoError(t, err) assert.NoError(t, err)
assert.Equal(t, int64(1E8), n) assert.Equal(t, int64(1e8), n)
source = newRandomSource(1E8) source = newRandomSource(1e8)
buf := make([]byte, 16) buf := make([]byte, 16)
_, _ = source.Read(buf) _, _ = source.Read(buf)
sink = newRandomSource(1E8) sink = newRandomSource(1e8)
_, err = io.Copy(sink, source) _, err = io.Copy(sink, source)
assert.Error(t, err, "Error in stream") assert.Error(t, err, "Error in stream")
} }
@ -754,23 +754,23 @@ func testEncryptDecrypt(t *testing.T, bufSize int, copySize int64) {
} }
func TestEncryptDecrypt1(t *testing.T) { func TestEncryptDecrypt1(t *testing.T) {
testEncryptDecrypt(t, 1, 1E7) testEncryptDecrypt(t, 1, 1e7)
} }
func TestEncryptDecrypt32(t *testing.T) { func TestEncryptDecrypt32(t *testing.T) {
testEncryptDecrypt(t, 32, 1E8) testEncryptDecrypt(t, 32, 1e8)
} }
func TestEncryptDecrypt4096(t *testing.T) { func TestEncryptDecrypt4096(t *testing.T) {
testEncryptDecrypt(t, 4096, 1E8) testEncryptDecrypt(t, 4096, 1e8)
} }
func TestEncryptDecrypt65536(t *testing.T) { func TestEncryptDecrypt65536(t *testing.T) {
testEncryptDecrypt(t, 65536, 1E8) testEncryptDecrypt(t, 65536, 1e8)
} }
func TestEncryptDecrypt65537(t *testing.T) { func TestEncryptDecrypt65537(t *testing.T) {
testEncryptDecrypt(t, 65537, 1E8) testEncryptDecrypt(t, 65537, 1e8)
} }
var ( var (
@ -803,7 +803,7 @@ func TestEncryptData(t *testing.T) {
} { } {
c, err := newCipher(NameEncryptionStandard, "", "", true) c, err := newCipher(NameEncryptionStandard, "", "", true)
assert.NoError(t, err) assert.NoError(t, err)
c.cryptoRand = newRandomSource(1E8) // nodge the crypto rand generator c.cryptoRand = newRandomSource(1e8) // nodge the crypto rand generator
// Check encode works // Check encode works
buf := bytes.NewBuffer(test.in) buf := bytes.NewBuffer(test.in)
@ -826,7 +826,7 @@ func TestEncryptData(t *testing.T) {
func TestNewEncrypter(t *testing.T) { func TestNewEncrypter(t *testing.T) {
c, err := newCipher(NameEncryptionStandard, "", "", true) c, err := newCipher(NameEncryptionStandard, "", "", true)
assert.NoError(t, err) assert.NoError(t, err)
c.cryptoRand = newRandomSource(1E8) // nodge the crypto rand generator c.cryptoRand = newRandomSource(1e8) // nodge the crypto rand generator
z := &zeroes{} z := &zeroes{}
@ -853,7 +853,7 @@ func TestNewEncrypterErrUnexpectedEOF(t *testing.T) {
fh, err := c.newEncrypter(in, nil) fh, err := c.newEncrypter(in, nil)
assert.NoError(t, err) assert.NoError(t, err)
n, err := io.CopyN(ioutil.Discard, fh, 1E6) n, err := io.CopyN(ioutil.Discard, fh, 1e6)
assert.Equal(t, io.ErrUnexpectedEOF, err) assert.Equal(t, io.ErrUnexpectedEOF, err)
assert.Equal(t, int64(32), n) assert.Equal(t, int64(32), n)
} }
@ -885,7 +885,7 @@ func (c *closeDetector) Close() error {
func TestNewDecrypter(t *testing.T) { func TestNewDecrypter(t *testing.T) {
c, err := newCipher(NameEncryptionStandard, "", "", true) c, err := newCipher(NameEncryptionStandard, "", "", true)
assert.NoError(t, err) assert.NoError(t, err)
c.cryptoRand = newRandomSource(1E8) // nodge the crypto rand generator c.cryptoRand = newRandomSource(1e8) // nodge the crypto rand generator
cd := newCloseDetector(bytes.NewBuffer(file0)) cd := newCloseDetector(bytes.NewBuffer(file0))
fh, err := c.newDecrypter(cd) fh, err := c.newDecrypter(cd)
@ -936,7 +936,7 @@ func TestNewDecrypterErrUnexpectedEOF(t *testing.T) {
fh, err := c.newDecrypter(in) fh, err := c.newDecrypter(in)
assert.NoError(t, err) assert.NoError(t, err)
n, err := io.CopyN(ioutil.Discard, fh, 1E6) n, err := io.CopyN(ioutil.Discard, fh, 1e6)
assert.Equal(t, io.ErrUnexpectedEOF, err) assert.Equal(t, io.ErrUnexpectedEOF, err)
assert.Equal(t, int64(16), n) assert.Equal(t, int64(16), n)
} }

View File

@ -298,7 +298,7 @@ func (f *Fs) Put(ctx context.Context, in io.Reader, src fs.ObjectInfo, options .
// This will create a duplicate if we upload a new file without // This will create a duplicate if we upload a new file without
// checking to see if there is one already - use Put() for that. // checking to see if there is one already - use Put() for that.
func (f *Fs) putUnchecked(ctx context.Context, in io.Reader, remote string, size int64, options ...fs.OpenOption) (fs.Object, error) { func (f *Fs) putUnchecked(ctx context.Context, in io.Reader, remote string, size int64, options ...fs.OpenOption) (fs.Object, error) {
if size > int64(100E9) { if size > int64(100e9) {
return nil, errors.New("File too big, cant upload") return nil, errors.New("File too big, cant upload")
} else if size == 0 { } else if size == 0 {
return nil, fs.ErrorCantUploadEmptyFiles return nil, fs.ErrorCantUploadEmptyFiles

View File

@ -835,7 +835,7 @@ func (f *Fs) copyOrMove(ctx context.Context, src fs.Object, remote string, metho
}, },
} }
if f.useOCMtime { if f.useOCMtime {
opts.ExtraHeaders["X-OC-Mtime"] = fmt.Sprintf("%f", float64(src.ModTime(ctx).UnixNano())/1E9) opts.ExtraHeaders["X-OC-Mtime"] = fmt.Sprintf("%f", float64(src.ModTime(ctx).UnixNano())/1e9)
} }
err = f.pacer.Call(func() (bool, error) { err = f.pacer.Call(func() (bool, error) {
resp, err = f.srv.Call(&opts) resp, err = f.srv.Call(&opts)
@ -1128,7 +1128,7 @@ func (o *Object) Update(ctx context.Context, in io.Reader, src fs.ObjectInfo, op
if o.fs.useOCMtime || o.fs.hasChecksums { if o.fs.useOCMtime || o.fs.hasChecksums {
opts.ExtraHeaders = map[string]string{} opts.ExtraHeaders = map[string]string{}
if o.fs.useOCMtime { if o.fs.useOCMtime {
opts.ExtraHeaders["X-OC-Mtime"] = fmt.Sprintf("%f", float64(src.ModTime(ctx).UnixNano())/1E9) opts.ExtraHeaders["X-OC-Mtime"] = fmt.Sprintf("%f", float64(src.ModTime(ctx).UnixNano())/1e9)
} }
if o.fs.hasChecksums { if o.fs.hasChecksums {
// Set an upload checksum - prefer SHA1 // Set an upload checksum - prefer SHA1

View File

@ -267,8 +267,8 @@ func (fsys *FS) Statfs(path string, stat *fuse.Statfs_t) (errc int) {
stat.Blocks = fsBlocks // Total data blocks in file system. stat.Blocks = fsBlocks // Total data blocks in file system.
stat.Bfree = fsBlocks // Free blocks in file system. stat.Bfree = fsBlocks // Free blocks in file system.
stat.Bavail = fsBlocks // Free blocks in file system if you're not root. stat.Bavail = fsBlocks // Free blocks in file system if you're not root.
stat.Files = 1E9 // Total files in file system. stat.Files = 1e9 // Total files in file system.
stat.Ffree = 1E9 // Free files in file system. stat.Ffree = 1e9 // Free files in file system.
stat.Bsize = blockSize // Block size stat.Bsize = blockSize // Block size
stat.Namemax = 255 // Maximum file name length? stat.Namemax = 255 // Maximum file name length?
stat.Frsize = blockSize // Fragment size, smallest addressable data size in the file system. stat.Frsize = blockSize // Fragment size, smallest addressable data size in the file system.

View File

@ -58,7 +58,7 @@ a bit of go code for each one.
`, `,
Hidden: true, Hidden: true,
Run: func(command *cobra.Command, args []string) { Run: func(command *cobra.Command, args []string) {
cmd.CheckArgs(1, 1E6, command, args) cmd.CheckArgs(1, 1e6, command, args)
for i := range args { for i := range args {
f := cmd.NewFsDir(args[i : i+1]) f := cmd.NewFsDir(args[i : i+1])
cmd.Run(false, false, command, func() error { cmd.Run(false, false, command, func() error {

View File

@ -58,8 +58,8 @@ func (f *FS) Statfs(ctx context.Context, req *fuse.StatfsRequest, resp *fuse.Sta
resp.Blocks = fsBlocks // Total data blocks in file system. resp.Blocks = fsBlocks // Total data blocks in file system.
resp.Bfree = fsBlocks // Free blocks in file system. resp.Bfree = fsBlocks // Free blocks in file system.
resp.Bavail = fsBlocks // Free blocks in file system if you're not root. resp.Bavail = fsBlocks // Free blocks in file system if you're not root.
resp.Files = 1E9 // Total files in file system. resp.Files = 1e9 // Total files in file system.
resp.Ffree = 1E9 // Free files in file system. resp.Ffree = 1e9 // Free files in file system.
resp.Bsize = blockSize // Block size resp.Bsize = blockSize // Block size
resp.Namelen = 255 // Maximum file name length? resp.Namelen = 255 // Maximum file name length?
resp.Frsize = blockSize // Fragment size, smallest addressable data size in the file system. resp.Frsize = blockSize // Fragment size, smallest addressable data size in the file system.

View File

@ -16,7 +16,7 @@ import (
var ( var (
// Flags // Flags
iterations = flag.Int("n", 1E6, "Iterations to try") iterations = flag.Int("n", 1e6, "Iterations to try")
maxBlockSize = flag.Int("b", 1024*1024, "Max block size to read") maxBlockSize = flag.Int("b", 1024*1024, "Max block size to read")
) )

View File

@ -17,7 +17,7 @@ import (
var ( var (
// Flags // Flags
iterations = flag.Int("n", 1E6, "Iterations to try") iterations = flag.Int("n", 1e6, "Iterations to try")
maxBlockSize = flag.Int("b", 1024*1024, "Max block size to read") maxBlockSize = flag.Int("b", 1024*1024, "Max block size to read")
simultaneous = flag.Int("transfers", 16, "Number of simultaneous files to open") simultaneous = flag.Int("transfers", 16, "Number of simultaneous files to open")
seeksPerFile = flag.Int("seeks", 8, "Seeks per file") seeksPerFile = flag.Int("seeks", 8, "Seeks per file")

View File

@ -69,7 +69,7 @@ rclone rc server, eg:
Use "rclone rc" to see a list of all possible commands.`, Use "rclone rc" to see a list of all possible commands.`,
Run: func(command *cobra.Command, args []string) { Run: func(command *cobra.Command, args []string) {
cmd.CheckArgs(0, 1E9, command, args) cmd.CheckArgs(0, 1e9, command, args)
cmd.Run(false, false, command, func() error { cmd.Run(false, false, command, func() error {
parseFlags() parseFlags()
if len(args) == 0 { if len(args) == 0 {

View File

@ -56,8 +56,8 @@ func TestPercentage(t *testing.T) {
assert.Equal(t, percent(9, 1000), "1%") assert.Equal(t, percent(9, 1000), "1%")
assert.Equal(t, percent(500, 1000), "50%") assert.Equal(t, percent(500, 1000), "50%")
assert.Equal(t, percent(1000, 1000), "100%") assert.Equal(t, percent(1000, 1000), "100%")
assert.Equal(t, percent(1E8, 1E9), "10%") assert.Equal(t, percent(1e8, 1e9), "10%")
assert.Equal(t, percent(1E8, 1E9), "10%") assert.Equal(t, percent(1e8, 1e9), "10%")
assert.Equal(t, percent(0, 0), "-") assert.Equal(t, percent(0, 0), "-")
assert.Equal(t, percent(100, -100), "-") assert.Equal(t, percent(100, -100), "-")
assert.Equal(t, percent(-100, 100), "-") assert.Equal(t, percent(-100, 100), "-")

View File

@ -101,7 +101,7 @@ var ctxFn = func(ctx context.Context, in rc.Params) (rc.Params, error) {
const ( const (
sleepTime = 100 * time.Millisecond sleepTime = 100 * time.Millisecond
floatSleepTime = float64(sleepTime) / 1E9 / 2 floatSleepTime = float64(sleepTime) / 1e9 / 2
) )
// sleep for some time so job.Duration is non-0 // sleep for some time so job.Duration is non-0

View File

@ -100,8 +100,8 @@ func TestParamsGetInt64(t *testing.T) {
{int(12), 12, ""}, {int(12), 12, ""},
{int64(13), 13, ""}, {int64(13), 13, ""},
{float64(14), 14, ""}, {float64(14), 14, ""},
{float64(9.3E18), 0, "overflows int64"}, {float64(9.3e18), 0, "overflows int64"},
{float64(-9.3E18), 0, "overflows int64"}, {float64(-9.3e18), 0, "overflows int64"},
} { } {
t.Run(fmt.Sprintf("%T=%v", test.value, test.value), func(t *testing.T) { t.Run(fmt.Sprintf("%T=%v", test.value, test.value), func(t *testing.T) {
in := Params{ in := Params{

View File

@ -248,7 +248,7 @@ func (ts *TokenSource) timeToExpiry() time.Duration {
return 0 return 0
} }
if t.Expiry.IsZero() { if t.Expiry.IsZero() {
return 3E9 * time.Second // ~95 years return 3e9 * time.Second // ~95 years
} }
return t.Expiry.Sub(time.Now()) return t.Expiry.Sub(time.Now())
} }