Skip to content

Conversation

@daniel-sanche
Copy link
Member

added imports to snippet comments (b/113025156)

@googlebot googlebot added the cla: yes This human has signed the Contributor License Agreement. label Oct 18, 2018

// getAsymmetricPublicKey retrieves the public key from a saved asymmetric key pair on KMS.
//
// Requires:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These lines are a little bit weird since they don't list every import, only some of them. Would you mind splitting all of these functions into separate files and include the import() block in the region tag? I think that's the pattern the canonical snippet will follow, so it would be a step in the right direction.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've had conversations with Kurtis (GoogleCloudPlatform/java-docs-samples#1218) and the product team (b/113025156) on how best to handle this. We decided that until we have an agreed upon standard way of handling imports, it would be best to leave the imports in the comments for now. This gives the users the information they need, and it's easy to be consistent with how we present the information across all supported languages without significant refactors.

As for not including all imports, I assumed standard imports like fmt, errors, and context would be considered a given for anyone familiar with go, but I can add them if you think it would be useful

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure. These are all standard library imports. So, goimports should find them. So, I'm not sure this is worth adding.

If we decide on the right way to include imports in the canonical snippet, we can update this.

Does that make sense?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suppose. I'd prefer to include these for consistency sake since these comments are needed for python and java. Even in go it might not be clear whether we're using standard crypto libraries or 3rd party ones with similar names, so I'd prefer to be explicit. But I guess these aren't as necessary for go

I am going to want to remove the region tags from the import block though, so this PR should stay open either way

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla: yes This human has signed the Contributor License Agreement.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants