dongping1689 2019-07-05 10:58
浏览 154
已采纳

在Google云端功能中找不到软件包“ firebase.google.com/go”

I'm trying to run some example code that stores some random data using a cloud function in the Firestore server, however, Cloud functions deploy command refuses to build the command:

// Package p contains an HTTP Cloud Function.
package p

import (
    //...
    firebase "firebase.google.com/go"
    "log"
    "net/http"
    "os"
)

// Store1 Stores data on FireBase
func Store1(w http.ResponseWriter, r *http.Request) {

    // Use the application default credentials
    ctx := context.Background()

    conf := &firebase.Config{ProjectID: "firefirefire"}
    app, err := firebase.NewApp(ctx, conf)
    if err != nil {
        log.Fatalln(err)
    }

    client, err := app.Firestore(ctx)
    if err != nil {
        log.Fatalln(err)
    }
    defer client.Close()

    _, _, err = client.Collection("users").Add(ctx, map[string]interface{}{
        "first": "Ada",
        "last":  "Lovelace",
        "born":  1815,
    })

    if err != nil {
        log.Fatalf("Failed adding alovelace: %v", err)
    }
    fmt.Println("ENV:" + os.Getenv("VAR1"))
    fmt.Fprint(w, html.EscapeString(d.Message))
}

This is what I get as an error:

localhost:store1 b$ ./deploy.sh
Updated property [functions/region].
Deploying function (may take a while - up to 2 minutes)...failed.
ERROR: (gcloud.functions.deploy) OperationError: code=3, message=Build failed: /tmp/sgb/gopath/src/serverlessapp/vendor/p/store1.go:6:2: cannot find package "firebase.google.com/go" in any of:
    /tmp/sgb/gopath/src/serverlessapp/vendor/firebase.google.com/go (vendor tree)
    /go/src/firebase.google.com/go (from $GOROOT)
    /tmp/sgb/gopath/src/firebase.google.com/go (from $GOPATH)

As you can see, the problem seems to be that Google doesn't have firebase.google.com/go on Cloud functions engine and as a result I can't have my serverless configuration do the firebase thing. Should I move to CloudSQL and just pay the $11 fee ? Should I continue to try to get Firebase to work? Should I try a Firebase Function instead? Please advise.

  • 写回答

1条回答

      报告相同问题?

      相关推荐 更多相似问题

      悬赏问题

      • ¥15 关于bitwise and/or 的问题
      • ¥30 nodejs child_process通信问题
      • ¥15 pretous做定时闹钟,keil的C语言程序下载到pretous仿真图中可以运行,但是运行结果不太对,麻烦哪位大神帮忙调一下。
      • ¥15 C语言高精度加减法出了问题
      • ¥15 用matlab来完成这两个程序
      • ¥15 如何在pyecharts绘制的图像上添加窗口?
      • ¥15 8086CPU汇编语言
      • ¥35 哪位大佬可以帮忙做一下,有赏金
      • ¥15 51单片机c语言制作数字电子时钟
      • ¥15 求大神帮忙看看这一题