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

Clean up init section #20

Open
808codist opened this issue Mar 30, 2022 · 1 comment
Open

Clean up init section #20

808codist opened this issue Mar 30, 2022 · 1 comment

Comments

@808codist
Copy link

This whole init section could be cleaned up:

  1. As you noted _validTagValueRegexp is not used. So we could remove it. @wblakecaldwell does this regex have a purpose?
  2. Since the regex is a static string, we can also use regexp.MustCompile() which does not return an error and will panic if the regex does not compile. But this is exactly what initTagBatch() is doing so we can simplify the declaration to var validTagValueRegexp = regexp.MustCompile(`^[a-zA-Z0-9_-]+$`) and remove initTagBatch() completely.
  3. Each Go file may have its own init() function [1]. I don't think we need init.go to call a bunch of other init functions. Unless there's some dependency and the order is important. But in this case I don't think it does.

[1] https://go.dev/doc/effective_go#init

Originally posted by @cleroux in #17 (comment)

@wblakecaldwell
Copy link
Contributor

Ah, I didn't know you could have an init() function in each file.

Hah - yeah... ideally, we could do more validation here, and use that regex, but removing it is fine.

Good call

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

2 participants