0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

go get と go install

Last updated at Posted at 2025-04-26

比較表

比較項目 go get go install
主な用途 パッケージのダウンロード+go.modの更新 実行ファイルのビルド&インストール
go.modに影響する? ✅ する(依存管理) ❌ しない(ビルド&インストールのみ)
コンパイルされる? 必ずではない(主にパッケージ取得) ✅ バイナリにビルドされる
主な使い方 - プロジェクトにパッケージを追加
- バージョン指定・更新
- CLIツールをインストール
- 他人のアプリをインストール
適しているシーン プロジェクト開発中の依存追加 CLIツールやアプリケーションのインストール

具体例

go get を使う(依存管理)

go get github.com/spf13/cobra
  • パッケージをダウンロード&インストール
  • go.modに依存を追加
  • go.sumにチェックサム情報を追加
  • 以後、プロジェクトのビルド・実行時に利用可能

go install を使う(ツールインストール)

go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest
  • ソースコードをダウンロードしてビルド
  • バイナリ(実行ファイル)を生成
  • $GOPATH/bin または $HOME/go/bin にインストール
  • go.modgo.sum は変更されない

技術メモ

  • go get は基本的にプロジェクト内部の依存管理用コマンド
  • go install開発環境向けツールインストール用コマンド

Go 1.17以降、CLIツールのインストールは go install を推奨
go getによるインストールは非推奨になった。

まとめ

go get go install
パッケージ管理?
ツールインストール? ❌(1.17以降非推奨)
主な目的 プロジェクト依存を追加 バイナリをローカルにインストール
go.modに影響?

参考リンク

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?