SCF服务示例找不到包cloudfunction package?

  • 回答 (1)
  • 关注 (0)
  • 查看 (95)

代码是官方文档里的:

package main

import (

"context"

"fmt"

"github.com/tencentyun/scf-go-lib/cloudfunction"

)

type DefineEvent struct {

// test event define

Key1 string `json:"key1"`

Key2 string `json:"key2"`

}

func hello(ctx context.Context, event DefineEvent) (string, error) {

fmt.Println("key1:", event.Key1)

fmt.Println("key2:", event.Key2)

return fmt.Sprintf("Hello %s!", event.Key1), nil

}

func main() {

// Make the handler available for Remote Procedure Call by Cloud Function

cloudfunction.Start(hello)

}

编译报错:

cannot find package "github.com/tencentyun/scf-go-lib/cloudfunction" in any of:

/usr/local/Cellar/go/1.12.5/libexec/src/github.com/tencentyun/scf-go-lib/cloudfunction (from $GOROOT)

/Users/ext.richie.zhu/go/src/github.com/tencentyun/scf-go-lib/cloudfunction (from $GOPATH)

用户4789074用户4789074提问于
用户4789074回答于
推荐

解决办法:

go get github.com/tencentyun/scf-go-lib/cloudfunction

扫码关注云+社区

领取腾讯云代金券