oapi-codegen
oapi-codegen copied to clipboard
Use `go install` instead of `go get` in the README example
Hi oapi-codegen team,
If we use go install github.com/deepmap/oapi-codegen/cmd/[email protected]
instead of the current example go get github.com/deepmap/oapi-codegen/cmd/oapi-codegen
, Go doesn't add oapi-codegen
as an indirect dependency of the repo. This makes the go.mod
cleaner overall.
Would it make sense to change this?
go install appeared only in go 1.16, so I believe that the minimum supported version of oapi-codegen would have to be bumped.
That being said, I really agree that go install is a better alternative.
I just noticed the go.mod
is still mentioning 1.14
=/.
It could be worth at least a mention in the docs something like:
If you're using Go 1.16+ a cleaner installation (without touching your
go.mod
) can be achieved by running:go install github.com/deepmap/oapi-codegen/cmd/[email protected]
@migueleliasweb The version in the go.mod
file is not the culprit, as it states the minimum version of go (feature wise) needed to compile the code (and warn if a compile error occurs that it might be because of the required go version). The maintainer's intended audience go version is what is important here as not all users will have the go install command behave in expected fashion.
As you mention, a conditional advice depending on the go version in the readme seems to be the only way to help users until the last supported version of this project is upgraded to 1.16. I believe @deepmap-marcinr is working on a v2, and is targeting 1.16.
@migueleliasweb Perhaps it's time to update the manual?
Agreed, this has caused me some minor confusion today.
oapi-codegen -package petstore petstore-expanded.yaml > petstore.gen.go
error loading swagger spec : open petstore-expanded.yaml: no such file or directory
Fixed by #588 , this may be closed
Thanks folks, you're correct this was closed already
If anyone stumbles upon this via google, the conventional way now to install this is:
go install github.com/deepmap/oapi-codegen/cmd/oapi-codegen@latest