Collectives™ on Stack Overflow
Find centralized, trusted content and collaborate around the technologies you use most.
Learn more about Collectives
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
Learn more about Teams
I am trying to setup swagger for gin-gonic on windows.
Documentation of swaggo states that I should run:
go get -u github.com/swaggo/swag/cmd/swag
After installation I should be able to run swag init
from within the root of my project where I have main.go
, but the cmdlet states the following:
swag : The term 'swag' is not recognized as the name of a cmdlet, function, script file, or operable program. Check
the spelling of the name, or if a path was included, verify that the path is correct and try again.
At line:1 char:1
+ swag
+ ~~~~
+ CategoryInfo : ObjectNotFound: (swag:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
How can I add swag to PATH or how should I proceed from here?
Ps, i followed documentation from here
Update: So I did a clean installation of Go on another PC, followed by go get -u github.com/swaggo/swag/cmd/swag
and swag
runs right of the bat. Earlier I followed this tutorial and I might have accidentally messed up my $GOPATH
on the original PC.
Follow the below article to get swagger on gin
https://levelup.gitconnected.com/tutorial-generate-swagger-specification-and-swaggerui-for-gin-go-web-framework-9f0c038483b5
If you face any issues to get swag use below command to get swag on windows
go install github.com/swaggo/swag/cmd/swag
-https://libraries.io/go/github.com%2Fswaggo%2Fhttp-swagger
-go to your file path them install the following packages
1-go get github.com/swaggo/http-swagger
2-Download Swag for Go by using:
-go get github.com/swaggo/swag/cmd/swag
3-Run the Swag in your Go project root folder which contains main.go file, Swag will parse comments and generate required files(docs folder and docs/doc.go).
-swag init
4.Download http-swagger by using:
- go get -u github.com/swaggo/http-swagger
5-Run it, and browser to
-http://localhost:1323/swagger/index.html
, you can see Swagger 2.0 Api documents.
And to know the path you are working on type
-go env
then look for GOPATH=
there you will see your path
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.