Skip to content

Field name restrictions tied too closely to Go language rules #206

@rvagg

Description

@rvagg

Will did over the go-ipld-git codec with ipld-prime, but it changed the serialization from lower-case git-standard names (tree, object, date etc.) to CamelCase names (Tree, Object, Date, etc.). Which seems reasonable, but it messed up the pathing resolution upstream, failing a go-ipfs test that was reaching down deep through a git DAG. Instead of brute-forcing a change to the path, I wanted to try and reconcile it with the original (and with the JS codec, and with Git standard naming—although this point is arguably flexible): https://github.com/ipfs/go-ipld-git/blob/0436bc7c4a2712d018bd8b49833745e1f7e12227/gen/gen.go

A couple of things arise from this:

  • The lower-case field names mean that outside of the package you couldn't use the plain struct forms to construct your objects (_Commit{...}), and I suppose you can't interrogate them that way either. Presumably you'd have to assemble the node using the standard assemblers and assign to the typed form. Which gets very verbose.
  • You can't use the field name type, so there's a substitution here for tagType. Which I guess means this is a reserved word in the IPLD data model in certain places.

Perhaps there's more than this. I'm wondering if we shouldn't be doing a bit of name mangling to make more cases work, like prefixing all fields with Field_ or somesuch. Or, maybe simply recognising these cases where the names will cause problems and mangling only those, predictably.

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