首次设置go-swagger
我是新来的首次设置go-swagger,go,swagger,go-swagger,Go,Swagger,Go Swagger,我是新来的go lang和go swagger。我跟随并已使用命令安装了go-swagger: go get -u github.com/go-swagger/go-swagger/cmd/swagger 我可以看到,go-swagger文件夹是在中创建的 C:\Go\bin\src\github.com\go-swagger 现在,我将我的项目路径添加到$GOPATH: echo %GOPATH% C:\Go\bin;D:\Personal\Learning\GoLang\Project-
go lang
和go swagger
。我跟随并已使用命令安装了go-swagger
:
go get -u github.com/go-swagger/go-swagger/cmd/swagger
我可以看到,go-swagger
文件夹是在中创建的
C:\Go\bin\src\github.com\go-swagger
现在,我将我的项目路径添加到$GOPATH
:
echo %GOPATH%
C:\Go\bin;D:\Personal\Learning\GoLang\Project-2;D:\Personal\Learning\GoLang\swagger;
当我跑的时候
D:\Personal\Learning\GoLang\swagger>swagger ./swagger.yaml
'swagger' is not recognized as an internal or external command,
operable program or batch file.
我错过了什么?另外,如果您能为我推荐一些关于《大摇大摆》的好材料,我将不胜感激,因为我发现很难设置所有内容。没有多少博客可以帮我做helloworld
谢谢
更新1:
我试图设置GOBIN
,但没有成功:
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\;
更新2:
我也尝试了建议的绝对路径,但没有成功:
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.
更新3:
下面的命令对我有效,但似乎不是正确的方式:
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
安装swagger或任何其他Go二进制文件时,可执行文件位于
%GOBIN%
目录中。要调用swagger
可执行文件,您需要将%GOBIN%
目录添加到Windows路径
而不是GOPATH
或使用绝对路径调用它
D:\Personal\Learning\GoLang\swagger> C:\Go\bin\swagger ./swagger.yaml
要将go二进制文件添加到路径,请查看此处。当您执行
go get-somepackage/cmd/somecmd
时,可执行文件被添加到%GOBIN%
,而不是添加到%GOPATH%/bin
因此,您必须将此目录添加到您的路径:
echo %GOPATH%
// make sure you have a nonempty GOPATH
setx PATH %PATH%;%GOPATH%/bin
绝对路径没有运气:
D:\Personal\Learning\GoLang\swagger>C:\Go\bin\swagger验证https://raw.githubusercontent.com/swagger-api/swagger-spec/master/examples/v2.0/json/petstore-expanded.json “C:\Go\bin\swagger”不被识别为内部或外部命令、可操作程序或批处理文件。
.Hi,你解决这个问题了吗?