FAQ
This problem is driving me nuts. Suppose I have a function like this:

func getFromCache(key string, outObj interface{}) { ... }

Within getFromCache I get a Go object from a cache, which in this case is a
simple map. My main code calls getFromCache like so:

var outPerson Person
getFromCache("aKey", &outPerson)

The thing I cannot get to work is to return outPerson as a Person object.
My code inside getFromCache looks something like this:

// ... code to retrieve object from into a variable retrievedObject
outObj = retrievedObject

This does not work. outPerson in the main code is empty.
reflect.TypeOf(retrievedObject) correctly returns "Person".

What am I doing wrong?

--
--
rottmann.net | Google+ <https://plus.google.com/106658337982640166595> |
Twitter <http://twitter.com/ralf> | Facebook<http://www.facebook.com/ralfrottmann>|
LinkedIn <http://de.linkedin.com/in/rottmann>

--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Search Discussions

Discussion Posts

Follow ups

Related Discussions

Discussion Navigation
viewthread | post
posts ‹ prev | 1 of 7 | next ›
Discussion Overview
groupgolang-nuts @
categoriesgo
postedApr 1, '14 at 9:14p
activeApr 2, '14 at 1:05a
posts7
users4
websitegolang.org

People

Translate

site design / logo © 2022 Grokbase