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

"main redeclared in this block" #7

Closed
hickford opened this issue Aug 23, 2023 · 2 comments
Closed

"main redeclared in this block" #7

hickford opened this issue Aug 23, 2023 · 2 comments

Comments

@hickford
Copy link

I tried to build this library go build ./... and got error:

# github.com/seancfoley/ipaddress-go/ipaddr/cmd
ipaddr/cmd/test.go:25:6: main redeclared in this block
        ipaddr/cmd/main.go:37:6: other declaration of main
@seancfoley
Copy link
Owner

I've taken a look at this issue and your associated PR.

I haven't quite made up my mind, but it's likely that I will not merge your associated PR as the solution, which moves the test.go main function into the ipaddr/test package, because the test package is meant to contain code for that package only and not a second package. AFAIK, the usual go convention is to avoid having a go "main" package source file in the same folder as other packages, so as not to mix the library or test code with application code to create binaries.

I've looked into how the go community usually handles this situation of having multiple binaries, and while there are not a lot of resources out there addressing this, I have found more than one resource suggesting that each binary should be in its own subfolder of the cmd folder, so I'm likely gonna do that, which should address this.

@seancfoley
Copy link
Owner

fixed in version 1.5.5

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

Successfully merging a pull request may close this issue.

2 participants