A real WAV file often carries chunks you do not care about between fmt and data. Today you walk the whole chunk list in order, stepping over anything unfamiliar to find the two chunks you need.
Iterate every chunk after the header, collecting ids in order and locating fmt and data.
The fmt and data chunks are the only two a minimal WAV reader must understand,
but files in the wild are full of others - LIST (metadata), fact, cue ,
JUNK (padding placeholders), and vendor-specific tags. A robust reader walks
the chunk list from the first chunk after the header, and for each chunk it either
handles it or steps over it using the size field. That is the whole point of a
self-describing container: you never have to know a chunk to skip it.
The walk is a loop: read a chunk, record it, advance the offset by the bytes that
chunk consumed (its 8-byte header plus its payload), repeat until you run out. To
find data, walk until you see that id and keep its payload. This loop is the
backbone of the reader - next lesson hardens it against the one alignment quirk
RIFF has, the padding byte.
// start just past the 12-byte header; readChunk returns consumed bytesfunc walk(b []byte) []Chunk {var out []Chunkoff := 12for off+8 <= len(b) {c, used, _ := readChunk(b[off:])out = append(out, c)off += used // advance to the next chunk}return out}