Closed sivabudh closed 2 years ago
I honestly don't see an immediate benefit in using generics for the protocol overall, since every OCPP message is very well defined and statically typed. As a result, I designed the library entirely based on a Request
and a Response
interface. Every concrete message is just a struct implementing one of those interfaces.
The feature I would consider as a potential candidate for generics is the DataTransferFeature
, as it is meant to support a user-defined protocol, based on any kind of struct. Right now this is implemented as an interface{}
type. This offers flexibility, but forces to manually parse the custom payload (or re-serialize and deserialize), since the library doesn't know the custom message type and just ends up parsing it as an inferred stdlib type (typically a map).
I will look into this option and see if generics could help solve this, once 1.18 is out.
Thanks!
[Off-topic; not related to bugs or feature suggestions]
Hi,
I heard that Go 1.18 which includes Type Parameters will be released in February 2022.
Do you think the library could potentially benefit from the feature? If you are so willing to entertain the possibility, how would the library be refactored to take advantage of this feature, if at all?