Skip to content

c-zhenhao/go-gin-swagger-tutorial

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

following tutorial from logrocket

https://blog.logrocket.com/documenting-go-web-apis-with-swag/

Demo

  • Create and Read
Create_Read.mov
  • Update and Delete
Update_Delete.mov

issues faced

  • Go wasn't setup properly, so swag init didnt work

    • issue
      • GOBIN is empty
        • to check, go env or go env GOBIN - it will be empty
    • fixes i did
      • export GOBIN=$(go env GOPATH)/bin
      • this will set the current project(?, i think) to use the go bin folder
        • in my case its /Users/zhenhaoc/go/bin
      • afterwards go install github.com/swaggo/swag/cmd/swag <-- this will install swag into the go bin folder
    • source swaggo/swag#197 (comment) tyvm!~
  • main.go doesn't recognise swaggerFiles

    • issue
      • swaggerFiles "github.com/swaggo/files" keeps getting deleted on save by gopls
    • fixes
      • save the main.go without the line first (lol)
      • go get -u github.com/swaggo/files
      • then add it back in lol
      • seems to resolve it?
  • trying to re-order the routes doesnt work

    • issue
      • reordering the routes doesnt do anything
      • apparently the operations needs to be sorted/defined
      • need to look into how to do it
    • fixes
      • try another tutorial lol

About

go swagger tutorial

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages