|
Karaziox |
at Feb 13, 2015 at 8:23 pm
|
⇧ |
| |
Of course, building a single file is what go run is good at. But usually
thoses files are not the ones taking multiple seconds build times. If you
have a project I assume you have split this project in multiples files,
with packages and all. The fact that go install doesn't run the binary is a
simple matter of "go install && $GOPATH/bin/mybinary" on Linux, "go install
&& %GOPATH/bin/mybin.exe" on Windows etc.
As I understand, you are using the single file for testing a non main
package? I would suggest the use of the test facilities of go so you get
reuseable tests after that. That would remove the need for go run.
See
http://golang.org/doc/code.html#Testingand
http://golang.org/pkg/testing/ for more details on that.
On Friday, February 13, 2015 at 3:14:58 PM UTC-5, bronze man wrote:I got your point.
The reason is that go install can not build a single golang file,and go
install can not run the compiled files.
So I can write my own version of go run to get better performance.
I can put my single golang file in to a temporary package,and go install
that package,and run the compiled files.
On Saturday, February 14, 2015 at 4:05:45 AM UTC+8, kara...@gmail.com
wrote:
Build and run don't do that by design. Run shouldn't modify anything in
your workspace. Build should only produce the executable you asked for. If
you want the benefits of go install, I'd say you should use go install. Are
there any reasons why you aren't?
On Friday, February 13, 2015 at 3:01:58 PM UTC-5, bronze man wrote:
Go run my project need 3s~ in my local computer, and need 7s~ in a one
core vps without pkg cache.
But go install only need 0.2s in my local computer with pkg cache.
It takes 1.071s to go run my project with pkg cache.
It takes 3.261s to go run my project without pkg cache.
It takes 0.148s to go install my project with pkg cache.
It takes 0.017s to run the compiled binary file.
If I use go run with pkg cache,some changes I just made is ignored.
I think there is a huge performance improvement in go run and go build
command.
--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
For more options, visit
https://groups.google.com/d/optout.