go-fed / activity

ActivityStreams & ActivityPub in golang, oh my!
BSD 3-Clause "New" or "Revised" License
703 stars 112 forks source link

Add key-interface lookup for 'unknown' properties #72

Closed cjslep closed 5 years ago

cjslep commented 5 years ago

This gives "early-access" (pre-1.0.0) to new properties on existing vocabulary types.

The unknown_ catch-all already exists for types. They are just not exposed in the vocab nor streams types. Right now, the unknown_ map is accessed in a controlled manner that guarantees correct usage if the UnknownXYZ APIs are used appropriately, to guarantee a panic-free experience.

Provide access to the following:

func (*Object) HasUnknownProperty(name string) bool { /* ... */ }
func (*Object) GetUnknownProperty(name string) interface{} { /* ... */ }
func (*Object) SetUnknownProperty(name string, value interface{}) { /* ... */ }

But be sure to document everywhere in BIG SCARY BOLD that it is up to the application to ensure a panic-free experience.

Edit: To be clear, it wouldn't be just for the vocab.Object type, but every type in vocab and streams.

cjslep commented 5 years ago

d0812c94714b99c6bfeaf90784df57c05313541a and a7d2d52351f4a32c6743966852d0d1e36c0eec6b