go-mls icon indicating copy to clipboard operation
go-mls copied to clipboard

Consistent use of pointers

Open bifurcation opened this issue 5 years ago • 2 comments

Right now, our APIs use a mix of pointers and direct object references. We should be more uniform in our approach here. Suggested guidelines:

  • For structs representing messages (e.g., Welcome, Commit), fields are by value, except when optional
  • For other structs (e.g., State, HPKEPrivateKey), fields are as produced / passed to APIs, thus usually pointers
  • Fields in messages are by value, except when optional
  • Objects are passed to/from API methods by reference (as pointers)

bifurcation avatar Dec 31 '19 22:12 bifurcation

FWIW, it appears the conventional wisdom differs a bit from my thoughts above: https://goinbigdata.com/golang-pass-by-pointer-vs-pass-by-value/

The main thing I would like to avoid copying around is secrets / private keys. So maybe we can have a more value-oriented approach.

bifurcation avatar Dec 31 '19 22:12 bifurcation

Once we have the initial version of end to end api, this might be good one to get started .. @bifurcation thoughts ?

suhasHere avatar Jan 05 '20 06:01 suhasHere