首页 > 解决方案 > Go gqlgen command not found 发生

问题描述

我正在学习 Go 和 GraphQL。
我正在构建一个 Go 环境,但是当我运行gqlgen init命令时,我在终端中收到了一条消息bash: gqlgen: command not found

当我运行 gqlgen init 命令时,终端中出现了一条消息。

执行的命令

$ mkdir with-apollo-api
$ cd with-apollo-api
$ go mod init github.com/yuuu/with-apollo-api
$ go get github.com/99designs/gqlgen
$ go get github.com/rs/cors

# Generate graph/schema.graphqls with gqlgen
$ gqlgen init

标签: gographql

解决方案


您没有将 gqlgen 作为可执行文件提供,而是作为项目中的依赖项提供。

安装可执行文件运行

go install github.com/99designs/gqlgen

它将安装可执行文件,现在您可以使用它了

gqlgen init

推荐阅读