duanfengtuo6012 2019-06-02 09:51
浏览 60

首次设置摇摆

I am new to go-lang and so to go-swagger. I am following a blog and have installed go-swagger with command :

go get -u github.com/go-swagger/go-swagger/cmd/swagger

I can see that the go-swagger folder is created in

C:\Go\bin\src\github.com\go-swagger

Now, I added my project path to $GOPATH :

echo %GOPATH%
C:\Go\bin;D:\Personal\Learning\GoLang\Project-2;D:\Personal\Learning\GoLang\swagger;

When I run

D:\Personal\Learning\GoLang\swagger>swagger ./swagger.yaml
'swagger' is not recognized as an internal or external command,
operable program or batch file.

What am I missing ? Also, I would be grateful if you can suggest me some good material for go-swagger as I am finding it very difficult to setup everything. There arent much blogs which can help me do HELLO WORLD kinda setup

Thanks

Update 1:

I tried to set GOBIN but no luck with that:

D:\Personal\Learning\GoLang\swagger>swagger validate https://raw.githubusercontent.com/swagger-api/swagger-spec/master/examples/v2.0/json/petstore-expanded.json
'swagger' is not recognized as an internal or external command,
operable program or batch file.

D:\Personal\Learning\GoLang\swagger>echo %GOBIN%
C:\Go\bin\;

Update 2:

I tried absolute path as suggested as well, but no luck:

D:\Personal\Learning\GoLang\swagger>C:\Go\bin\swagger validate https://raw.githubusercontent.com/swagger-api/swagger-spec/master/examples/v2.0/json/petstore-expanded.json
'C:\Go\bin\swagger' is not recognized as an internal or external command,
operable program or batch file.

Update 3:

Below command worked for me but it doesn't seem to be proper way:

go run C:\Go\bin\src\github.com\go-swagger\go-swagger\cmd\swagger\swagger.go  validate https://raw.githubusercontent.com/swagger-api/swagger-spec/master/examples/v2.0/json/petstore-expanded.json
  • 写回答

1条回答 默认 最新

  • douliexu5623 2019-06-02 12:49
    关注

    When you install swagger or any other Go binary, the executable is on the %GOBIN% directory. To call the swagger executable you need to add the %GOBIN% directory to the Windows Path not the GOPATH or call it using the absolute path.

    D:\Personal\Learning\GoLang\swagger> C:\Go\bin\swagger ./swagger.yaml
    

    To add the go binaries to the path look here https://stackoverflow.com/a/9546345/1199408.

    评论

报告相同问题?

悬赏问题

  • ¥15 c程序不知道为什么得不到结果
  • ¥40 复杂的限制性的商函数处理
  • ¥15 程序不包含适用于入口点的静态Main方法
  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置