-
Notifications
You must be signed in to change notification settings - Fork 573
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
can not run multi file project #555
Comments
Hi, That's a limitation of go itself, not the plugin, see below (I'm using zsh in case you wonder why my console output looks like that): main() is in untitled6.go, xxx() is in demo.go florin@XYZ [10:29:29] [/var/www/personal/untitled6]
-> % /usr/lib/go/bin/go run /var/www/personal/untitled6/src/untitled6.go
# command-line-arguments
src/untitled6.go:7: undefined: xxx
florin@XYZ [10:29:31] [/var/www/personal/untitled6]
-> % /usr/lib/go/bin/go run src/untitled6.go
# command-line-arguments
src/untitled6.go:7: undefined: xxx
florin@XYZ [10:29:45] [/var/www/personal/untitled6]
-> % go run src/untitled6.go
# command-line-arguments
src/untitled6.go:7: undefined: xxx
florin@XYZ [10:29:53] [/var/www/personal/untitled6]
-> % go run
go run: no go files listed
florin@XYZ [10:29:56] [/var/www/personal/untitled6]
-> % cd src
florin@XYZ [10:30:14] [/var/www/personal/untitled6/src]
-> % go run
go run: no go files listed
florin@XYZ [10:30:16] [/var/www/personal/untitled6/src]
-> % go run ./...
go run: no go files listed
florin@XYZ [10:30:21] [/var/www/personal/untitled6/src]
-> % go run untitled6.go
# command-line-arguments
./untitled6.go:7: undefined: xxx
If you are able to run this from the command line in and it's not working from the plugin then it should be a problem. |
wow, quick reply... ;-) That was what I first thought, then I stumbled on this thread: https://groups.google.com/forum/#!topic/golang-nuts/dP9SKOsG0AU where Julian Phillips states:
I tried it and when I run
it runs fine. But, indeed, you have to mention both files before it works. Would it not be a little limiting if everything needs to be in the same go file? Or am I missing something else here? (but then, I am still exploring go...) |
Yeah, well, I'm waiting for a server to configure itself ;) The statement from Julian is true but in order for it to work you either
|
ok, learning here... I do not exactly know what cmd is fired off when I hit run, but I could imagine it could be turned into a "go run *.go" equivalent... I chew on it a little, while waiting for my server to configure itself (will take another hour or so ;-) |
did some chewing... Indeed this limitation only applies to the main package. So this probably only confuses the newbee go-er. I would say the best way is to do the "*go run .go" equivalent when you see multiple files in the main package. This will not have any downsides when, as you describe is your standard way, you only have a single file in your main package. Easy change (right?), less confusion. After all it is worthwhile that newbee's stay on board! I leave it up to the plugin developer to judge this enhancement request. Anyway, thanks for writing the plugin! Tom |
I think it could be added, as an option, just like the ones we have for running tests, shouldn't be a problem. I'll close the issue and open a new one for the feature request. |
As for the command(s) that are run when you trigger a certain go action in the IDE, it should always be the first line of output in the console / window / tool panel :) |
There a non so subtle thing at play here. You can imagine having two completely different main programs in the same folder (unrelated to each other). But if they are in the same folder they will have the same package name. This will confuse everyone when you try To be more clear imagine the following scenario:
package main
func main() {
print("i'm the first binary");
} `src/binary2.go`
package main
func main() {
print("i'm the second binary");
} What happens if you do a For now the current behaviour will do. Maybe later on we can add better analysis and do an automatic run (with the proper file list). |
I thought about that scenario to: mutliple 'main' entries for the same code base. I guess you could 'go run' the main file plus all files NOT containing a main(). Only a heuristic solution I agree, someone might have two non-main() files each belonging to a separate main() containing file and these non-main() files could contain the same func's. My proposed strategy above would result in a redeclaration error probably. But then this is not so high prio I agree, it just confused me and made me put a growing amount of code in my first real go file :-), learning, learning... Put it on the list, others can find this discussion now, that will probably help enough for now. Keep up the good work! |
tentatively targeted for 1.0.0 |
Hi @dlsniper (or whoever I've to tag ;)) I know, how this sounds, but this issue is pushed forward since the beginning of 2014. It would be nice Right now I help myself by just leaving the "File" field empty. The IDE constantly complains about an invalid run configuration and when I run it, I have to "Continue anyway", but after that it works :) However, I'd really appreciate, if this actually quite common setup would be supported out of the box. Thanks |
Hi @kingcrunch. I do understand the frustration on the matter so let me give you a bit of context. Have you tried the If this doesn't help unfortunately there's not much I can do right now (and I guess others are busy as well) so the best way to have this faster would be to help out with some of the issues in the plugin (maybe even this one). I know it's not ideal but unfortunately that's the state of things. Thank you for your understanding and Thank you! for not just +1-ing this. Kind regards, |
@kingcrunch Thanks, i make Run Kind File and File is . it's work. thanks for you |
How to set/configure "Run | Edit Configurations | + | Go Application" this on visual studio code editor. |
Can not run a func in another file.
When I have one go file I can run fine.
When I have two go files (main using a func in the other), I get an "undefined:" error.
repro:
My 'internals':
The text was updated successfully, but these errors were encountered: