Home >Backend Development >Golang >zsh: command not found: swag
php editor Baicao introduces you to a practical command line tool: zsh. However, sometimes you may encounter the error message "zsh: command not found: swag" when using zsh. This error message means that zsh cannot find the command named "swag". In this article, we will help you solve this problem so that you can use zsh and related commands smoothly.
I'm trying to use gin-swagger
to set up OpenAPI documentation on several APIs written in gin
. When I install the package in the project path via go install github.com/swaggo/swag/cmd/swag@latest
, I cannot run swag init
!
swag init
Output:
zsh: command not found: swag
This is the repository link.
I realized that the problem is related to GOPATH
!
I browsed the ~/go/bin
path and saw swag
, indicating it was installed correctly. Then, I open the .zshrc
file to check the variables as follows:
GOROOT=/usr/local/go GOPATH=~/.go PATH=$PATH:$GOROOT/bin:$GOPATH/bin
Next, I corrected GOPATH
from GOPATH=~/.go
to GOPATH=~/go
to fix the problem.
Now, swag init
can work.
The above is the detailed content of zsh: command not found: swag. For more information, please follow other related articles on the PHP Chinese website!