我目前正在使用fresh在项目中任何源文件的每次更改时重建并重新启动网络服务器。
一切正常。但是,在pkg目录下创建一段时间后会生成文件。这导致刷新不再发生,原因是不是获取源文件(.go文件)来构建二进制文件,而是获取.a文件。我该如何避免此功能?
添加信息:
文件:与main.go相同级别的runner.conf
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
根本不工作:
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
修复
最后,我无法使其发挥作用。但是,我使用这个插件创建了一个解决方案:
https://github.com/alexnj/SublimeOnSaveBuild
尝试以save为基础,并且我已经创建了这个构建系统(称为GoLang):
{
"shell_cmd": "sh /Users/acruz/go_projects/build_go.sh \"$project_path\"",
"working_dir": "${project_path}"
}
文件build_go.sh是:
#!/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
一个@TODO将在项目配置中定义二进制文件的名称......但对我来说这可行。这样做的好处之一是你不必添加-a标志,这将使编译过程变慢,并且调试信息将在构建窗口中显示...
答案 0 :(得分:1)
考虑Pull Request 20约为"添加了ignore_dirs设置",您可以使用该新设置明确忽略pkg
文件夹。
ignore_dirs path1, path2, ...
Check how that ignore_dirs
path is checked:
if info.IsDir() && !isTmpDir(path) {
if _, ignore := ignorePaths[info.Name()]; (len(path) > 1 &&
strings.HasPrefix(filepath.Base(path), ".")) || ignore {
return filepath.SkipDir
答案 1 :(得分:1)
您可以更改$ GOPATH / src / github.com / pilu / fresh / runner / build.go#L13
cmd := exec.Command("go", "build", "-o", buildPath(), root())
是
cmd := exec.Command("go", "build", "-a", "-o", buildPath(), root())
然后
go install -a github.com/pilu/fresh
标志-a强制重新编译.a文件