LoginSignup
0
0

More than 1 year has passed since last update.

go getがつかえない。(oapi-codegenのインストール)

Posted at

Goのバイナリを取得する。

oapi-codegenを使おうと思って、go getしたら怒られました。

go 1.17以降はgo installを使わないとだめそうです。

$ go get github.com/deepmap/oapi-codegen/cmd/oapi-codegen@v1.8.2
go: go.mod file not found in current directory or any parent directory.
	'go get' is no longer supported outside a module.
	To build and install a command, use 'go install' with a version,
	like 'go install example.com/cmd@latest'
	For more information, see https://golang.org/doc/go-get-install-deprecation
	or run 'go help get' or 'go help install'.

メッセージの中にあるインフォメーションを見たら、
go modで使うものと、コマンドとして使うバイナリの両方で使うと混乱するから辞めたそうです。

こんな感じでコマンド実行してやればOK

$ go install github.com/deepmap/oapi-codegen/cmd/oapi-codegen@v1.8.2

oapi-codegenをコマンドに登録する

go install で手に入れたバイナリはどこにあるのか?

GOPATHに記載されたところに入っているらしい。

$ go env | grep PATH
GOPATH="/Users/[Username]/go"

$ ls /Users/[Username]/go/bin
oapi-codegen
.bash_profileの編集
.bash_profile
if [ -f ~/.bashrc ] ; then
. ~/.bashrc
fi

export PATH=$HOME/.nodebrew/current/bin:$PATH

# serverless (node)
export PATH="$HOME/code/sls/node_modules/.bin/:$PATH"
# awscli
export PATH="$HOME/Library/Python/3.7/bin/:$PATH"
# go
export PATH="$HOME/go/bin:$PATH"   ##←これを追加。

source .bash_profileでファイルを読み直したらコマンドが実行できるようになります。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0