Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

support go generate for constants #317

Merged
merged 1 commit into from
Mar 2, 2023
Merged

support go generate for constants #317

merged 1 commit into from
Mar 2, 2023

Conversation

chrisfenner
Copy link
Member

This change moves the definition of types in constants.go into that file, so that tools such as stringer can be pointed at it without also being pointed at structures.go.

The TPM specification defines several duplicate constants (AlgSHA = AlgSHA1, for example). This change moves all the "duplicated, extra" definitions into a new file called constants_internal.go so they can easily be omitted from tools such as stringer.

This change moves the definition of TPMRC helper constants so that they are not themselves TPMRC values. This prevents tools such as stringer from generating String() methods for them.

Finally, this change adds TPMHT (Handle type) values for completeness and fixes some minor typos in initialisms (TPMHTPCR, TPMHTAC). See https://github.com/golang/go/wiki/CodeReviewComments#initialisms

The 'go generate' command has been added at the top of constants.go, so 'go generate' from the command line will generate a file that implements Stringer for all these types

@chrisfenner chrisfenner requested review from alexmwu, jkl73 and a team as code owners March 2, 2023 20:59
This change moves the definition of types in constants.go into that
file, so that tools such as stringer can be pointed at it without also
being pointed at structures.go.

The TPM specification defines several duplicate constants (AlgSHA =
AlgSHA1, for example). This change moves all the "duplicated, extra"
definitions into a new file called constants_internal.go so they can
easily be omitted from tools such as stringer.

This change moves the definition of TPMRC helper constants so that they
are not themselves TPMRC values. This prevents tools such as stringer
from generating String() methods for them.

Finally, this change adds TPMHT (Handle type) values for completeness
and fixes some minor typos in initialisms (TPMHTPCR, TPMHTAC). See
https://github.com/golang/go/wiki/CodeReviewComments#initialisms

The 'go generate' command has been added at the top of constants.go, so
'go generate' from the command line will generate a file that implements
Stringer for all these types
@chrisfenner chrisfenner merged commit fe5c4ed into google:tpmdirect Mar 2, 2023
@chrisfenner chrisfenner deleted the constants branch March 2, 2023 22:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant