e2core icon indicating copy to clipboard operation
e2core copied to clipboard

Variable fqfn conflicts with imported package

Open javorszky opened this issue 3 years ago • 5 comments

In vkrouter

  • import: https://github.com/suborbital/atmo/blob/main/atmo/appsource/vkrouter.go#L11
  • variable: https://github.com/suborbital/atmo/blob/main/atmo/appsource/vkrouter.go#L73

This should not happen. Gets confusing, and go's shadow rules will make it hard to understand which one is being used.

javorszky avatar Feb 10 '22 10:02 javorszky

@javorszky Can you explain what should be done here? I want to take this issue

bishal7679 avatar Jul 06 '22 18:07 bishal7679

Should I remove the import package?

bishal7679 avatar Jul 06 '22 18:07 bishal7679

Hey @bishal7679 ! Thanks for your interest in this.

The ask is to rename the variable fqfn to something else, because in this particular case the issue is:

package appsource

import (
    "github.com/suborbital/atmo/fqfn"
)

func something() {
    fqfn := fqfn.FromParts(ident, namespace, fn, version)
    // ...
}

In the variable declaration (fqfn :=), it's essentially redeclaring what fqfn is. Previously it was how you referenced the package. After that line the package is unreachable because fqfn now means the variable.

The easiest solution is to find a different name for the variable, like runnableFQFN or something similar to differentiate between the local variable, and the package.

Let me know if you'd like more context around it 🙂

javorszky avatar Jul 07 '22 11:07 javorszky

@javorszky Thanks! I will make a PR for this issue

bishal7679 avatar Jul 07 '22 14:07 bishal7679

@javorszky Please review this PR

bishal7679 avatar Jul 08 '22 18:07 bishal7679