LoginSignup
5
3

More than 5 years have passed since last update.

Atomでgo run出来るようにatom-runner.coffeeを修正

Last updated at Posted at 2017-09-15

VSCodeよりAtomのほうがQiita上で情報が多かった。
VSCode用の設定手順はこちら

ubuntu 17.04にて作業

Atomのインストール

sudo dpkg -i atom-amd64.deb

sudo apt install -y golang-go
~/.bashrc
export GOPATH=$HOME/go/

Atom用追加パッケージインストール

apmパッケージ
apm install go-plus
apm install godef

Atom上でcontrol-,を押すのも良いです。

スクリーンショット_2017-09-16_04-40-14.png

hello.go の編集

hello.go
package main

import "fmt"

func main() {
    fmt.Println("Hello world!")
}

としたところ、画面右に追加機能をインストールするか確認が出た。
「Yes」を全て押す。

スクリーンショット_2017-09-16_04-42-26.png

VSCode向けには手で取得する必要があったdelve(デバッグに使われる)も自動で取得してくれる。

スクリーンショット_2017-09-16_04-46-58.png

Atom-runnerの修正

スクリーンショット_2017-09-16_05-03-25.png

atom-runner を入れるとAlt-Shift-Rで go runが出来るらしいが、
go run: no go files listedと表示され実行してくれない。

err1.png

152行目に以下修正
参考: http://givememorelove.blogspot.jp/2016/06/golang-ide.html

~/.atom/packages/atom-runner/lib/atom-runner.coffee
    args = []
    if editor.getPath()
      editor.save()
      args.push(editor.getPath()) if !selection
    splitCmd = cmd.split(/\s+/)
    if splitCmd.length > 1
      cmd = splitCmd[0]
      args = splitCmd.slice(1).concat(args)
+   if editor.getPath()
+     editor.save()
+     args.push(editor.getPath())
    try
      dir = atom.project.getPaths()[0] || '.'
      try
        if not fs.statSync(dir).isDirectory()
          throw new Error("Bad dir")

ok.png

go-plus 下枠の移動

  • 矢印押せば右/下に移動されるのが気に入った。

スクリーンショット_2017-09-16_04-51-00.png
スクリーンショット_2017-09-16_04-51-20.png

5
3
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
5
3