Remove GOPATH (breaking change for using wag outside of GOPATH) #423
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is a merge request into the
v9.x
dev branch, currently even withmaster
but this will be where it starts to diverge.This PR is split into two commits.
The first commit is fairly mechanical: the idea is to reduce any remaining uses of GOPATH to the top-level, rather than using it deeper into the generator. The deeper usage of GOPATH that needed to be eliminated is in the
Generator
type in ourswagger
package. Previously this struct was receiving a path that was interpreted relative to GOPATH, now it's receiving an absolute path.In addition, I tried to simplify a bit by removing the number of
*path
variables. For example, in practice,modelsPath
was always{basePath}/models
; yet at the same time, the assumption that models lived in that directory was hardcoded in other places, so that if we just changedmodelsPath
, things would actually break.The second commit included a BREAKING CHANGE⚠️ 🔴 . This change was necessary to completely remove any dependence on GOPATH. Now the -output-path, if it's relative, is interpreted relative to current working directory. Previously, we would combine GOPATH with the module path in go.mod to guesstimate where to interpret it relative to.
This change is only sorta kinda breaking. If you were using
wag
inside${GOPATH}/src/path/to/package
already, nothing changes for you. Using wag outside such a directory... was already kinda broken. So while this is a breaking change, it's really fixing things. Previously, if I ranwag
in~/someDir
(i.e. outside of GOPATH),wag
would put the generated files inside of GOPATH, which is basically never what you want.Testing
Running
make test
not only passes the test, it also results in literally zero diffs inside samples, meaning that this is not changing anything in the use cases we are about.I also tried running wag outside of GOPATH... and it actually worked! It produced generated files inside the working directory instead of randomly far away.
Merge Checklist
make build
make generate
/VERSION
file - N/A, not trying to release yet.Closes #328