17
9

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Goでディレクトリ&ファイル名を指定してビルド

Posted at

背景

go buildしたらワーキングディレクトリ直下に実行ファイルが生成された
⇒ここじゃやだ、毎回移動するのめんどい

ってのが背景です。
調べた・・・

「-o」ってオプションでできそうです。

やってみる

コチラのプロジェクトを使ってやってみます。

# 出力先はsrcと同階層のbinディレクトリの下
$ go build -o ../../bin/v1

# treeで見てみる
$ cd /tmp/vendor-test
$ tree
.
├── bin
│   └── v1
└── src
    └── v1
        ├── glide.lock
        ├── glide.yaml
        ├── main.go

できてる!
いいね!

だが待て・・・動かなければ意味がない

# 移動
$ cd /tmp/vendor-test/bin

# 実行
$ ./v1
2016/02/11 14:31:30.470609 Starting Goji on [::]:8000

起動できてる!

17
9
1

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
17
9

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?