Home >Backend Development >Golang >zsh: command not found: swag

zsh: command not found: swag

WBOY
WBOYforward
2024-02-09 08:45:091183browse

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.

Question content

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.

Solution

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!

Statement:
This article is reproduced at:stackoverflow.com. If there is any infringement, please contact admin@php.cn delete