mirror of
https://github.com/minio/minio.git
synced 2025-11-07 21:02:58 -05:00
add gocritic/ruleguard checks back again, cleanup code. (#13665)
- remove some duplicated code - reported a bug, separately fixed in #13664 - using strings.ReplaceAll() when needed - using filepath.ToSlash() use when needed - remove all non-Go style comments from the codebase Co-authored-by: Aditya Manthramurthy <donatello@users.noreply.github.com>
This commit is contained in:
@@ -29,7 +29,7 @@ import (
|
||||
func AppendFile(dst string, src string, osync bool) error {
|
||||
flags := os.O_WRONLY | os.O_APPEND | os.O_CREATE
|
||||
if osync {
|
||||
flags = flags | os.O_SYNC
|
||||
flags |= os.O_SYNC
|
||||
}
|
||||
appendFile, err := os.OpenFile(dst, flags, 0666)
|
||||
if err != nil {
|
||||
|
||||
@@ -136,7 +136,7 @@ func (w *LimitWriter) Write(p []byte) (n int, err error) {
|
||||
var n1 int
|
||||
if w.skipBytes > 0 {
|
||||
if w.skipBytes >= int64(len(p)) {
|
||||
w.skipBytes = w.skipBytes - int64(len(p))
|
||||
w.skipBytes -= int64(len(p))
|
||||
return n, nil
|
||||
}
|
||||
p = p[w.skipBytes:]
|
||||
@@ -147,11 +147,11 @@ func (w *LimitWriter) Write(p []byte) (n int, err error) {
|
||||
}
|
||||
if w.wLimit < int64(len(p)) {
|
||||
n1, err = w.Writer.Write(p[:w.wLimit])
|
||||
w.wLimit = w.wLimit - int64(n1)
|
||||
w.wLimit -= int64(n1)
|
||||
return n, err
|
||||
}
|
||||
n1, err = w.Writer.Write(p)
|
||||
w.wLimit = w.wLimit - int64(n1)
|
||||
w.wLimit -= int64(n1)
|
||||
return n, err
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user