Skip to content

specs-go: Consistent pointer policy for invalid-value detection? #772

Open
@wking

Description

@wking

The nominal original policy for this repository was to use pointers for Go properties that were not always REQUIRED. This was codified in #287, and then reversed in #656 to be anti-pointer. However, in #764, maintainers are again asking for pointers. I think we should have a consistent position on this issue, so here's an attempt to summarize the arguments on each side:

Anti-pointer

Pro-pointer

Consistent policy

While “pointers for every omitempty property is nice and consistent, the consensus position seems to be that the increased complication of pointer handling outweighs the desire for consistency there. That's fine.

We only explicitly support null for some properties inside linux.resources.devices (which I should have removed #656). I haven't heard anyone calling for the ability to distinguish between null and unset in Go, but that's probably orthogonal to the pointer policy because you'd have to use interface{} to do it.

We have to use pointers for optional structs, because of golang/go#11939.

So the contentious point seems to be:

For optional properties where the zero value is invalid (e.g. cpus and, if #764 lands, timeout), do we want to be able to distinguish the cases in Go? Or can Go consumers assume that validation has already been done and treat Go's zero-value cases as “unset”?

We have had maintainers on both sides of that line, and while having an evolving policy is fine, I'd rather not have an inconsistent policy. I'm happy to submit pull requests to unify the repository around whichever position we want to adopt.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions