package main import "fmt" type NetMsg interface { Pack() []byte } type MsgToken struct { Token [4]byte } func (t MsgToken) Pack() []byte { return t.Token[:] } func main() { messages := []NetMsg{ MsgToken { Token: [4]byte{0xff, 0xff, 0xff, 0xff}, }, } if token, ok := messages[0].(MsgToken); ok { token.Token = [4]byte{0x00, 0x00, 0x00, 0x00} fmt.Printf("setting token: %v\n", token.Token) } fmt.Printf("messages: %v\n", messages) }