dourong8495 2016-12-09 13:40
浏览 29
已采纳

App Engine go context.Context没有名称空间

After obtain a context from ctx, ctxErr := appengine.Namespace(ctx, "MyContext") I would expect ctx namespace to be populated with MyContext

Code

import (
...
"golang.org/x/net/context"
"google.golang.org/appengine"
)


ctx := appengine.NewContext(r)
ctx, ctxErr := appengine.Namespace(ctx, "MyContext")
if ctxErr != nil {
  log.Errorf(ctx, "Failed to obtain custom namespace context, error:%s", ctxErr.Error())
  //use default if all else fails
  ctx = appengine.NewContext(r)
}

However this is not the case, thus causing all namespace aware API to use default namespace.

Dump of ctx produces the following (see yellow bordered output)

enter image description here

Example App

Populate projectID := "" with your project id, ensure you have performed authentication on your development environment and run go run /example/app/main.go

Example App

  • 写回答

1条回答 默认 最新

  • dongxiai3003 2016-12-13 22:56
    关注

    Mixing of google api go libs, was causing the problem.

    Long Answer

    Short Answer

    Google Cloud API libs come in two different flavors, issues was caused by mixing of lib features from libs below.

    google-cloud-go Recommanded

    google-api-go-client

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度