In GOLANG is there an easy to way to cast structs for polymorphic behavior across channels? I'm trying to send different versions of a struct across one channel, so for example I'm going to have different types of Events, like a LoginEvent. Each one will have different amounts of data in the struct.
package main
import "fmt"
type Event struct {
EvtType EvtType
Username string
Data string
}
type LoginEvent struct {
Event
CallBackChannel chan *Event
}
type EvtType int
const (
Login EvtType = iota+1
Logout
ChatMessage
Presense
BuddyList
)
func main() {
fakeOutputChan := make(chan<- *Event)
ourSrvChannel := make(chan *Event)
lg := (LoginEvent{Event{Login,"",""} ,ourSrvChannel})
fakeOutputChan <- (*Event)(&lg)
fmt.Println("Hello, playground")
}