I create one simple test, which when run go test runs for a very long time. Seconds 10, although writing on the results of 0.025s. Maybe because every time there is a build?

 package main

 import (
     "testing"
     "github.com/stretchr/testify/assert"
 )


 func TestGetModelById (t * testing.T) {
     assert.Equal (t, 1, 1)
 }

    1 answer 1

    That is why (and most likely it happens in Windows, right?).

    You can try to improve the situation somewhat, according to this part of the documentation go help test :

    The test files "_test" will be a test binary.

    Simply put, you can make all your tests a separate package (for example, all_test ) or packages (for example, for the internal package foo make the package foo_test ) and make it go install . The next run, go test ./... , will "pick up" these packages from $GOPATH/pkg without compiling.

    On the other hand, the synthesis of a temporary binary will be performed all the same for testing and linking these packages to it. Therefore, if there are few tests, this method may not improve the situation.

    Therefore, perhaps the only way is to speed up the build (put $GOPATH on an SSD, for example) or, if possible, use something more basic for basic development (a system based on GNU / Linux or * BSD or Mac OS), and on Windows "final" testing before building for a binary release.

    • go 1.6, ubuntu 14.04, SSD, use glide as a package manager, but after go install everything stops working (go test) and you have to delete the pkg folder - Oleg Khamov