Recommend to keep the visibility of the top-level identifiers
If the new package starts with ".", All top-level identifiers will have prefixes to prevent conflicts, and their uses will also be updated.
for example, I use ".int" package name to generalize queue, the "New" function will rewrite to "intNew", this changed the visibility of the template function "New". If I used ".Int", it may changed the visibility of those identifiers started with lower case character. So I recommend to keep the visibility of the top-level Identifiers.
I think this issue only applies to .result package target.
Do you have a suggestion to keep top-level identifiers to be exported while we still have prefixing?
For me, it is nice to have all top-level identifiers unexported:
- prefixed identifier name is ugly for exported API.
- Although it was exported, it might not be needed to be exported after rewrite under the new package.
If it is needed, I often create aliases in the current package in another file like:
func New() *IntQueue {
return intNew()
}
I think the simple rule is : if top level identifier start with lower case character, then Chang the prefix first letter to Lower case, vice versa.
prefix in general should be all lowercase yyy. Could you explain more about your idea if the generic package has uppercase top-level identifiers, like Xxx? The current behavior is yyyXxx.