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

x/tools/gopls: consider supporting script directories with multiple programs #41206

Open
stamblerre opened this issue Sep 3, 2020 · 3 comments
Open

Comments

@stamblerre
Copy link
Contributor

@stamblerre stamblerre commented Sep 3, 2020

Currently, gopls only supports directories with a single main, no matter whether you open a single file or a directory. For single files, we load the entire directory, no matter what. Some users create directories with multiple mains, which they run using go run file.go. Should gopls support such directories? If so, how should it work?

@bcmills
Copy link
Member

@bcmills bcmills commented Sep 4, 2020

Most single files intended for use with go run should be tagged // +build ignore or similar, and they necessarily each declare a func main. Perhaps you could use unusual build constraints plus func main as a heuristic for which mode to use?

@myitcv
Copy link
Member

@myitcv myitcv commented Sep 4, 2020

Previous discussion: #33595

@myitcv
Copy link
Member

@myitcv myitcv commented Sep 4, 2020

Looking at the arguments against this, if someone can come up with a good enough name for the file that contains the build-ignore main package, they can use that name for a subdirectory ./internal/$NAME thereby obviating the need for any kind of single-file support in gopls.

The counter argument to this is that there is lots of preexisting code out there that does following the single-file approach.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
4 participants
You can’t perform that action at this time.