dongyo1818 2019-02-10 22:31
浏览 65

Golang Cloud功能和本地依赖项

I am trying to deploy to google cloud using deploy command and my code refers local package using the github url. I getting below when deploying using gcloud deploy command. So in this example. My endpoints package refers to local package price using the full git url. What am I missing here ?

package endpoints

import (
    "encoding/json"
    "fmt"
    "github.com/piscean/pricing/price"
    "net/http"
)

func LawnPricing(w http.ResponseWriter, r *http.Request) {

    m, err := price.Pricing()

    c, err := json.Marshal(m)

    w.Write(c)
    r.Body.Close()
}

ERROR: (gcloud.functions.deploy) OperationError: code=3, message=Build failed: /tmp/sgb/gopath/src/serverlessapp/vendor/endpoints/pricing.go:6:2: cannot find package "github.com/piscean/pricing/price" in any of: /tmp/sgb/gopath/src/serverlessapp/vendor/github.com/piscean/pricing/price (vendor tree) /go/src/github.com/piscean/pricing/price (from $GOROOT) /tmp/sgb/gopath/src/github.com/piscean/pricing/price (from $GOPATH) /tmp/sgb/gopath/src/serverlessapp/vendor/endpoints/zipcode.go:5:2: cannot find package "github.com/piscean/pricing/zip" in any of: /tmp/sgb/gopath/src/serverlessapp/vendor/github.com/piscean/pricing/zip (vendor tree) /go/src/github.com/piscean/pricing/zip (from $GOROOT) /tmp/sgb/gopath/src/github.com/piscean/pricing/zip (from $GOPATH)

  • 写回答

1条回答 默认 最新

  • dpspn60064 2019-02-11 04:38
    关注

    You should use the dependency package management tool for this called as dep.

    Install dep by using the command:

    go get -u github.com/golang/dep/cmd/dep

    This would create the binary of dep in the GOBIN directory. Navigate to directory where main package is present and execute the command:

    For Windows: %GOBIN%\dep.exe init

    For Linux: $GOBIN\dep init

    This would create Gopkg.toml and Gopkg.lock files along with the vendor folder that would solve your issue.

    Reference: https://golang.github.io/dep/docs/introduction.html

    评论

报告相同问题?

悬赏问题

  • ¥15 基于卷积神经网络的声纹识别
  • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
  • ¥100 为什么这个恒流源电路不能恒流?
  • ¥15 有偿求跨组件数据流路径图
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 CSAPPattacklab
  • ¥15 一直显示正在等待HID—ISP
  • ¥15 Python turtle 画图
  • ¥15 stm32开发clion时遇到的编译问题