oapi-codegen icon indicating copy to clipboard operation
oapi-codegen copied to clipboard

Use `go install` instead of `go get` in the README example

Open migueleliasweb opened this issue 3 years ago • 5 comments

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?

migueleliasweb avatar Aug 26 '21 11:08 migueleliasweb

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.

davidovich avatar Aug 26 '21 12:08 davidovich

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 avatar Aug 26 '21 12:08 migueleliasweb

@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.

davidovich avatar Aug 26 '21 14:08 davidovich

@migueleliasweb Perhaps it's time to update the manual?

batazor avatar Mar 28 '22 06:03 batazor

Agreed, this has caused me some minor confusion today.

TarekAS avatar Apr 15 '22 11:04 TarekAS

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

nickajacks1 avatar Sep 23 '23 20:09 nickajacks1

Thanks folks, you're correct this was closed already

jamietanna avatar Jan 08 '24 09:01 jamietanna

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

Siddhartha90 avatar Mar 22 '24 22:03 Siddhartha90