Created
September 12, 2017 20:56
-
-
Save trasa/f50a42779991e853d6c9d3b5a3b8e4eb to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// fragment | |
case "say": | |
// can we get this to work using the existing type from the map? | |
responsePrototypePtr := responseRegistry["say"] | |
log.Printf("responsePrototypePtr %s is at addr %p", reflect.TypeOf(responsePrototypePtr), responsePrototypePtr) | |
// allocate a new response based off of prototype | |
// this allocates a **Response | |
responseObjPtr := reflect.New(reflect.TypeOf(&responsePrototypePtr)).Interface() | |
log.Printf("responseObjPtr type %s, string %s", reflect.TypeOf(responseObjPtr), responseObjPtr) | |
// now need to allocate a Response | |
responseObj := reflect.New(reflect.TypeOf(responseObjPtr)) | |
//responseObj = reflect.New(reflect.TypeOf(responseObjPtr.Elem().Interface().(Response))) | |
log.Printf("responseObj type %s at addr %p", reflect.TypeOf(responseObj), responseObj) | |
log.Printf("&responseObj type %s", reflect.TypeOf(&responseObj)) | |
log.Println("what im trying to get:", reflect.TypeOf(&SayResponse{})) | |
log.Printf("does this equal? %s", reflect.TypeOf(&SayResponse{}) == reflect.TypeOf(responseObj)) | |
if reflect.TypeOf(&SayResponse{}) != reflect.TypeOf(responseObj) { | |
panic("types are wrong") | |
} | |
log.Println("responseObj kind", reflect.TypeOf(responseObj).Kind()) | |
response = decodeResponse(responseObj, rawMap) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment