What you want is a table-driven test. https://bitbucket.org/zombiezen/yaml/src/f262957a017e30e74631cefc18cb94e2c068bcc4/scanner_test.go?at=default