Probably the first article Ive ever read about lexical parsing with code that i have actually understood - and I dont even program in golang. Great job.
Lexical analysis using these bespoke methods (writing the finite state machine) is so tedious and error prone. I don't have that much experience but I just went through crafting interpreters and replaced this same module with https://github.com/J-F-Liu/pom , which is a parser combinator library, and it was way easier.
I like parser combinators but a word of warning.
A lot of parser combinators (not all) have problems with recursive grammar such as Json and SQL [1].
For instance, a JSON map can contain a JSON map and this can lead to stack overflows when defining the grammar.
[1] https://fsharpforfunandprofit.com/posts/understanding-parser...