swag: Can't install swag
Describe the bug I’m unable to install swag given the instructions on the README
To Reproduce Steps to reproduce the behavior:
- Execute
go get github.com/swaggo/swag/cmd/swagon the command line - See the following error:
go get github.com/swaggo/swag/cmd/swag
# github.com/ghodss/yaml
./yaml.go:102:28: undefined: yaml.UnmarshalStrict
- Try to run
swag - See the following error:
zsh: command not found: swag
Expected behavior
swag should be installed properly on my machine.
Desktop (please complete the following information):
- OS: macOS High Sierra
- Version: go version go1.10.3 darwin/amd64
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Comments: 25 (4 by maintainers)
Path variable must be set: After running
go get -v -u github.com/swaggo/swag/cmd/swagPlease check/usr/local/go/binor$HOME/go/binwhere those swag executable is present.Make sure you have that PATH in
/etc/profileor$HOME/.profilee.g. export PATH=$PATH:$HOME/go/bin
@jasonhancock, please use
export PATH=$(go env GOPATH)/bin:$PATHuse this command please:
go install github.com/swaggo/swag/cmd/swag@latest@jdiedrick Looks like you have older github.com/ghodss/yaml version at local, please add the
-uflag when getting swag like:go get -u github.com/swaggo/swag/cmd/swag@hariraogotit from the directory with your main.go, run
$HOME/go/bin/swagor add$HOME/go/binto your$PATH, or copy$HOME/go/bin/swagto a directory in your$PATH@jasonhancock $HOME/go/bin/swag init
Worked for me
In my case, I added these two lines to my environment variable(MacOS):
Open a new terminal, then execute the Swaggo command.
Works thanks!!
Followed the recommendation and still “zsh: command not found: swag”