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 8 years ago
- Comments: 26 (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@jasonhancock $HOME/go/bin/swag init
Worked for me
@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$PATHIn my case, I added these two lines to my environment variable(MacOS):
Open a new terminal, then execute the Swaggo command.
Followed the recommendation and still “zsh: command not found: swag”
I searched for the same issue and came in.
I started tracking down the cause myself.
The conclusion is that the build failed because the go.mod, go.sum file did not have the right to update.
The fundamental solution is to change the permissions of some files in Makefile to 755, or adjust the permissions as follows.
My environment is as follows.
Go Preferences are as follows.
The solution is as follows.
Works thanks!!