SublimeLinter-govet icon indicating copy to clipboard operation
SublimeLinter-govet copied to clipboard

Markers are shifted right after non-ASCII characters: go vet columns are UTF-8 bytes, linter needs column_unit = 'utf8'

Open dpc00 opened this issue 2 months ago • 0 comments

The markers are shifted to the right by the number of extra bytes of every non-ASCII character earlier on the line, because go vet reports columns in UTF-8 bytes and the linter treats them as character columns.

Reproduce (Sublime Text 4215, SublimeLinter 4.30, SublimeLinter-govet current, Go 1.26.5; go.mod with module example.com/govet_test, main.go):

package main

import "fmt"

func main() {
	fmt.Printf("%d\n", "plain")
	s := "ééé"; fmt.Printf("%d\n", s)
	t := "😀"; fmt.Printf("%d\n", t)
}

go vet . reports:

main.go:6:14: fmt.Printf format %d has arg "plain" of wrong type string
main.go:7:29: fmt.Printf format %d has arg s of wrong type string
main.go:8:27: fmt.Printf format %d has arg t of wrong type string

In each of the three lines the position is that of the % of %d. On line 7 it is the 26th character but byte column 29 (three é, one extra byte each); on line 8 it is the 24th character but byte column 27 (the emoji is four bytes).

Actual (the character SublimeLinter highlights):

line should be is
6 (ASCII) % %
7 (after ééé) % n
8 (after the emoji) % n

Fix: add column_unit = 'utf8' to the Govet class (core 4.30 has this attribute; this is also what Go's own tools use). I set it on the running class and relinted the same file: all three markers are then exactly on %.

dpc00 avatar Oct 01 '26 22:10 dpc00