Use gofumpt to format code

gofumpt (mvdan.cc/gofumpt) is a fork of gofmt with stricter rules.

Brought to you by

	git ls-files \*.go | grep -v ^vendor/ | xargs gofumpt -s -w

Looking at the diff, all these changes make sense.

Also, replace gofmt with gofumpt in golangci.yml.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
This commit is contained in:
Kir Kolyshkin
2021-06-01 11:56:21 -07:00
parent 3a0234e1fe
commit e6048715e4
75 changed files with 195 additions and 216 deletions
@@ -23,7 +23,7 @@ func TestWriteCgroupFileHandlesInterrupt(t *testing.T) {
cgroupName := fmt.Sprintf("test-eint-%d", time.Now().Nanosecond())
cgroupPath := filepath.Join(memoryCgroupMount, cgroupName)
if err := os.MkdirAll(cgroupPath, 0755); err != nil {
if err := os.MkdirAll(cgroupPath, 0o755); err != nil {
t.Fatal(err)
}
defer os.RemoveAll(cgroupPath)
+2 -2
View File
@@ -28,7 +28,8 @@ var (
func prepareOpenat2() error {
prepOnce.Do(func() {
fd, err := unix.Openat2(-1, cgroupfsDir, &unix.OpenHow{
Flags: unix.O_DIRECTORY | unix.O_PATH})
Flags: unix.O_DIRECTORY | unix.O_PATH,
})
if err != nil {
prepErr = &os.PathError{Op: "openat2", Path: cgroupfsDir, Err: err}
if err != unix.ENOSYS {
@@ -52,7 +53,6 @@ func prepareOpenat2() error {
// cgroupv2 has a single mountpoint and no "cpu,cpuacct" symlinks
resolveFlags |= unix.RESOLVE_NO_XDEV | unix.RESOLVE_NO_SYMLINKS
}
})
return prepErr
+1 -3
View File
@@ -10,9 +10,7 @@ import (
"strings"
)
var (
ErrNotValidFormat = errors.New("line is not a valid key value format")
)
var ErrNotValidFormat = errors.New("line is not a valid key value format")
// ParseUint converts a string to an uint64 integer.
// Negative values are returned at zero as, due to kernel bugs,
+5 -5
View File
@@ -31,7 +31,7 @@ func TestGetCgroupParamsInt(t *testing.T) {
tempFile := filepath.Join(tempDir, cgroupFile)
// Success.
err = ioutil.WriteFile(tempFile, []byte(floatString), 0755)
err = ioutil.WriteFile(tempFile, []byte(floatString), 0o755)
if err != nil {
t.Fatal(err)
}
@@ -43,7 +43,7 @@ func TestGetCgroupParamsInt(t *testing.T) {
}
// Success with new line.
err = ioutil.WriteFile(tempFile, []byte(floatString+"\n"), 0755)
err = ioutil.WriteFile(tempFile, []byte(floatString+"\n"), 0o755)
if err != nil {
t.Fatal(err)
}
@@ -55,7 +55,7 @@ func TestGetCgroupParamsInt(t *testing.T) {
}
// Success with negative values
err = ioutil.WriteFile(tempFile, []byte("-12345"), 0755)
err = ioutil.WriteFile(tempFile, []byte("-12345"), 0o755)
if err != nil {
t.Fatal(err)
}
@@ -68,7 +68,7 @@ func TestGetCgroupParamsInt(t *testing.T) {
// Success with negative values lesser than min int64
s := strconv.FormatFloat(math.MinInt64, 'f', -1, 64)
err = ioutil.WriteFile(tempFile, []byte(s), 0755)
err = ioutil.WriteFile(tempFile, []byte(s), 0o755)
if err != nil {
t.Fatal(err)
}
@@ -80,7 +80,7 @@ func TestGetCgroupParamsInt(t *testing.T) {
}
// Not a float.
err = ioutil.WriteFile(tempFile, []byte("not-a-float"), 0755)
err = ioutil.WriteFile(tempFile, []byte("not-a-float"), 0o755)
if err != nil {
t.Fatal(err)
}