go-swagger: Generate spec does not work with Go Modules
Problem statement
the swagger CLI tool does not work correctly when the target repository is a Go 1.11 Module. The tool should not use GOPATH/src to resolve dependencies, and instead use the GOPATH/pkg/mod The possible failure cases I have discovered are as follows:
- required dependency is not in GOPATH
- results in the CLI tool saying it cannot find dependency
- dependency in GOPATH is not the same as declared in MODULE
- individual types/functions/packages fail, rather than the dependency as a whole
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Reactions: 28
- Comments: 19 (4 by maintainers)
I had success in my module-based project by doing what @bserdar did and adding the following twist:
Guys, is there any progress with modules? If no, how could I get around this issue?
this has been resolved,see here: https://github.com/go-swagger/go-swagger/issues/1906
Ugly workaround: I have my source tree outside GOPATH, and a symlink to it under GOPATH. I use the version under GOPATH to build swagger specs, and the original for real work.
I don’t think so. It will work if the project you are running on is in the GOPATH and you have GO111MODULE=off. However, if you have GO111MODULE=on or your project is not in the GOPATH it will fail. It will continue to fail until they use a different library for parsing go code.
On Wed, Jan 23, 2019 at 8:41 AM Amireza Fatemi notifications@github.com wrote: