func decodeCustomLayer(data []byte, p gopacket.PacketBuilder) error {
	p.AddLayer(&CustomLayer{data[0], data[1], data[2:]})
	return p.NextDecoder(gopacket.LayerTypePayload)
}
Custom decode function. We can name it whatever we want
but it should have the same arguments and return value
When the layer is registered we tell it to use this decode function
package main
import (
	"fmt"
	"github.com/google/gopacket"
)
type CustomLayer struct {
	SomeByte    byte
	AnotherByte byte
	restOfData  []byte
}
var CustomLayerType = gopacket.RegisterLayerType(
	2001,
	gopacket.LayerTypeMetadata{
		"CustomLayerType",
		gopacket.DecodeFunc(decodeCustomLayer),
	},
)
func (l CustomLayer) LayerType() gopacket.LayerType {
	return CustomLayerType
}
func (l CustomLayer) LayerContents() []byte {
	return []byte{l.SomeByte, l.AnotherByte}
}
func (l CustomLayer) LayerPayload() []byte {
	return l.restOfData
}