Skip to content

Commit 4084b37

Browse files
authored
Merge pull request #2413 from alexandear/refactor/update-golangci-lint-v1-59-1
update golangci-lint (1.59.1)
2 parents 188dcb5 + 619a4ca commit 4084b37

File tree

17 files changed

+28
-28
lines changed

17 files changed

+28
-28
lines changed

.github/workflows/test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ jobs:
3838
- name: Run golangci-lint
3939
uses: golangci/[email protected]
4040
with:
41-
version: v1.55.2
41+
version: v1.59.1
4242
args: --verbose --timeout=10m
4343
- name: Run yamllint
4444
run: yamllint .

cmd/lima-guestagent/main_linux.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ func newApp() *cobra.Command {
2121
Version: strings.TrimPrefix(version.Version, "v"),
2222
}
2323
rootCmd.PersistentFlags().Bool("debug", false, "debug mode")
24-
rootCmd.PersistentPreRunE = func(cmd *cobra.Command, args []string) error {
24+
rootCmd.PersistentPreRunE = func(cmd *cobra.Command, _ []string) error {
2525
debug, _ := cmd.Flags().GetBool("debug")
2626
if debug {
2727
logrus.SetLevel(logrus.DebugLevel)

cmd/limactl/editflags/editflags.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ func registerEdit(cmd *cobra.Command, commentPrefix string) {
2222
flags := cmd.Flags()
2323

2424
flags.Int("cpus", 0, commentPrefix+"number of CPUs") // Similar to colima's --cpu, but the flag name is slightly different (cpu vs cpus)
25-
_ = cmd.RegisterFlagCompletionFunc("cpus", func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
25+
_ = cmd.RegisterFlagCompletionFunc("cpus", func(*cobra.Command, []string, string) ([]string, cobra.ShellCompDirective) {
2626
var res []string
2727
for _, f := range completeCPUs(runtime.NumCPU()) {
2828
res = append(res, strconv.Itoa(f))
@@ -33,7 +33,7 @@ func registerEdit(cmd *cobra.Command, commentPrefix string) {
3333
flags.IPSlice("dns", nil, commentPrefix+"specify custom DNS (disable host resolver)") // colima-compatible
3434

3535
flags.Float32("memory", 0, commentPrefix+"memory in GiB") // colima-compatible
36-
_ = cmd.RegisterFlagCompletionFunc("memory", func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
36+
_ = cmd.RegisterFlagCompletionFunc("memory", func(*cobra.Command, []string, string) ([]string, cobra.ShellCompDirective) {
3737
var res []string
3838
for _, f := range completeMemoryGiB(memory.TotalMemory()) {
3939
res = append(res, fmt.Sprintf("%.1f", f))
@@ -44,15 +44,15 @@ func registerEdit(cmd *cobra.Command, commentPrefix string) {
4444
flags.StringSlice("mount", nil, commentPrefix+"directories to mount, suffix ':w' for writable (Do not specify directories that overlap with the existing mounts)") // colima-compatible
4545

4646
flags.String("mount-type", "", commentPrefix+"mount type (reverse-sshfs, 9p, virtiofs)") // Similar to colima's --mount-type=(sshfs|9p|virtiofs), but "reverse-sshfs" is Lima is called "sshfs" in colima
47-
_ = cmd.RegisterFlagCompletionFunc("mount-type", func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
47+
_ = cmd.RegisterFlagCompletionFunc("mount-type", func(*cobra.Command, []string, string) ([]string, cobra.ShellCompDirective) {
4848
return []string{"reverse-sshfs", "9p", "virtiofs"}, cobra.ShellCompDirectiveNoFileComp
4949
})
5050

5151
flags.Bool("mount-writable", false, commentPrefix+"make all mounts writable")
5252
flags.Bool("mount-inotify", false, commentPrefix+"enable inotify for mounts")
5353

5454
flags.StringSlice("network", nil, commentPrefix+"additional networks, e.g., \"vzNAT\" or \"lima:shared\" to assign vmnet IP")
55-
_ = cmd.RegisterFlagCompletionFunc("network", func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
55+
_ = cmd.RegisterFlagCompletionFunc("network", func(*cobra.Command, []string, string) ([]string, cobra.ShellCompDirective) {
5656
// TODO: retrieve the lima:* network list from networks.yaml
5757
return []string{"lima:shared", "lima:bridged", "lima:host", "lima:user-v2", "vzNAT"}, cobra.ShellCompDirectiveNoFileComp
5858
})
@@ -71,22 +71,22 @@ func RegisterCreate(cmd *cobra.Command, commentPrefix string) {
7171
flags := cmd.Flags()
7272

7373
flags.String("arch", "", commentPrefix+"machine architecture (x86_64, aarch64, riscv64)") // colima-compatible
74-
_ = cmd.RegisterFlagCompletionFunc("arch", func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
74+
_ = cmd.RegisterFlagCompletionFunc("arch", func(*cobra.Command, []string, string) ([]string, cobra.ShellCompDirective) {
7575
return []string{"x86_64", "aarch64", "riscv64"}, cobra.ShellCompDirectiveNoFileComp
7676
})
7777

7878
flags.String("containerd", "", commentPrefix+"containerd mode (user, system, user+system, none)")
79-
_ = cmd.RegisterFlagCompletionFunc("vm-type", func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
79+
_ = cmd.RegisterFlagCompletionFunc("vm-type", func(*cobra.Command, []string, string) ([]string, cobra.ShellCompDirective) {
8080
return []string{"user", "system", "user+system", "none"}, cobra.ShellCompDirectiveNoFileComp
8181
})
8282

8383
flags.Float32("disk", 0, commentPrefix+"disk size in GiB") // colima-compatible
84-
_ = cmd.RegisterFlagCompletionFunc("memory", func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
84+
_ = cmd.RegisterFlagCompletionFunc("memory", func(*cobra.Command, []string, string) ([]string, cobra.ShellCompDirective) {
8585
return []string{"10", "30", "50", "100", "200"}, cobra.ShellCompDirectiveNoFileComp
8686
})
8787

8888
flags.String("vm-type", "", commentPrefix+"virtual machine type (qemu, vz)") // colima-compatible
89-
_ = cmd.RegisterFlagCompletionFunc("vm-type", func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
89+
_ = cmd.RegisterFlagCompletionFunc("vm-type", func(*cobra.Command, []string, string) ([]string, cobra.ShellCompDirective) {
9090
return []string{"qemu", "vz"}, cobra.ShellCompDirectiveNoFileComp
9191
})
9292

cmd/limactl/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ func newApp() *cobra.Command {
6363
rootCmd.PersistentFlags().Bool("debug", false, "debug mode")
6464
// TODO: "survey" does not support using cygwin terminal on windows yet
6565
rootCmd.PersistentFlags().Bool("tty", isatty.IsTerminal(os.Stdout.Fd()), "Enable TUI interactions such as opening an editor. Defaults to true when stdout is a terminal. Set to false for automation.")
66-
rootCmd.PersistentPreRunE = func(cmd *cobra.Command, args []string) error {
66+
rootCmd.PersistentPreRunE = func(cmd *cobra.Command, _ []string) error {
6767
l, _ := cmd.Flags().GetString("log-level")
6868
if l != "" {
6969
lvl, err := logrus.ParseLevel(l)

cmd/limactl/show_ssh.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ Instead, use 'ssh -F %s/default/ssh.config lima-default' .
6666
}
6767

6868
shellCmd.Flags().StringP("format", "f", sshutil.FormatCmd, "Format: "+strings.Join(sshutil.Formats, ", "))
69-
_ = shellCmd.RegisterFlagCompletionFunc("format", func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
69+
_ = shellCmd.RegisterFlagCompletionFunc("format", func(*cobra.Command, []string, string) ([]string, cobra.ShellCompDirective) {
7070
return sshutil.Formats, cobra.ShellCompDirectiveNoFileComp
7171
})
7272
return shellCmd

cmd/limactl/snapshot.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ func newSnapshotCommand() *cobra.Command {
1515
snapshotCmd := &cobra.Command{
1616
Use: "snapshot",
1717
Short: "Manage instance snapshots",
18-
PersistentPreRun: func(cmd *cobra.Command, args []string) {
18+
PersistentPreRun: func(*cobra.Command, []string) {
1919
logrus.Warn("`limactl snapshot` is experimental")
2020
},
2121
GroupID: advancedCommand,

pkg/editutil/editutil.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ func fileWarning(filename string) string {
2424
s += "# -----------\n"
2525
for _, line := range strings.Split(strings.TrimSuffix(string(b), "\n"), "\n") {
2626
s += "#"
27-
if len(line) > 0 {
27+
if line != "" {
2828
s += " " + line
2929
}
3030
s += "\n"

pkg/fsutil/fsutil_others.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@
22

33
package fsutil
44

5-
func IsNFS(path string) (bool, error) {
5+
func IsNFS(string) (bool, error) {
66
return false, nil
77
}

pkg/guestagent/api/client/client.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ type GuestAgentClient struct {
1515

1616
func NewGuestAgentClient(dialFn func(ctx context.Context) (net.Conn, error)) (*GuestAgentClient, error) {
1717
opts := []grpc.DialOption{
18-
grpc.WithContextDialer(func(ctx context.Context, target string) (net.Conn, error) {
18+
grpc.WithContextDialer(func(ctx context.Context, _ string) (net.Conn, error) {
1919
return dialFn(ctx)
2020
}),
2121
grpc.WithTransportCredentials(NewCredentials()),

pkg/guestagent/kubernetesservice/kubernetesservice_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ func TestGetPorts(t *testing.T) {
2828
kubeClient, informerFactory := newFakeKubeClient()
2929
serviceInformer := informerFactory.Core().V1().Services().Informer()
3030
_, err := serviceInformer.AddEventHandler(cache.ResourceEventHandlerFuncs{
31-
AddFunc: func(obj interface{}) { serviceCreatedCh <- struct{}{} },
31+
AddFunc: func(interface{}) { serviceCreatedCh <- struct{}{} },
3232
})
3333
assert.NilError(t, err)
3434
informerFactory.Start(ctx.Done())

pkg/hostagent/dns/dns.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -400,7 +400,7 @@ func listenAndServe(network Network, opts ServerOptions) (*dns.Server, error) {
400400

401401
func chunkify(buffer string, limit int) []string {
402402
var result []string
403-
for len(buffer) > 0 {
403+
for buffer != "" {
404404
if len(buffer) < limit {
405405
limit = len(buffer)
406406
}

pkg/limayaml/defaults.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -211,19 +211,19 @@ func FillDefault(y, d, o *LimaYAML, filePath string) {
211211
cpuType := defaultCPUType()
212212
var overrideCPUType bool
213213
for k, v := range d.CPUType {
214-
if len(v) > 0 {
214+
if v != "" {
215215
overrideCPUType = true
216216
cpuType[k] = v
217217
}
218218
}
219219
for k, v := range y.CPUType {
220-
if len(v) > 0 {
220+
if v != "" {
221221
overrideCPUType = true
222222
cpuType[k] = v
223223
}
224224
}
225225
for k, v := range o.CPUType {
226-
if len(v) > 0 {
226+
if v != "" {
227227
overrideCPUType = true
228228
cpuType[k] = v
229229
}

pkg/networks/usernet/client.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ func NewClient(endpointSock string, subnet net.IP) *Client {
129129
func create(sock string, subnet net.IP, base string) *Client {
130130
client := &http.Client{
131131
Transport: &http.Transport{
132-
DialContext: func(ctx context.Context, network, addr string) (net.Conn, error) {
132+
DialContext: func(context.Context, string, string) (net.Conn, error) {
133133
return net.Dial("unix", sock)
134134
},
135135
},

pkg/networks/validate.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,11 +114,11 @@ func validatePath(path string, allowDaemonGroupWritable bool) error {
114114
}
115115
ownerIsAdmin := owner.Uid == "0"
116116
if !ownerIsAdmin {
117-
ownerGroupIds, err := owner.GroupIds()
117+
ownerGroupIDs, err := owner.GroupIds()
118118
if err != nil {
119119
return err
120120
}
121-
for _, g := range ownerGroupIds {
121+
for _, g := range ownerGroupIDs {
122122
if g == adminGroup.Gid {
123123
ownerIsAdmin = true
124124
break

pkg/templatestore/templatestore.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ func Templates() ([]Template, error) {
3737
templatesDir := filepath.Join(usrlocalsharelimaDir, "templates")
3838

3939
var res []Template
40-
walkDirFn := func(p string, d fs.DirEntry, err error) error {
40+
walkDirFn := func(p string, _ fs.DirEntry, err error) error {
4141
if err != nil {
4242
return err
4343
}

pkg/vz/network_darwin.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ func DialQemu(unixSock string) (*os.File, error) {
5252
}
5353

5454
remote := tcpproxy.DialProxy{
55-
DialContext: func(ctx context.Context, network, address string) (net.Conn, error) {
55+
DialContext: func(context.Context, string, string) (net.Conn, error) {
5656
return dgramConn, nil
5757
},
5858
}

pkg/vz/vm_darwin.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -711,10 +711,10 @@ func createSockPair() (server, client *os.File, _ error) {
711711
}
712712
server = os.NewFile(uintptr(serverFD), "server")
713713
client = os.NewFile(uintptr(clientFD), "client")
714-
runtime.SetFinalizer(server, func(file *os.File) {
714+
runtime.SetFinalizer(server, func(*os.File) {
715715
logrus.Debugf("Server network file GC'ed")
716716
})
717-
runtime.SetFinalizer(client, func(file *os.File) {
717+
runtime.SetFinalizer(client, func(*os.File) {
718718
logrus.Debugf("Client network file GC'ed")
719719
})
720720
vmNetworkFiles = append(vmNetworkFiles, server, client)

0 commit comments

Comments
 (0)