Initial split of internal and external api types.

I .... I don't get it.  I thought returning address-of-a-local was legit,
if not exactly common, in go.


On Tue, Jul 15, 2014 at 9:40 PM, Daniel Smith <notifications@github.com>
wrote:

> In pkg/api/internal/helper.go:
>
> > +	obj = checkPtr(obj)
> > +	jsonBase, err := prepareEncode(obj)
> > +	if err != nil {
> > +		return nil, err
> > +	}
> > +	data, err = json.MarshalIndent(obj, "", "	")
> > +	jsonBase.Kind = ""
> > +	return data, err
> > +}
> > +
> > +func checkPtr(obj interface{}) interface{} {
> > +	v := reflect.ValueOf(obj)
> > +	if v.Kind() == reflect.Ptr {
> > +		return obj
> > +	}
> > +	v2 := reflect.New(v.Type())
>
> It's not addressable. The reflect package actually disallows this, which
> is the equivalent of what you're suggesting-- it's basically never what you
> want to do when using the reflect package:
>
> func foo(x int) *int {
> return &x
> }
>
> --
> Reply to this email directly or view it on GitHub
> <https://github.com/GoogleCloudPlatform/kubernetes/pull/476/files#r14981056>
> .
>