commit 3083e3dd1cb493efa7557138726614b1d3758e81
parent 5b0199e0674b051428672a1460ed5109b3cedadf
Author: Oliver Lowe <o@olowe.co>
Date: Sun, 4 May 2025 13:05:13 +1000
m3u8: enable toggling lexer debug output
Diffstat:
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/m3u8/lex.go b/m3u8/lex.go
@@ -4,6 +4,7 @@ import (
"bufio"
"fmt"
"io"
+ "os"
"strings"
"unicode/utf8"
)
@@ -73,6 +74,9 @@ type lexer struct {
pos int
width int
items chan item
+
+ // if enabled, emitted items are printed to standard error.
+ debug bool
}
type stateFn func(*lexer) stateFn
@@ -113,7 +117,9 @@ func (l *lexer) run() {
func (l *lexer) emit(t itemType) {
l.items <- item{t, l.input[l.start:l.pos]}
- // fmt.Println(item{t, l.input[l.start:l.pos]})
+ if l.debug {
+ fmt.Fprintln(os.Stderr, item{t, l.input[l.start:l.pos]})
+ }
l.start = l.pos
}