douao3636 2014-12-29 19:27
浏览 84
已采纳

生成后删除.a文件-GoLang

I'm currently using fresh to rebuild and restart the webserver on every change of any of the source files in my project.

It works ok. However, after some time files are created at pkg directory. This causes the refresh does not happens anymore, and the reason is instead of getting the source files (.go files) to build the binary, it gets the .a files. How can I avoid this feature?

Adding information:

File: runner.conf at the same level of main.go

root: .
tmp_path: ./tmp
build_name: bin/app.bin
build_log: runner-build-errors.log
valid_ext: .go, .tpl, .tmpl, .html
build_delay: 600
colors: 1
log_color_main: cyan
log_color_build: yellow
log_color_runner: green
log_color_watcher: magenta
log_color_app:
ignore_dirs: ./pkg

Is not working at all:

13:39:48 watcher     | Watching .
13:39:48 watcher     | Watching bin
13:39:48 watcher     | Watching pkg
13:39:48 watcher     | Watching pkg/darwin_amd64
13:39:48 watcher     | Watching public
13:39:48 watcher     | Watching src
13:39:48 watcher     | Watching src/site.org
13:39:48 watcher     | Watching src/site.org/application
13:39:48 watcher     | Watching src/site.org/application/controllers
13:39:48 watcher     | Watching src/site.org/application/controllers/web
13:39:48 watcher     | Watching src/site.org/system

FIXING

In the end, I was not able to make it work. However, I create a solution using this plugin:

https://github.com/alexnj/SublimeOnSaveBuild

That tries to build on save, and I've created this build system (called GoLang):

{
    "shell_cmd": "sh /Users/acruz/go_projects/build_go.sh \"$project_path\"",
    "working_dir": "${project_path}"
}

And the file build_go.sh is:

#!/bin/sh
echo "Removing PKG folder if exists"
rm -Rf pkg

echo "Building application"
go build -o bin/app.bin main.go

echo "Killing application"
killall app.bin

echo "Running application ./bin/app.bin"
echo ""
echo "Debug information:"
echo ""

./bin/app.bin

One @TODO will be defining in the project configuration the name of the binary... but for me this works ok. One of the benefits of doing this is you don't have to add the -a flag, which will make slow the compilation process, and the debug information will be showed just there in the build window...

Debug information

  • 写回答

2条回答 默认 最新

  • douya5194 2014-12-29 20:45
    关注

    You can change $GOPATH/src/github.com/pilu/fresh/runner/build.go#L13

    cmd := exec.Command("go", "build", "-o", buildPath(), root())
    

    to be

    cmd := exec.Command("go", "build", "-a", "-o", buildPath(), root())
    

    and then

    go install -a github.com/pilu/fresh
    

    flag -a force recompiling of .a files

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 八爪鱼爬数据为什么自己停了
  • ¥15 交替优化波束形成和ris反射角使保密速率最大化
  • ¥15 树莓派与pix飞控通信
  • ¥15 自动转发微信群信息到另外一个微信群
  • ¥15 outlook无法配置成功
  • ¥30 这是哪个作者做的宝宝起名网站
  • ¥60 版本过低apk如何修改可以兼容新的安卓系统
  • ¥25 由IPR导致的DRIVER_POWER_STATE_FAILURE蓝屏
  • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
  • ¥50 有数据,怎么用matlab求全要素生产率