Skip to content

Commit

Permalink
Fixed len count on multi-byte characters
Browse files Browse the repository at this point in the history
  • Loading branch information
seriallink committed Aug 1, 2022
1 parent 96e1849 commit 9778477
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ func (c *config) preProcessStruct(st *ast.StructType, inline ...bool) {
lens := make([]int, 0, tags.Len())
for _, key := range tags.Keys() {
t, _ := tags.Get(key)
lens = append(lens, len(t.String()))
lens = append(lens, length(t.String()))
ln.tags = append(ln.tags, t.String())
}

Expand Down Expand Up @@ -270,3 +270,7 @@ func updateResult(lines []*line, max, idx int) {
}
}
}

func length(s string) int {
return len([]rune(s))
}

0 comments on commit 9778477

Please sign in to comment.