Skip to content

Commit

Permalink
fix: filter iota
Browse files Browse the repository at this point in the history
  • Loading branch information
dmji committed Jan 1, 2025
1 parent 284febf commit 59168bb
Showing 1 changed file with 19 additions and 10 deletions.
29 changes: 19 additions & 10 deletions goi18n/extract_command.go
Original file line number Diff line number Diff line change
Expand Up @@ -199,18 +199,27 @@ func (e *extractor) extractConsts(node ast.GenDecl) {
for _, s := range node.Specs {
if vs, ok := s.(*ast.ValueSpec); ok {
for i, n := range vs.Names {
if len(vs.Values) <= i {
break
}
bl, ok := vs.Values[i].(*ast.BasicLit)
if !ok {
break
}

if bl, ok := vs.Values[i].(*ast.BasicLit); ok {
v, err := strconv.Unquote(bl.Value)
if err != nil {
continue
}
e.consts = append(e.consts, &constObj{
name: n.Name,
value: v,
packageName: e.packageName,
})
v, err := strconv.Unquote(bl.Value)
if err != nil {
continue
}
if v == "iota" {
break
}
e.consts = append(e.consts, &constObj{
name: n.Name,
value: v,
packageName: e.packageName,
})

}
}
}
Expand Down

0 comments on commit 59168bb

Please sign in to comment.