2

I got the following output upon running test in my golang project (truncated. see the complete output down below) :

import path contains backslash; use slash: "gitlab.com\\group-name\\project-name/vendor/..."

project-name is the name of the project I'm working on. The project itself run smoothly, only the test was error.

I have no idea how such an import path (containing \\) generated, who could be responsible for generating that import (is it go test?), and how should I do about fixing it?

I tried to run the test after upgrading go version from 1.6.x to 1.8, if this matter.


environment :

  • go version go1.8 windows/amd64
  • goconvey v1.6.2
  • glide package manager

command :

go test api_test.go

output :

# command-line-arguments
.\api_test.go:6: import path contains backslash; use slash: "gitlab.com\\group-name\\project-name/vendor/github.com/smartystreets/assertions"
.\api_test.go:6: cannot import "gitlab.com\\group-name\\project-name/vendor/github.com/smartystreets/goconvey/convey" 
    due to version skew - reinstall package (bad package path "gitlab.com\\group-name\\project-name/vendor/github.com/smartystreets/assertions" for package assertions)
FAIL    command-line-arguments [build failed]

api_test.go : (just a random sample of goconvey for now, and still produce the error)

package test

import (
    "testing"

    . "github.com/smartystreets/goconvey/convey"
)

func TestIntegerStuff(t *testing.T) {
    Convey("Given some integer with a starting value", t, func() {
        x := 1

        Convey("When the integer is incremented", func() {
            x++

            Convey("The value should be greater by one", func() {
                So(x, ShouldEqual, 2)
            })
        })
    })
}
har07
  • 88,338
  • 12
  • 84
  • 137
  • Did you check the editor encoding? – Marcelo Salazar Mar 11 '17 at 14:43
  • I'm using visual studio code. I doubt this has something to do with the source code file encoding though.. – har07 Mar 12 '17 at 09:17
  • So far I can get around this by using [goconvey's web UI](https://github.com/smartystreets/goconvey/wiki/Execution#auto-test-and-web-ui) .. – har07 Mar 12 '17 at 09:18
  • 1
    Running test on the entire folder (just `go test` without passing file name) also worked apparently... – har07 Mar 13 '17 at 02:33
  • 2
    Just want to mention that I'm having the same issue. go test without passing the file name works, but go test mypack_test.go fails with "import path contains backslash; use slash:" seems a go test issue as I checked all files and there are no backslashes in any – Hace Apr 20 '17 at 09:16

0 Answers0