package pes

type PacketChannel <-chan *Packet

func (input PacketChannel) PayloadOnly() <-chan []byte {
	output := make(chan []byte)
	go func() {
		defer close(output)
		for packet := range input {
			output <- packet.Payload
		}
	}()
	return output
}

package pes

type PacketChannel <-chan *Packet

func (input PacketChannel) PayloadOnly() <-chan []byte {
	output := make(chan []byte)
	go func() {
		for packet := range input {
			output <- packet.Payload
		}
		close(output)
	}()
	return output
}

--- 
+++ 
@@ -5,10 +5,10 @@
 func (input PacketChannel) PayloadOnly() <-chan []byte {
 	output := make(chan []byte)
 	go func() {
+		defer close(output)
 		for packet := range input {
 			output <- packet.Payload
 		}
-		close(output)
 	}()
 	return output
 }
Use defer to schedule channel closing
