Initial split of internal and external api types.

Then how come it won't let me get the address of the argument that was
passed?  I guess it's because the compiler can't statically analyze that
and do lifetime extension.  OK.  Not relevant to this PR


On Tue, Jul 15, 2014 at 10:12 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 because you wouldn't get the address of the variable you passed to
> ValueOf; you get the address of the copy that go made for you. I remember
> the bad old days when reflect didn't have this restriction. It was super
> easy to accidentally write a really confusing bug.
>
> --
> Reply to this email directly or view it on GitHub
> <https://github.com/GoogleCloudPlatform/kubernetes/pull/476/files#r14981561>
> .
>