Skip to content

Commit 3dff1ab

Browse files
authored
Merge pull request #1966 from alexandear/enable-gofumpt-whitespace-linters
Enable gofumpt, whitespace linters
2 parents 7dff8ba + 5085191 commit 3dff1ab

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

58 files changed

+157
-151
lines changed

.golangci.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ linters:
5151
# - godot
5252
# - godox
5353
# - goerr113
54-
# - gofumpt
54+
- gofumpt
5555
# - goheader
5656
# - golint
5757
# - gomnd
@@ -77,7 +77,7 @@ linters:
7777
# - unconvert
7878
# - unparam
7979
- unused
80-
# - whitespace
80+
- whitespace
8181
# - wrapcheck
8282
# - wsl
8383
linters-settings:

cmd/lima-guestagent/daemon_linux.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ func daemonAction(cmd *cobra.Command, _ []string) error {
8080
if err != nil {
8181
return err
8282
}
83-
if err := os.Chmod(socket, 0777); err != nil {
83+
if err := os.Chmod(socket, 0o777); err != nil {
8484
return err
8585
}
8686
l = socketL

cmd/lima-guestagent/install_systemd_linux.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import (
1515
)
1616

1717
func newInstallSystemdCommand() *cobra.Command {
18-
var installSystemdCommand = &cobra.Command{
18+
installSystemdCommand := &cobra.Command{
1919
Use: "install-systemd",
2020
Short: "install a systemd unit (user)",
2121
RunE: installSystemdAction,
@@ -38,11 +38,11 @@ func installSystemdAction(cmd *cobra.Command, _ []string) error {
3838
logrus.Infof("File %q already exists, overwriting", unitPath)
3939
} else {
4040
unitDir := filepath.Dir(unitPath)
41-
if err := os.MkdirAll(unitDir, 0755); err != nil {
41+
if err := os.MkdirAll(unitDir, 0o755); err != nil {
4242
return err
4343
}
4444
}
45-
if err := os.WriteFile(unitPath, unit, 0644); err != nil {
45+
if err := os.WriteFile(unitPath, unit, 0o644); err != nil {
4646
return err
4747
}
4848
logrus.Infof("Written file %q", unitPath)

cmd/lima-guestagent/main_linux.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ func main() {
1515
}
1616

1717
func newApp() *cobra.Command {
18-
var rootCmd = &cobra.Command{
18+
rootCmd := &cobra.Command{
1919
Use: "lima-guestagent",
2020
Short: "Do not launch manually",
2121
Version: strings.TrimPrefix(version.Version, "v"),

cmd/limactl/copy.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ Example: limactl copy default:/etc/os-release .
2323
`
2424

2525
func newCopyCommand() *cobra.Command {
26-
var copyCommand = &cobra.Command{
26+
copyCommand := &cobra.Command{
2727
Use: "copy SOURCE ... TARGET",
2828
Aliases: []string{"cp"},
2929
Short: "Copy files between host and guest",

cmd/limactl/debug.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ func newDebugCommand() *cobra.Command {
2121
}
2222

2323
func newDebugDNSCommand() *cobra.Command {
24-
var cmd = &cobra.Command{
24+
cmd := &cobra.Command{
2525
Use: "dns UDPPORT [TCPPORT]",
2626
Short: "Debug built-in DNS",
2727
Long: "DO NOT USE! THE COMMAND SYNTAX IS SUBJECT TO CHANGE!",

cmd/limactl/delete.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import (
1414
)
1515

1616
func newDeleteCommand() *cobra.Command {
17-
var deleteCommand = &cobra.Command{
17+
deleteCommand := &cobra.Command{
1818
Use: "delete INSTANCE [INSTANCE, ...]",
1919
Aliases: []string{"remove", "rm"},
2020
Short: "Delete an instance of Lima.",

cmd/limactl/disk.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import (
1616
)
1717

1818
func newDiskCommand() *cobra.Command {
19-
var diskCommand = &cobra.Command{
19+
diskCommand := &cobra.Command{
2020
Use: "disk",
2121
Short: "Lima disk management",
2222
Example: ` Create a disk:
@@ -40,7 +40,7 @@ func newDiskCommand() *cobra.Command {
4040
}
4141

4242
func newDiskCreateCommand() *cobra.Command {
43-
var diskCreateCommand = &cobra.Command{
43+
diskCreateCommand := &cobra.Command{
4444
Use: "create DISK",
4545
Example: `
4646
To create a new disk:
@@ -92,7 +92,7 @@ func diskCreateAction(cmd *cobra.Command, args []string) error {
9292

9393
logrus.Infof("Creating %s disk %q with size %s", format, name, units.BytesSize(float64(diskSize)))
9494

95-
if err := os.MkdirAll(diskDir, 0700); err != nil {
95+
if err := os.MkdirAll(diskDir, 0o700); err != nil {
9696
return err
9797
}
9898

@@ -104,7 +104,7 @@ func diskCreateAction(cmd *cobra.Command, args []string) error {
104104
}
105105

106106
func newDiskListCommand() *cobra.Command {
107-
var diskListCommand = &cobra.Command{
107+
diskListCommand := &cobra.Command{
108108
Use: "list",
109109
Example: `
110110
To list existing disks:
@@ -190,7 +190,7 @@ func diskListAction(cmd *cobra.Command, args []string) error {
190190
}
191191

192192
func newDiskDeleteCommand() *cobra.Command {
193-
var diskDeleteCommand = &cobra.Command{
193+
diskDeleteCommand := &cobra.Command{
194194
Use: "delete DISK [DISK, ...]",
195195
Example: `
196196
To delete a disk:
@@ -279,7 +279,7 @@ func forceDeleteCommand(diskName string) string {
279279
}
280280

281281
func newDiskUnlockCommand() *cobra.Command {
282-
var diskUnlockCommand = &cobra.Command{
282+
diskUnlockCommand := &cobra.Command{
283283
Use: "unlock DISK [DISK, ...]",
284284
Example: `
285285
Emergency recovery! If an instance is force stopped, it may leave a disk locked while not actually using it.

cmd/limactl/edit.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import (
2121
)
2222

2323
func newEditCommand() *cobra.Command {
24-
var editCommand = &cobra.Command{
24+
editCommand := &cobra.Command{
2525
Use: "edit INSTANCE",
2626
Short: "Edit an instance of Lima",
2727
Args: WrapArgsError(cobra.MaximumNArgs(1)),
@@ -95,13 +95,13 @@ func editAction(cmd *cobra.Command, args []string) error {
9595
}
9696
if err := limayaml.Validate(*y, true); err != nil {
9797
rejectedYAML := "lima.REJECTED.yaml"
98-
if writeErr := os.WriteFile(rejectedYAML, yBytes, 0644); writeErr != nil {
98+
if writeErr := os.WriteFile(rejectedYAML, yBytes, 0o644); writeErr != nil {
9999
return fmt.Errorf("the YAML is invalid, attempted to save the buffer as %q but failed: %v: %w", rejectedYAML, writeErr, err)
100100
}
101101
// TODO: may need to support editing the rejected YAML
102102
return fmt.Errorf("the YAML is invalid, saved the buffer as %q: %w", rejectedYAML, err)
103103
}
104-
if err := os.WriteFile(filePath, yBytes, 0644); err != nil {
104+
if err := os.WriteFile(filePath, yBytes, 0o644); err != nil {
105105
return err
106106
}
107107
logrus.Infof("Instance %q configuration edited", instName)

cmd/limactl/editflags/editflags.go

Lines changed: 24 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,8 @@ func YQExpressions(flags *flag.FlagSet, newInstance bool) ([]string, error) {
109109
d := defaultExprFunc
110110
defs := []def{
111111
{"cpus", d(".cpus = %s"), false, false},
112-
{"dns",
112+
{
113+
"dns",
113114
func(_ *flag.Flag) (string, error) {
114115
ipSlice, err := flags.GetIPSlice("dns")
115116
if err != nil {
@@ -127,9 +128,11 @@ func YQExpressions(flags *flag.FlagSet, newInstance bool) ([]string, error) {
127128
return expr, nil
128129
},
129130
false,
130-
false},
131+
false,
132+
},
131133
{"memory", d(".memory = \"%sGiB\""), false, false},
132-
{"mount",
134+
{
135+
"mount",
133136
func(_ *flag.Flag) (string, error) {
134137
ss, err := flags.GetStringSlice("mount")
135138
if err != nil {
@@ -148,10 +151,12 @@ func YQExpressions(flags *flag.FlagSet, newInstance bool) ([]string, error) {
148151
return expr, nil
149152
},
150153
false,
151-
false},
154+
false,
155+
},
152156
{"mount-type", d(".mountType = %q"), false, false},
153157
{"mount-writable", d(".mounts[].writable = %s"), false, false},
154-
{"network",
158+
{
159+
"network",
155160
func(_ *flag.Flag) (string, error) {
156161
ss, err := flags.GetStringSlice("network")
157162
if err != nil {
@@ -177,8 +182,10 @@ func YQExpressions(flags *flag.FlagSet, newInstance bool) ([]string, error) {
177182
return expr, nil
178183
},
179184
false,
180-
false},
181-
{"rosetta",
185+
false,
186+
},
187+
{
188+
"rosetta",
182189
func(_ *flag.Flag) (string, error) {
183190
b, err := flags.GetBool("rosetta")
184191
if err != nil {
@@ -187,9 +194,11 @@ func YQExpressions(flags *flag.FlagSet, newInstance bool) ([]string, error) {
187194
return fmt.Sprintf(".rosetta.enabled = %v | .rosetta.binfmt = %v", b, b), nil
188195
},
189196
false,
190-
true},
197+
true,
198+
},
191199
{"set", d("%s"), false, false},
192-
{"video",
200+
{
201+
"video",
193202
func(_ *flag.Flag) (string, error) {
194203
b, err := flags.GetBool("video")
195204
if err != nil {
@@ -201,9 +210,11 @@ func YQExpressions(flags *flag.FlagSet, newInstance bool) ([]string, error) {
201210
return ".video.display = \"none\"", nil
202211
},
203212
false,
204-
false},
213+
false,
214+
},
205215
{"arch", d(".arch = %q"), true, false},
206-
{"containerd",
216+
{
217+
"containerd",
207218
func(_ *flag.Flag) (string, error) {
208219
s, err := flags.GetString("containerd")
209220
if err != nil {
@@ -223,8 +234,8 @@ func YQExpressions(flags *flag.FlagSet, newInstance bool) ([]string, error) {
223234
}
224235
},
225236
true,
226-
false},
227-
237+
false,
238+
},
228239
{"disk", d(".disk= \"%sGiB\""), true, false},
229240
{"vm-type", d(".vmType = %q"), true, false},
230241
{"plain", d(".plain = %s"), true, false},

0 commit comments

Comments
 (0)