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

zsh: command not found: swag

WBOY
Release: 2024-02-09 08:45:09
forward
1127 people have browsed it

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
Copy after login

Output:

zsh: command not found: swag
Copy after login
<小时/>

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
Copy after login

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!

source:stackoverflow.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template