Google Cloud Storage Client Application Error When Using Go Runtime Google App Engine

I am trying to execute the sample code from this link and try to perform operations with Google Cloud Storage using the Google Cloud Storage Client application from Go runtime, but the next part in the sample code gives the error "cannot use c (type" appengine ".Context) as type context.Context in the function argument: "appengine". The context does not implement context.Context (missing Deadline method) "

c := appengine.NewContext(r)
hc := &http.Client{
    Transport: &oauth2.Transport{
        Source: google.AppEngineTokenSource(c, storage.ScopeFullControl),
        Base:   &urlfetch.Transport{Context: c},
    },
}

What is the problem? How can I solve this problem?

+4
source share
2

, appengine.Context, context.Context.

google.AppEngineTokenSource() context.Context, , ( appengine.Context).

Context :

cloud.NewContext(projID string, c *http.Client)

:

c := appengine.NewContext(r)
hc := &http.Client{}
ctx := cloud.NewContext(appengine.AppID(c), hc)
hc.Transport = &oauth2.Transport{
    Source: google.AppEngineTokenSource(ctx, storage.ScopeFullControl),
    Base:   &urlfetch.Transport{Context: c},
}
+5

appengine google.golang.org/appengine, : https://github.com/golang/oauth2/#app-engine

+2

All Articles