refactor: 采用 Go 1.22+ 语法简化循环和切片初始化

- 使用  替代
- 简化  为
- 统一代码风格,移除冗余的容量参数

Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
This commit is contained in:
2026-04-09 10:34:25 +08:00
parent e8618f4888
commit 9825a85359
3 changed files with 4 additions and 4 deletions

View File

@@ -51,12 +51,12 @@ func (d *Device) statusEventHandler(evt gpiocdev.LineEvent) {
// initStatus 读取初始状态
func (d *Device) initStatus() error {
offsets := d.inLines.Offsets()
status := make([]int, len(offsets), len(offsets))
status := make([]int, len(offsets))
err := d.inLines.Values(status)
if err != nil {
return err
}
for i := 0; i < len(status); i++ {
for i := range status {
d.status[offsets[i]] = DefaultStatusLine(status[i])
}