命令'go install ckage'失败,退出代码为1

时间:2018-10-07 04:45:09

标签: go gulp

我正在尝试设置gulp watch任务,但最终安装一个软件包时出错。但是我高度怀疑这是因为stripPath不能按预期的方式运行。

这是错误日志:

[21:20:27] Using gulpfile ~/Documents/Projects/GoLang/src/github.com/idiotLeon/TutorialBuildingDistributedApplicationsWithGo/gulpfile.js
[21:20:27] Starting 'watch'...
[21:20:27] Finished 'watch' after 8.52 ms
[21:20:33] Starting 'compilepkg'...
can't load package: package ckage: cannot find package "ckage" in any of:
    /usr/local/Cellar/go/1.11/libexec/src/ckage (from $GOROOT)
    /Users/Leon/Documents/Projects/GoLang/src/ckage (from $GOPATH)
[21:20:33] 'compilepkg' errored after 58 ms
[21:20:33] Error in plugin "gulp-shell"
Message:
    Command `go install ckage` failed with exit code 1

代码如下:
gulp.js

var gulp = require('gulp');
var path = require('path');
var shell = require('gulp-shell');

var goPath = 'mypackage/*.go';

gulp.task('compilepkg', function () {
    return gulp.src(goPath, { read: false })
        .pipe(shell(['go install <%= stripPath(file.path) %>'],
            {
                templateData: {
                    stripPath: function (filePath) {
                        var subPath = filePath.substring(process.cwd().length + 5);
                        var pkg = subPath.substring(0, subPath.lastIndexOf(path.sep));
                        return pkg;
                    }
                }
            })
        );
});

gulp.task('watch', function () {
    gulp.watch(goPath, ['compilepkg']);
});

这是仓库(github),在第一次提交时就出现了此问题。

更多背景:

go version go1.11 darwin/amd64

node -v: v10.10.0

package.json

{
  "name": "tutorialbuildingdistributedapplicationswithgo",
  "version": "1.0.0",
  "description": "",
  "main": "main.go",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "author": "",
  "license": "ISC",
  "dependencies": {
    "gulp": "^3.9.1",
    "gulp-shell": "^0.6.5",
    "path": "^0.12.7"
  }
}

0 个答案:

没有答案