Skip to content

Commit

Permalink
Fix go vet failure
Browse files Browse the repository at this point in the history
When running the go vet linter on the entire project, we encounter a failure
stating that an integer to string conversion using "string(c)" can lead to
unexpected results. Such a failure might become an error in future
versions of Go. See for example https://go.dev/doc/go1.15#vet.

By explicitly converting the integer to a rune before casting it to a
string, we avoid this issue and can run go test without the "-vet=off"
flag.
  • Loading branch information
Troy Figiel committed Feb 25, 2024
1 parent cd83393 commit 5073146
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion fontmaker/core/fontmaker.go
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,7 @@ func (f *FontMaker) MakeWidthArray(widths map[int]int) (string, error) {
str := "\tme.cw = make(gopdf.FontCw)\n"
for c := 0; c <= 255; c++ {
str += "\tme.cw["
chr := string(c)
chr := string(rune(c))
if chr == "\"" {
str += "gopdf.ToByte(\"\\\"\")"
} else if chr == "\\" {
Expand Down

0 comments on commit 5073146

Please sign in to comment.