Skip to content

Commit 73848f8

Browse files
authored
Merge pull request #4036 from fengshunli/var
🐛 cleanup/enhancement: keep all variables used defined on top of`main.go`
2 parents 4c4103e + 4d86fcd commit 73848f8

File tree

8 files changed

+8
-8
lines changed
  • docs/book/src
    • cronjob-tutorial/testdata/project/cmd
    • getting-started/testdata/project/cmd
  • pkg/plugins/golang/v4/scaffolds/internal/templates
  • testdata
    • project-v4-multigroup-with-deploy-image/cmd
    • project-v4-multigroup/cmd
    • project-v4-with-deploy-image/cmd
    • project-v4-with-grafana/cmd
    • project-v4/cmd

8 files changed

+8
-8
lines changed

docs/book/src/cronjob-tutorial/testdata/project/cmd/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ func main() {
7777
var probeAddr string
7878
var secureMetrics bool
7979
var enableHTTP2 bool
80+
var tlsOpts []func(*tls.Config)
8081
flag.StringVar(&metricsAddr, "metrics-bind-address", "0", "The address the metrics endpoint binds to. "+
8182
"Use :8443 for HTTPS or :8080 for HTTP, or leave as 0 to disable the metrics service.")
8283
flag.StringVar(&probeAddr, "health-probe-bind-address", ":8081", "The address the probe endpoint binds to.")
@@ -106,7 +107,6 @@ func main() {
106107
c.NextProtos = []string{"http/1.1"}
107108
}
108109

109-
tlsOpts := []func(*tls.Config){}
110110
if !enableHTTP2 {
111111
tlsOpts = append(tlsOpts, disableHTTP2)
112112
}

docs/book/src/getting-started/testdata/project/cmd/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ func main() {
5858
var probeAddr string
5959
var secureMetrics bool
6060
var enableHTTP2 bool
61+
var tlsOpts []func(*tls.Config)
6162
flag.StringVar(&metricsAddr, "metrics-bind-address", "0", "The address the metrics endpoint binds to. "+
6263
"Use :8443 for HTTPS or :8080 for HTTP, or leave as 0 to disable the metrics service.")
6364
flag.StringVar(&probeAddr, "health-probe-bind-address", ":8081", "The address the probe endpoint binds to.")
@@ -87,7 +88,6 @@ func main() {
8788
c.NextProtos = []string{"http/1.1"}
8889
}
8990

90-
tlsOpts := []func(*tls.Config){}
9191
if !enableHTTP2 {
9292
tlsOpts = append(tlsOpts, disableHTTP2)
9393
}

pkg/plugins/golang/v4/scaffolds/internal/templates/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,7 @@ func main() {
226226
var probeAddr string
227227
var secureMetrics bool
228228
var enableHTTP2 bool
229+
var tlsOpts []func(*tls.Config)
229230
flag.StringVar(&metricsAddr, "metrics-bind-address", "0", "The address the metrics endpoint binds to. " +
230231
"Use :8443 for HTTPS or :8080 for HTTP, or leave as 0 to disable the metrics service.")
231232
flag.StringVar(&probeAddr, "health-probe-bind-address", ":8081", "The address the probe endpoint binds to.")
@@ -255,7 +256,6 @@ func main() {
255256
c.NextProtos = []string{"http/1.1"}
256257
}
257258
258-
tlsOpts := []func(*tls.Config){}
259259
if !enableHTTP2 {
260260
tlsOpts = append(tlsOpts, disableHTTP2)
261261
}

testdata/project-v4-multigroup-with-deploy-image/cmd/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ func main() {
8383
var probeAddr string
8484
var secureMetrics bool
8585
var enableHTTP2 bool
86+
var tlsOpts []func(*tls.Config)
8687
flag.StringVar(&metricsAddr, "metrics-bind-address", "0", "The address the metrics endpoint binds to. "+
8788
"Use :8443 for HTTPS or :8080 for HTTP, or leave as 0 to disable the metrics service.")
8889
flag.StringVar(&probeAddr, "health-probe-bind-address", ":8081", "The address the probe endpoint binds to.")
@@ -112,7 +113,6 @@ func main() {
112113
c.NextProtos = []string{"http/1.1"}
113114
}
114115

115-
tlsOpts := []func(*tls.Config){}
116116
if !enableHTTP2 {
117117
tlsOpts = append(tlsOpts, disableHTTP2)
118118
}

testdata/project-v4-multigroup/cmd/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ func main() {
8383
var probeAddr string
8484
var secureMetrics bool
8585
var enableHTTP2 bool
86+
var tlsOpts []func(*tls.Config)
8687
flag.StringVar(&metricsAddr, "metrics-bind-address", "0", "The address the metrics endpoint binds to. "+
8788
"Use :8443 for HTTPS or :8080 for HTTP, or leave as 0 to disable the metrics service.")
8889
flag.StringVar(&probeAddr, "health-probe-bind-address", ":8081", "The address the probe endpoint binds to.")
@@ -112,7 +113,6 @@ func main() {
112113
c.NextProtos = []string{"http/1.1"}
113114
}
114115

115-
tlsOpts := []func(*tls.Config){}
116116
if !enableHTTP2 {
117117
tlsOpts = append(tlsOpts, disableHTTP2)
118118
}

testdata/project-v4-with-deploy-image/cmd/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ func main() {
5858
var probeAddr string
5959
var secureMetrics bool
6060
var enableHTTP2 bool
61+
var tlsOpts []func(*tls.Config)
6162
flag.StringVar(&metricsAddr, "metrics-bind-address", "0", "The address the metrics endpoint binds to. "+
6263
"Use :8443 for HTTPS or :8080 for HTTP, or leave as 0 to disable the metrics service.")
6364
flag.StringVar(&probeAddr, "health-probe-bind-address", ":8081", "The address the probe endpoint binds to.")
@@ -87,7 +88,6 @@ func main() {
8788
c.NextProtos = []string{"http/1.1"}
8889
}
8990

90-
tlsOpts := []func(*tls.Config){}
9191
if !enableHTTP2 {
9292
tlsOpts = append(tlsOpts, disableHTTP2)
9393
}

testdata/project-v4-with-grafana/cmd/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ func main() {
5454
var probeAddr string
5555
var secureMetrics bool
5656
var enableHTTP2 bool
57+
var tlsOpts []func(*tls.Config)
5758
flag.StringVar(&metricsAddr, "metrics-bind-address", "0", "The address the metrics endpoint binds to. "+
5859
"Use :8443 for HTTPS or :8080 for HTTP, or leave as 0 to disable the metrics service.")
5960
flag.StringVar(&probeAddr, "health-probe-bind-address", ":8081", "The address the probe endpoint binds to.")
@@ -83,7 +84,6 @@ func main() {
8384
c.NextProtos = []string{"http/1.1"}
8485
}
8586

86-
tlsOpts := []func(*tls.Config){}
8787
if !enableHTTP2 {
8888
tlsOpts = append(tlsOpts, disableHTTP2)
8989
}

testdata/project-v4/cmd/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ func main() {
5858
var probeAddr string
5959
var secureMetrics bool
6060
var enableHTTP2 bool
61+
var tlsOpts []func(*tls.Config)
6162
flag.StringVar(&metricsAddr, "metrics-bind-address", "0", "The address the metrics endpoint binds to. "+
6263
"Use :8443 for HTTPS or :8080 for HTTP, or leave as 0 to disable the metrics service.")
6364
flag.StringVar(&probeAddr, "health-probe-bind-address", ":8081", "The address the probe endpoint binds to.")
@@ -87,7 +88,6 @@ func main() {
8788
c.NextProtos = []string{"http/1.1"}
8889
}
8990

90-
tlsOpts := []func(*tls.Config){}
9191
if !enableHTTP2 {
9292
tlsOpts = append(tlsOpts, disableHTTP2)
9393
}

0 commit comments

Comments
 (0)