This sounds like an X–Y problem, where someone has a detailed question that we could find an answer for but that seems to be leading them in the wrong direction. Since you haven’t said what you’re really trying to accomplish here, we can only guess.
My guess is that
next-error (or other ways of navigating to error locations, such as clicking on them) is taking you to the wrong column, because of the odd way that gofmt reports error locations.
The bad news is that there’s no good way to transform the error locations before you call
next-error. The good news is that you can fix this after you invoke
Emacs identifies errors by using
compilation-error-regexp-alist, which is an index into all the available regexes for matching error messages and extracting their line and column numbers. You should use
C-h v to pull up the documentation and familiarize yourself with the details, though they’re not directly useful. The regexes don’t provide you with any way to do math on the column number, but it’s useful background information.
If you check the help for
next-error, however, you will find that it calls hook functions after it does the main job. The variable
next-error-hook holds a list of functions to call right after moving to the error location. If you add a function to this list, you can move to the correct point. Perhaps something like this:
(defun db48x/go-next-error-hook ()
(let ((col (current-column)))
(add-hook 'next-error-hook #'db48x/go-next-error-hook)
This is pretty simple; it just moves back to the beginning of the line, then moves over the right number of characters, counting tabs as one character.
You can find elsewhere how to add this hook only in buffers that are visiting a go file.
Also, I should point out that this problem is apparently already handled correctly in Emacs 27.1. I don’t know what version it was fixed in, but given the number of new features and bug fixes that have gone in since Emacs 24, I recommend upgrading. Even in the long–term support version of an OS you deserve to have the best possible editor.
Naturally, if this answer doesn’t solve your problem, feel free to amend your question to supply additional information.