错误将文件复制到golang中的stdin

时间:2017-04-26 02:15:40

标签: go dokku

我正在使用echo为dokku管理构建一个Web应用程序。它有一个url路由器来处理tarfile deploying,我的处理程序如下: 包路由器

import (
    "fmt"
    "github.com/labstack/echo"
    "io"
    "net/http"
    "os/exec"
)

// deploy app via tar file
func deployTarApp(c echo.Context) error {
    name := c.Param("name")
    file, ef := c.FormFile("file")
    if ef != nil || file == nil {
        return c.NoContent(http.StatusBadRequest)
    }
    tempfile, et := file.Open()
    if et != nil {
        return c.JSON(http.StatusInternalServerError, et)
    }
    cmd := exec.Command(DokkuPath, "tar:in", name)
    stdin, err := cmd.StdinPipe()
    if err != nil {
        return c.JSON(http.StatusInternalServerError, err)
    }
    go func() {
        defer stdin.Close()
        io.Copy(stdin, tempfile)
    }()
    out, e := cmd.CombinedOutput()
    if e != nil {
        fmt.Println(string(out), e)
        return c.JSON(http.StatusInternalServerError, e)
    }
    return c.NoContent(http.StatusOK)
}

首先获取表单文件,然后将其复制到stdin,然后运行dokku tar:in app-name。但代码抛出错误

/var/lib/dokku/plugins/available/git/functions: line 114: /home/dokku/node-sample/refs/heads/master: No such file or directory
 exit status 128

处理程序有什么问题?我是golang的新手,所以我对它并不熟悉。谢谢你的帮助。

0 个答案:

没有答案