Skip to content

Commit

Permalink
Merge pull request #7 from seriallink/master
Browse files Browse the repository at this point in the history
Fixed len count on multi-byte characters
  • Loading branch information
momaek authored Aug 2, 2022
2 parents 96e1849 + 9778477 commit 6e44025
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 6e44025

Please sign in to comment.