• Rob Pike's avatar
    text/template: shut down lexing goroutine on error · 64c39a30
    Rob Pike authored
    When a parse error occurred, the lexing goroutine would lay idle.
    It's not likely a problem but if the program is for some reason
    accepting badly formed data repeatedly, it's wasteful.
    
    The solution is easy: Just drain the input on error. We know this
    will succeed because the input is always a string and is therefore
    guaranteed finite.
    
    With debugging prints in the package tests I've shown this is effective,
    shutting down 79 goroutines that would otherwise linger, out of 123 total.
    
    Fixes #10574.
    
    Change-Id: I8aa536e327b219189a7e7f604a116fa562ae1c39
    Reviewed-on: https://go-review.googlesource.com/9658Reviewed-by: 's avatarRuss Cox <rsc@golang.org>
    64c39a30
lex_test.go 11.4 KB