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:

  1. Execute go get github.com/swaggo/swag/cmd/swag on the command line
  2. See the following error:
go get github.com/swaggo/swag/cmd/swag
# github.com/ghodss/yaml
./yaml.go:102:28: undefined: yaml.UnmarshalStrict
  1. Try to run swag
  2. 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

@pei0804

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Comments: 25 (4 by maintainers)

Most upvoted comments

Path variable must be set: After running go get -v -u github.com/swaggo/swag/cmd/swag Please check /usr/local/go/bin or $HOME/go/bin where those swag executable is present.

Make sure you have that PATH in /etc/profile or $HOME/.profile

e.g. export PATH=$PATH:$HOME/go/bin

@jasonhancock, please use export PATH=$(go env GOPATH)/bin:$PATH

use 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 -u flag 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/swag or add $HOME/go/bin to your $PATH, or copy $HOME/go/bin/swag to 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):

export GOPATH=/Users/[user-folder-name]/go
export PATH=$GOPATH/bin:$PATH

Open a new terminal, then execute the Swaggo command.

go install github.com/swaggo/swag/cmd/swag@latest

Works thanks!!

Followed the recommendation and still “zsh: command not found: swag”