delete the struct aliases & consider merging all of structures and commands into one 'tpm2' package
chrisfenner opened this issue · 4 comments
#300 has:
Complicated to write due to all the structures being wrapped with internal
Tools that allow "peeking" the definition of symbols will show the alias definition and not the actual structure, which hinders discoverability.
The proposed fix in #300 is:
Moving all the structs into one big file rather than being wrapped in "internal". This will also solve the "hovering for fields" problem.
The obvious drawback of this fix is that it will embiggen the spelling of every symbol, e.g.:
import "github.com/google/go-tpm/direct/structures/tpma"
tpma.Object
becomes something like:
import "github.com/google/go-tpm/direct/structures"
structures.tpmaObject
We have to prefix every type with something corresponding to the TPMA_
, TPM2B_
, etc. from the spec. We can't strip tpm
from the prefix because then we have 2b
as a prefix of some symbols (and Go symbols can't start with a digit).
Since this is a development branch and I plan to work on tpmdirect some more over the long weekend, I went ahead and merged this in #308. I'll leave this open so we can discuss and review after the fact, happy to undo this refactor based on discussions and how this prototype ages.
I also support this change.
For the stuttering name, one thing we can do is have the TPM
prefix stripped from everything that would be a valid Golang identifier TPMS_*
, TPMA_*
, etc. but special-case TPM2B
. Prefixes could be tpm2.B*
or tpm2.TwoB*
FWIW, I'm more in favor of consistency, but thought I'd bring this up. Also, writing out tpm2.SNVPublic
for example seems stranger than tpm2.TPMSNVPublic
, as the "2" is inserted in a TPM spec name. This also makes finding things in the code base harder
We discussed this offline