Golang-运行需要很长时间才能执行

I have a little problem, where every time I run 'go run >filename<' after making changes to my problem, it takes many seconds to start executing.

I tried it with a simple program like this:

package main

import "fmt"

func main() {
    fmt.Println("Output")
}

And it took about 18 seconds to print out the result.

And ideas on what could cause this problem?

I am on windows by the way.

Thanks in Advance

$ go run command always complies the code into a temporary binary file and then executes it, every time it is run.

To go around this you could do $ go build -i main.go which will compile dependencies separately as .a files (i'm guessing this is the part that takes the longest because it takes time to build the dependencies) and then execute it with $ ./main, and each execution should be faster that $ go run.

You could also run a $ go get -u ./... to update all your deps and building with the -x flag will show you if the toolchain is finding incompatible versions.

$ go install builds the command in a temporary directory then moves it to $GOPATH/bin so you can execute it without the path $ main.

The last two commands require a rebuild/reinstall if the code has changes.