Repository: etcd-io/etcd (language: go)

Issue:
Enable gofumpt linter
### What would you like to be added?

This issue formalizes the work to enable the gofumpt linter .

The completion track is as follows:

- [x] ~~#18748~~
- [x] ~~#18754~~
- [x] ~~#18956~~
- [x] ~~#18954~~
- [x] ~~#18953~~
- [x] ~~#18858~~


Discussion / hints:

Fix patch:
diff --git a/pkg/expect/expect.go b/pkg/expect/expect.go
index 1a0999c43b0..8aab16e52a4 100644
--- a/pkg/expect/expect.go
+++ b/pkg/expect/expect.go
@@ -34,9 +34,7 @@ import (
 
 const debugLinesTail = 40
 
-var (
-	ErrProcessRunning = fmt.Errorf("process is still running")
-)
+var ErrProcessRunning = fmt.Errorf("process is still running")
 
 type ExpectedResponse struct {
 	Value         string
diff --git a/pkg/netutil/routes_linux.go b/pkg/netutil/routes_linux.go
index f55899b0bda..b00ce457ec7 100644
--- a/pkg/netutil/routes_linux.go
+++ b/pkg/netutil/routes_linux.go
@@ -27,9 +27,11 @@ import (
 	"go.etcd.io/etcd/pkg/v3/cpuutil"
 )
 
-var errNoDefaultRoute = fmt.Errorf("could not find default route")
-var errNoDefaultHost = fmt.Errorf("could not find default host")
-var errNoDefaultInterface = fmt.Errorf("could not find default interface")
+var (
+	errNoDefaultRoute     = fmt.Errorf("could not find default route")
+	errNoDefaultHost      = fmt.Errorf("could not find default host")
+	errNoDefaultInterface = fmt.Errorf("could not find default interface")
+)
 
 // GetDefaultHost obtains the first IP address of machine from the routing table and returns the IP address as string.
 // An IPv4 address is preferred to an IPv6 address for backward compatibility.
diff --git a/pkg/osutil/osutil.go b/pkg/osutil/osutil.go
index c1405db7008..f79108a6870 100644
--- a/pkg/osutil/osutil.go
+++ b/pkg/osutil/osutil.go
@@ -15,7 +15,5 @@
 // Package osutil implements operating system-related utility functions.
 package osutil
 
-var (
-	// support to override setting SIG_DFL so tests don't terminate early
-	setDflSignal = dflSignal
-)
+// support to override setting SIG_DFL so tests don't terminate early
+var setDflSignal = dflSignal
diff --git a/pkg/traceutil/trace.go b/pkg/traceutil/trace.go
index 0f36323bd19..abf5cf1d229 100644
--- a/pkg/traceutil/trace.go
+++ b/pkg/traceutil/trace.go
@@ -211,12 +211,14 @@ func (t *Trace) logInfo(threshold time.Duration) (string, []zap.Field) {
 		lastStepTime = tstep.time
 	}
 
-	fs := []zap.Field{zap.String("detail", writeFields(t.fields)),
+	fs := []zap.Field{
+		zap.String("detail", writeFields(t.fields)),
 		zap.Duration("duration", totalDuration),
 		zap.Time("start", t.startTime),
 		zap.Time("end", endTime),
 		zap.Strings("steps", steps),
-		zap.Int("step_count", len(steps))}
+		zap.Int("step_count", len(steps)),
+	}
 	return msg, fs
 }
 
diff --git a/tools/.golangci.yaml b/tools/.golangci.yaml
index 397b32eb1de..ecb8a43d10a 100644
--- a/tools/.golangci.yaml
+++ b/tools/.golangci.yaml
@@ -19,7 +19,7 @@ linters:
     # - structcheck
     # - varcheck
     - errorlint
-    - gofmt
+    - gofumpt
     - goimports
     - ineffassign
     - nakedret


Test patch:
diff --git a/pkg/featuregate/feature_gate_test.go b/pkg/featuregate/feature_gate_test.go
index 1981496715e..7411f363fa3 100644
--- a/pkg/featuregate/feature_gate_test.go
+++ b/pkg/featuregate/feature_gate_test.go
@@ -233,7 +233,7 @@ func TestFeatureGateOverride(t *testing.T) {
 	const testBetaGate Feature = "TestBeta"
 
 	// Don't parse the flag, assert defaults are used.
-	var f = New("test", zaptest.NewLogger(t))
+	f := New("test", zaptest.NewLogger(t))
 	f.Add(map[Feature]FeatureSpec{
 		testAlphaGate: {Default: false, PreRelease: Alpha},
 		testBetaGate:  {Default: false, PreRelease: Beta},
@@ -262,7 +262,7 @@ func TestFeatureGateFlagDefaults(t *testing.T) {
 	const testBetaGate Feature = "TestBeta"
 
 	// Don't parse the flag, assert defaults are used.
-	var f = New("test", zaptest.NewLogger(t))
+	f := New("test", zaptest.NewLogger(t))
 	f.Add(map[Feature]FeatureSpec{
 		testAlphaGate: {Default: false, PreRelease: Alpha},
 		testBetaGate:  {Default: true, PreRelease: Beta},
@@ -286,7 +286,7 @@ func TestFeatureGateKnownFeatures(t *testing.T) {
 	)
 
 	// Don't parse the flag, assert defaults are used.
-	var f = New("test", zaptest.NewLogger(t))
+	f := New("test", zaptest.NewLogger(t))
 	f.Add(map[Feature]FeatureSpec{
 		testAlphaGate:      {Default: false, PreRelease: Alpha},
 		testBetaGate:       {Default: true, PreRelease: Beta},
diff --git a/pkg/netutil/netutil_test.go b/pkg/netutil/netutil_test.go
index 119d06a352c..5b4551e1fc7 100644
--- a/pkg/netutil/netutil_test.go
+++ b/pkg/netutil/netutil_test.go
@@ -318,6 +318,7 @@ func TestURLsEqual(t *testing.T) {
 		}
 	}
 }
+
 func TestURLStringsEqual(t *testing.T) {
 	defer func() { resolveTCPAddr = resolveTCPAddrDefault }()
 	errOnResolve := func(ctx context.Context, addr string) (*net.TCPAddr, error) {