Skip to content

Commit e14d041

Browse files
author
Ubuntu
committed
chore: fix errcheck lint warnings by explicitly ignoring return values
1 parent 0f67db1 commit e14d041

5 files changed

Lines changed: 11 additions & 11 deletions

File tree

cmd/encode.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ var encodeCmd = &cobra.Command{
3737
// }
3838
// },
3939
Run: func(cmd *cobra.Command, args []string) {
40-
cmd.Help()
40+
_ = cmd.Help()
4141
},
4242
}
4343

cmd/host/host.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ func NewCmdInventory() *cobra.Command {
1111
Short: "管理存储的主机和节点信息",
1212
Long: `管理存储的主机、身份认证和节点信息。支持列出、添加、修改和删除操作。`,
1313
Run: func(cmd *cobra.Command, args []string) {
14-
cmd.Help()
14+
_ = cmd.Help()
1515
},
1616
}
1717

@@ -31,7 +31,7 @@ func NewCmdInventoryTag() *cobra.Command {
3131
Use: "tag",
3232
Short: "管理节点的标签",
3333
Run: func(cmd *cobra.Command, args []string) {
34-
cmd.Help()
34+
_ = cmd.Help()
3535
},
3636
}
3737

cmd/host/list.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ func NewCmdInventoryList() *cobra.Command {
4242
}
4343

4444
w := tabwriter.NewWriter(os.Stdout, 0, 0, 3, ' ', 0)
45-
fmt.Fprintln(w, "名称/ID\t别名\t主机地址\t用户\t认证方式\t跳板机\t标签")
45+
_, _ = fmt.Fprintln(w, "名称/ID\t别名\t主机地址\t用户\t认证方式\t跳板机\t标签")
4646

4747
keys := make([]string, 0, len(nodes))
4848
for k := range nodes {
@@ -55,7 +55,7 @@ func NewCmdInventoryList() *cobra.Command {
5555
host, _ := provider.GetHost(nodeId)
5656
identity, _ := provider.GetIdentity(nodeId)
5757

58-
fmt.Fprintf(w, "%s\t%s\t%s\t%s\t%s\t%s\t%s\n",
58+
_, _ = fmt.Fprintf(w, "%s\t%s\t%s\t%s\t%s\t%s\t%s\n",
5959
nodeId,
6060
strings.Join(node.Alias, ", "),
6161
fmt.Sprintf("%s:%d", host.Address, host.Port),
@@ -65,7 +65,7 @@ func NewCmdInventoryList() *cobra.Command {
6565
strings.Join(node.Tags, ", "),
6666
)
6767
}
68-
w.Flush()
68+
_ = w.Flush()
6969
},
7070
}
7171
cmd.Flags().StringVarP(&tagFilter, "tag", "t", "", "按标签筛选节点")
@@ -97,7 +97,7 @@ func NewCmdInventoryTags() *cobra.Command {
9797
}
9898

9999
w := tabwriter.NewWriter(os.Stdout, 0, 0, 3, ' ', 0)
100-
fmt.Fprintln(w, "标签\t节点数量")
100+
_, _ = fmt.Fprintln(w, "标签\t节点数量")
101101

102102
tags := make([]string, 0, len(tagMap))
103103
for t := range tagMap {
@@ -106,9 +106,9 @@ func NewCmdInventoryTags() *cobra.Command {
106106
sort.Strings(tags)
107107

108108
for _, t := range tags {
109-
fmt.Fprintf(w, "%s\t%d\n", t, tagMap[t])
109+
_, _ = fmt.Fprintf(w, "%s\t%d\n", t, tagMap[t])
110110
}
111-
w.Flush()
111+
_ = w.Flush()
112112
},
113113
}
114114
}

cmd/host/load.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ func ExecuteLoadHost(hosts []utils.HostInfo) error {
8686
logger.PrintErrorf("[%s] 验证失败: %v", h.Host, err)
8787
return
8888
}
89-
client.Close()
89+
_ = client.Close()
9090

9191
logger.PrintSuccessf("[%s] 验证通过并已保存", h.Host)
9292

cmd/utils/hosts.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ func ReadCSVFile(path string) ([]HostInfo, error) {
3333
}
3434
return nil, fmt.Errorf("无法打开CSV文件: %v", err)
3535
}
36-
defer file.Close()
36+
defer func() { _ = file.Close() }()
3737

3838
reader := csv.NewReader(file)
3939
// 允许不一致的列数(可选,视CSV规范而定)

0 commit comments

Comments
 (0)