Golang Test Case


  While running  my test case it  s not working it show error,
_**import path contains backslash; use slash in golang.org/x/net/context**_ ,  i do not know how i will solving error please can any help  me,

I believe you just have to replace \ with / in your imports

This looks weird. Are you using go test or go test <filename>? (See the last two comments in this related issue that observe the issue with go test <filename> only.)

Does this only happen with go test (versus go run, go build, etc)?

Did you check all of the involved files for backslashes (not only the one that occurs in the error message)?

In case you use an older Go version, it might be worth trying the latest one.

Also, if you have access to a Linux machine, verify if the issue replicates there. (Assuming you currently use a Windows machine.)

      **go test <filename>**  if i run my application **go run main.go**, its fine while running in the test cases fail

Did you check all involved import paths, especially those that the test files import? Maybe the error message is imprecise and the erroneous import path is not golang.org/x/net/context but rather some other import path used for the test.

Are you using the latest Go version?

Do you observe this on a specific operating system only (esp. Windows comes to mind here)?

i m using 1.9 version And operating system windows 8.1

What import paths do you have in your *_test.go files that are not in the other *.go files?

I need to import .go file also

Thank you

I am not sure I understand your reply. My question aimed at finding those import statements that are only used by your _test.go files but not by the .go files to be tested. The point is that the error occurs only during test, so as a first step I would narrow down the list of possible import statements to those that are used only in the _test.go files.

I have solved that issue problem is github.com/antigloss/go/logger package,
Thank you so much for responding

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.