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}, }, } for i,msg := range messages { if token, ok := msg.(MsgToken); ok { token.Token = [4]byte{0x00, 0x00, 0x00, 0x00} messages[i] = token } } fmt.Printf("messages: %v\n", messages) }