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

The application/Tags type acts like it supports by value semantics but really it doesn't #183

Open
keep94 opened this issue Jul 9, 2024 · 0 comments

Comments

@keep94
Copy link
Contributor

keep94 commented Jul 9, 2024

application.New() returns a Tags instance by value hinting that the Tags type supports by-value semantics. Unfortunately this is not the case. Consider this code:

tagsa := application.New("appName", "serviceName")
tagsb := tagsa

// Oops tagsb now has the same custom tag added to tagsa
tagsa.AddCustomTagFromEnv("varName", "tag")

Solution: application.New should be deprecated. A different new function that returns a *Tags instead of Tags should be created. Documentation should stress that Tags does not support by-value semantics. Or application.New could just return *Tags as a breaking change.

Alternatively, Tags could be made to support by-value semantics. To do this, modifications to CustomTags field of Tags would mean creating a new map each time rather than modifying it in place.

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

No branches or pull requests

1 participant