Skip to content

Commit c6dae46

Browse files
committed
Gofumpt the code
Gofumpt is a superset of gofmt, enabling some extra rules resulting, for the most part, in a more readable code. This replaces gofmt (which will be removed in the next commit). Signed-off-by: Kir Kolyshkin <[email protected]>
1 parent b9c5324 commit c6dae46

File tree

19 files changed

+107
-160
lines changed

19 files changed

+107
-160
lines changed

dbus/dbus_test.go

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ import (
2121
func TestNeedsEscape(t *testing.T) {
2222
// Anything not 0-9a-zA-Z should always be escaped
2323
for want, vals := range map[bool][]byte{
24-
false: []byte{'a', 'b', 'z', 'A', 'Q', '1', '4', '9'},
25-
true: []byte{'#', '%', '$', '!', '.', '_', '-', '%', '\\'},
24+
false: {'a', 'b', 'z', 'A', 'Q', '1', '4', '9'},
25+
true: {'#', '%', '$', '!', '.', '_', '-', '%', '\\'},
2626
} {
2727
for i := 1; i < 10; i++ {
2828
for _, b := range vals {
@@ -36,8 +36,8 @@ func TestNeedsEscape(t *testing.T) {
3636

3737
// 0-9 in position 0 should be escaped
3838
for want, vals := range map[bool][]byte{
39-
false: []byte{'A', 'a', 'e', 'x', 'Q', 'Z'},
40-
true: []byte{'0', '4', '5', '9'},
39+
false: {'A', 'a', 'e', 'x', 'Q', 'Z'},
40+
true: {'0', '4', '5', '9'},
4141
} {
4242
for _, b := range vals {
4343
got := needsEscape(0, b)
@@ -46,7 +46,6 @@ func TestNeedsEscape(t *testing.T) {
4646
}
4747
}
4848
}
49-
5049
}
5150

5251
func TestPathBusEscape(t *testing.T) {
@@ -64,7 +63,6 @@ func TestPathBusEscape(t *testing.T) {
6463
t.Errorf("bad result for PathBusEscape(%s): got %q, want %q", in, got, want)
6564
}
6665
}
67-
6866
}
6967

7068
func TestPathBusUnescape(t *testing.T) {
@@ -89,7 +87,6 @@ func TestPathBusUnescape(t *testing.T) {
8987
// TestNew ensures that New() works without errors.
9088
func TestNew(t *testing.T) {
9189
_, err := New()
92-
9390
if err != nil {
9491
t.Fatal(err)
9592
}

dbus/methods_test.go

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -460,7 +460,6 @@ func TestGetUnitByPID(t *testing.T) {
460460
defer conn.Close()
461461

462462
path, err := conn.GetUnitByPID(context.Background(), 1)
463-
464463
if err != nil {
465464
t.Error(err)
466465
}
@@ -476,7 +475,6 @@ func TestGetUnitNameByPID(t *testing.T) {
476475
defer conn.Close()
477476

478477
name, err := conn.GetUnitNameByPID(context.Background(), 1)
479-
480478
if err != nil {
481479
t.Error(err)
482480
}
@@ -495,7 +493,6 @@ func TestListUnitsByNames(t *testing.T) {
495493
defer conn.Close()
496494

497495
units, err := conn.ListUnitsByNames([]string{target1, target2})
498-
499496
if err != nil {
500497
t.Skip(err)
501498
}
@@ -526,7 +523,6 @@ func TestListUnitsByPatterns(t *testing.T) {
526523
defer conn.Close()
527524

528525
units, err := conn.ListUnitsByPatterns([]string{}, []string{"systemd-journald*", target2})
529-
530526
if err != nil {
531527
t.Skip(err)
532528
}
@@ -554,7 +550,6 @@ func TestListUnitsFiltered(t *testing.T) {
554550
defer conn.Close()
555551

556552
units, err := conn.ListUnitsFiltered([]string{"active"})
557-
558553
if err != nil {
559554
t.Fatal(err)
560555
}
@@ -568,7 +563,6 @@ func TestListUnitsFiltered(t *testing.T) {
568563
}
569564

570565
units, err = conn.ListUnitsFiltered([]string{"inactive"})
571-
572566
if err != nil {
573567
t.Fatal(err)
574568
}
@@ -589,7 +583,6 @@ func TestListUnitFilesByPatterns(t *testing.T) {
589583
defer conn.Close()
590584

591585
units, err := conn.ListUnitFilesByPatterns([]string{"static"}, []string{"systemd-journald*", target2})
592-
593586
if err != nil {
594587
t.Skip(err)
595588
}
@@ -603,7 +596,6 @@ func TestListUnitFilesByPatterns(t *testing.T) {
603596
}
604597

605598
units, err = conn.ListUnitFilesByPatterns([]string{"disabled"}, []string{"systemd-journald*", target2})
606-
607599
if err != nil {
608600
t.Fatal(err)
609601
}
@@ -625,7 +617,6 @@ func TestListUnitFiles(t *testing.T) {
625617
defer conn.Close()
626618

627619
units, err := conn.ListUnitFiles()
628-
629620
if err != nil {
630621
t.Fatal(err)
631622
}
@@ -1619,7 +1610,6 @@ func TestMaskUnmask(t *testing.T) {
16191610
if uChanges[0].Destination != "" {
16201611
t.Fatalf("Change destination should be empty, %+v", uChanges[0])
16211612
}
1622-
16231613
}
16241614

16251615
// Test a global Reload
@@ -1743,7 +1733,7 @@ func testAttachProcessesToUnit(t *testing.T, subcgroup string) {
17431733
t.Fatal(err)
17441734
}
17451735
path := prop.Value.Value().(string)
1746-
err = os.Mkdir(filepath.Join("/sys/fs/cgroup", path, subcgroup), 0777)
1736+
err = os.Mkdir(filepath.Join("/sys/fs/cgroup", path, subcgroup), 0o777)
17471737
if err != nil {
17481738
t.Fatal(err)
17491739
}

dbus/subscription_set_test.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ func TestSubscriptionSetUnit(t *testing.T) {
2424
target := "subscribe-events-set.service"
2525

2626
conn, err := New()
27-
2827
if err != nil {
2928
t.Fatal(err)
3029
}

dbus/subscription_test.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ import (
2222
// TestSubscribe exercises the basics of subscription
2323
func TestSubscribe(t *testing.T) {
2424
conn, err := New()
25-
2625
if err != nil {
2726
t.Fatal(err)
2827
}
@@ -43,7 +42,6 @@ func TestSubscribeUnit(t *testing.T) {
4342
target := "subscribe-events.service"
4443

4544
conn, err := New()
46-
4745
if err != nil {
4846
t.Fatal(err)
4947
}

import1/dbus_test.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ func TestExportTar(t *testing.T) {
6767
t.Fatal(err)
6868
}
6969

70-
err = os.MkdirAll("tmp/", os.ModeDir|0755)
70+
err = os.MkdirAll("tmp/", os.ModeDir|0o755)
7171
if err != nil {
7272
t.Fatal(err)
7373
}
@@ -88,7 +88,7 @@ func TestExportRaw(t *testing.T) {
8888
t.Fatal(err)
8989
}
9090

91-
err = os.MkdirAll("tmp/", os.ModeDir|0755)
91+
err = os.MkdirAll("tmp/", os.ModeDir|0o755)
9292
if err != nil {
9393
t.Fatal(err)
9494
}
@@ -114,6 +114,7 @@ func TestPullTar(t *testing.T) {
114114
t.Fatal(err)
115115
}
116116
}
117+
117118
func TestPullRaw(t *testing.T) {
118119
conn, err := New()
119120
if err != nil {

internal/dlopen/dlopen.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ package dlopen
2020
// #include <stdlib.h>
2121
// #include <dlfcn.h>
2222
import "C"
23+
2324
import (
2425
"errors"
2526
"fmt"

journal/journal_test.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@ func TestValidVarName(t *testing.T) {
5454
t.Fatalf("%q should be an invalid variable", tt)
5555
}
5656
}
57-
5857
}
5958

6059
func TestJournalSend(t *testing.T) {

login1/dbus_test.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ import (
2626
// TestNew ensures that New() works without errors.
2727
func TestNew(t *testing.T) {
2828
_, err := New()
29-
3029
if err != nil {
3130
t.Fatal(err)
3231
}

scripts/ci-runner.sh

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -83,28 +83,6 @@ function run_tests {
8383
sudo rm -rf ./test_bins
8484
}
8585

86-
function go_fmt {
87-
for pkg in ${PACKAGES}; do
88-
echo " - ${pkg}"
89-
fmtRes=$(gofmt -l "./${pkg}")
90-
if [ -n "${fmtRes}" ]; then
91-
echo -e "gofmt checking failed:\n${fmtRes}"
92-
exit 255
93-
fi
94-
done
95-
}
96-
97-
function go_vet {
98-
for pkg in ${PACKAGES}; do
99-
echo " - ${pkg}"
100-
vetRes=$(go vet "./${pkg}")
101-
if [ -n "${vetRes}" ]; then
102-
echo -e "govet checking failed:\n${vetRes}"
103-
exit 254
104-
fi
105-
done
106-
}
107-
10886
function license_check {
10987
licRes=$(for file in $(find . -type f -iname '*.go' ! -path './vendor/*'); do
11088
head -n3 "${file}" | grep -Eq "(Copyright|generated|GENERATED)" || echo -e " ${file}"
@@ -139,16 +117,6 @@ case "$subcommand" in
139117
run_tests
140118
;;
141119

142-
"go_fmt" )
143-
echo "Checking gofmt..."
144-
go_fmt
145-
;;
146-
147-
"go_vet" )
148-
echo "Checking govet..."
149-
go_vet
150-
;;
151-
152120
"license_check" )
153121
echo "Checking licenses..."
154122
license_check

sdjournal/functions.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,10 @@
1616
package sdjournal
1717

1818
import (
19-
"github.com/coreos/go-systemd/v22/internal/dlopen"
2019
"sync"
2120
"unsafe"
21+
22+
"github.com/coreos/go-systemd/v22/internal/dlopen"
2223
)
2324

2425
var (

0 commit comments

Comments
 (0)