I want to send a Struct across a network. I understand the use of gob, but gob requires the name of the struct, and my use case requires the remote node to
receive the data, and create the structure based on the received data. So I can send a packet <struct name, struct data >
From this code, I can get the name of the struct.
type myStruct struct {
One int
Two float64
}
p := reflect.ValueOf( &f )
name := p.Type().String()
fmt.Println( name )
Is there a way to get the struct instantiated from the string:
p := reflect.New( name ) //and p being type myStruct
I'll dive into the implementation of the rpc module to figure it out myself, but in the meantime I appreciate discussing it.