Skip to content

Commit 0f9c128

Browse files
authored
Merge pull request #18754 from mmorel-35/contrib/golangci-lint/gofumpt
fix: enable gofumpt instead of gofmt linter in contrib, etcdctl and etcdutl
2 parents 39bff2a + 3ef69d2 commit 0f9c128

20 files changed

+50
-49
lines changed

contrib/raftexample/raft.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,8 @@ var defaultSnapshotCount uint64 = 10000
8686
// commit channel, followed by a nil message (to indicate the channel is
8787
// current), then new log entries. To shutdown, close proposeC and read errorC.
8888
func newRaftNode(id int, peers []string, join bool, getSnapshot func() ([]byte, error), proposeC <-chan string,
89-
confChangeC <-chan raftpb.ConfChange) (<-chan *commit, <-chan error, <-chan *snap.Snapshotter) {
89+
confChangeC <-chan raftpb.ConfChange,
90+
) (<-chan *commit, <-chan error, <-chan *snap.Snapshotter) {
9091
commitC := make(chan *commit)
9192
errorC := make(chan error)
9293

@@ -218,7 +219,7 @@ func (rc *raftNode) loadSnapshot() *raftpb.Snapshot {
218219
// openWAL returns a WAL ready for reading.
219220
func (rc *raftNode) openWAL(snapshot *raftpb.Snapshot) *wal.WAL {
220221
if !wal.Exist(rc.waldir) {
221-
if err := os.Mkdir(rc.waldir, 0750); err != nil {
222+
if err := os.Mkdir(rc.waldir, 0o750); err != nil {
222223
log.Fatalf("raftexample: cannot create dir for wal (%v)", err)
223224
}
224225

@@ -273,7 +274,7 @@ func (rc *raftNode) writeError(err error) {
273274

274275
func (rc *raftNode) startRaft() {
275276
if !fileutil.Exist(rc.snapdir) {
276-
if err := os.Mkdir(rc.snapdir, 0750); err != nil {
277+
if err := os.Mkdir(rc.snapdir, 0o750); err != nil {
277278
log.Fatalf("raftexample: cannot create dir for snapshot (%v)", err)
278279
}
279280
}

etcdctl/ctlv3/command/check.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ func NewCheckPerfCommand() *cobra.Command {
139139

140140
// newCheckPerfCommand executes the "check perf" command.
141141
func newCheckPerfCommand(cmd *cobra.Command, args []string) {
142-
var checkPerfAlias = map[string]string{
142+
checkPerfAlias := map[string]string{
143143
"s": "s", "small": "s",
144144
"m": "m", "medium": "m",
145145
"l": "l", "large": "l",
@@ -312,7 +312,7 @@ func NewCheckDatascaleCommand() *cobra.Command {
312312

313313
// newCheckDatascaleCommand executes the "check datascale" command.
314314
func newCheckDatascaleCommand(cmd *cobra.Command, args []string) {
315-
var checkDatascaleAlias = map[string]string{
315+
checkDatascaleAlias := map[string]string{
316316
"s": "s", "small": "s",
317317
"m": "m", "medium": "m",
318318
"l": "l", "large": "l",

etcdctl/ctlv3/command/elect_command.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,7 @@ import (
2828
"go.etcd.io/etcd/pkg/v3/cobrautl"
2929
)
3030

31-
var (
32-
electListen bool
33-
)
31+
var electListen bool
3432

3533
// NewElectCommand returns the cobra command for "elect".
3634
func NewElectCommand() *cobra.Command {

etcdctl/ctlv3/command/ep_command.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,10 @@ import (
3232
"go.etcd.io/etcd/pkg/v3/flags"
3333
)
3434

35-
var epClusterEndpoints bool
36-
var epHashKVRev int64
35+
var (
36+
epClusterEndpoints bool
37+
epHashKVRev int64
38+
)
3739

3840
// NewEndpointCommand returns the cobra command for "endpoint".
3941
func NewEndpointCommand() *cobra.Command {

etcdctl/ctlv3/command/lease_command.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -151,9 +151,7 @@ func leaseListCommandFunc(cmd *cobra.Command, args []string) {
151151
display.Leases(*resp)
152152
}
153153

154-
var (
155-
leaseKeepAliveOnce bool
156-
)
154+
var leaseKeepAliveOnce bool
157155

158156
// NewLeaseKeepAliveCommand returns the cobra command for "lease keep-alive".
159157
func NewLeaseKeepAliveCommand() *cobra.Command {

etcdctl/ctlv3/command/printer.go

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,9 +111,11 @@ func (p *printerRPC) MemberAdd(r v3.MemberAddResponse) { p.p((*pb.MemberAddRespo
111111
func (p *printerRPC) MemberRemove(id uint64, r v3.MemberRemoveResponse) {
112112
p.p((*pb.MemberRemoveResponse)(&r))
113113
}
114+
114115
func (p *printerRPC) MemberUpdate(id uint64, r v3.MemberUpdateResponse) {
115116
p.p((*pb.MemberUpdateResponse)(&r))
116117
}
118+
117119
func (p *printerRPC) MemberPromote(id uint64, r v3.MemberPromoteResponse) {
118120
p.p((*pb.MemberPromoteResponse)(&r))
119121
}
@@ -134,6 +136,7 @@ func (p *printerRPC) RoleList(r v3.AuthRoleListResponse) { p.p((*pb.AuthRoleList
134136
func (p *printerRPC) RoleGrantPermission(_ string, r v3.AuthRoleGrantPermissionResponse) {
135137
p.p((*pb.AuthRoleGrantPermissionResponse)(&r))
136138
}
139+
137140
func (p *printerRPC) RoleRevokePermission(_ string, _ string, _ string, r v3.AuthRoleRevokePermissionResponse) {
138141
p.p((*pb.AuthRoleRevokePermissionResponse)(&r))
139142
}
@@ -143,15 +146,19 @@ func (p *printerRPC) UserList(r v3.AuthUserListResponse) { p.p((*pb.Auth
143146
func (p *printerRPC) UserChangePassword(r v3.AuthUserChangePasswordResponse) {
144147
p.p((*pb.AuthUserChangePasswordResponse)(&r))
145148
}
149+
146150
func (p *printerRPC) UserGrantRole(_ string, _ string, r v3.AuthUserGrantRoleResponse) {
147151
p.p((*pb.AuthUserGrantRoleResponse)(&r))
148152
}
153+
149154
func (p *printerRPC) UserRevokeRole(_ string, _ string, r v3.AuthUserRevokeRoleResponse) {
150155
p.p((*pb.AuthUserRevokeRoleResponse)(&r))
151156
}
157+
152158
func (p *printerRPC) UserDelete(_ string, r v3.AuthUserDeleteResponse) {
153159
p.p((*pb.AuthUserDeleteResponse)(&r))
154160
}
161+
155162
func (p *printerRPC) AuthStatus(r v3.AuthStatusResponse) {
156163
p.p((*pb.AuthStatusResponse)(&r))
157164
}
@@ -211,8 +218,10 @@ func makeEndpointHealthTable(healthList []epHealth) (hdr []string, rows [][]stri
211218
}
212219

213220
func makeEndpointStatusTable(statusList []epStatus) (hdr []string, rows [][]string) {
214-
hdr = []string{"endpoint", "ID", "version", "storage version", "db size", "in use", "percentage not in use", "quota", "is leader", "is learner", "raft term",
215-
"raft index", "raft applied index", "errors"}
221+
hdr = []string{
222+
"endpoint", "ID", "version", "storage version", "db size", "in use", "percentage not in use", "quota", "is leader", "is learner", "raft term",
223+
"raft index", "raft applied index", "errors",
224+
}
216225
for _, status := range statusList {
217226
rows = append(rows, []string{
218227
status.Ep,

etcdctl/ctlv3/command/printer_fields.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -248,9 +248,11 @@ func (p *fieldsPrinter) RoleList(r v3.AuthRoleListResponse) {
248248
}
249249
fmt.Println()
250250
}
251+
251252
func (p *fieldsPrinter) RoleGrantPermission(role string, r v3.AuthRoleGrantPermissionResponse) {
252253
p.hdr(r.Header)
253254
}
255+
254256
func (p *fieldsPrinter) RoleRevokePermission(role string, key string, end string, r v3.AuthRoleRevokePermissionResponse) {
255257
p.hdr(r.Header)
256258
}
@@ -259,6 +261,7 @@ func (p *fieldsPrinter) UserChangePassword(r v3.AuthUserChangePasswordResponse)
259261
func (p *fieldsPrinter) UserGrantRole(user string, role string, r v3.AuthUserGrantRoleResponse) {
260262
p.hdr(r.Header)
261263
}
264+
262265
func (p *fieldsPrinter) UserRevokeRole(user string, role string, r v3.AuthUserRevokeRoleResponse) {
263266
p.hdr(r.Header)
264267
}

etcdctl/ctlv3/command/printer_simple.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,9 +183,11 @@ func (s *simplePrinter) MoveLeader(leader, target uint64, r v3.MoveLeaderRespons
183183
func (s *simplePrinter) DowngradeValidate(r v3.DowngradeResponse) {
184184
fmt.Printf("Downgrade validate success, cluster version %s\n", r.Version)
185185
}
186+
186187
func (s *simplePrinter) DowngradeEnable(r v3.DowngradeResponse) {
187188
fmt.Printf("Downgrade enable success, cluster version %s\n", r.Version)
188189
}
190+
189191
func (s *simplePrinter) DowngradeCancel(r v3.DowngradeResponse) {
190192
fmt.Printf("Downgrade cancel success, cluster version %s\n", r.Version)
191193
}

etcdctl/ctlv3/command/printer_table.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ func (tp *tablePrinter) MemberList(r v3.MemberListResponse) {
3434
table.SetAlignment(tablewriter.ALIGN_RIGHT)
3535
table.Render()
3636
}
37+
3738
func (tp *tablePrinter) EndpointHealth(r []epHealth) {
3839
hdr, rows := makeEndpointHealthTable(r)
3940
table := tablewriter.NewWriter(os.Stdout)
@@ -44,6 +45,7 @@ func (tp *tablePrinter) EndpointHealth(r []epHealth) {
4445
table.SetAlignment(tablewriter.ALIGN_RIGHT)
4546
table.Render()
4647
}
48+
4749
func (tp *tablePrinter) EndpointStatus(r []epStatus) {
4850
hdr, rows := makeEndpointStatusTable(r)
4951
table := tablewriter.NewWriter(os.Stdout)
@@ -54,6 +56,7 @@ func (tp *tablePrinter) EndpointStatus(r []epStatus) {
5456
table.SetAlignment(tablewriter.ALIGN_RIGHT)
5557
table.Render()
5658
}
59+
5760
func (tp *tablePrinter) EndpointHashKV(r []epHashKV) {
5861
hdr, rows := makeEndpointHashKVTable(r)
5962
table := tablewriter.NewWriter(os.Stdout)

etcdctl/ctlv3/command/snapshot_command.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,7 @@ import (
2727
"go.etcd.io/etcd/pkg/v3/cobrautl"
2828
)
2929

30-
var (
31-
snapshotExample = util.Normalize(`
30+
var snapshotExample = util.Normalize(`
3231
# Save snapshot to a given file
3332
etcdctl snapshot save /backup/etcd-snapshot.db
3433
@@ -46,7 +45,6 @@ var (
4645
4746
# Save snapshot with desirable time format
4847
etcdctl snapshot save /mnt/backup/etcd/backup_$(date +%Y%m%d_%H%M%S).db`)
49-
)
5048

5149
// NewSnapshotCommand returns the cobra command for "snapshot".
5250
func NewSnapshotCommand() *cobra.Command {

0 commit comments

Comments
 (0)