Go v1.8 - how to migrate to new "context" package?

160 views
Skip to first unread message

Alexander Trakhimenok

unread,
Nov 2, 2017, 10:38:49 PM11/2/17
to google-appengine-go
Great news about Go version 1.8 generally available on AppEngine Standard.

In the announcement in blog and in forum topic it is suggested to migrate from "golang.org/x/net/context" to the new "context" package.

But I'm confused how we can do it if datastore package is expecting the old "golang.org/x/net/context". I'm getting errors that "context.Context" can't be used as "golang.org/x/net/context.Context"

Is it possible at all now (am I missing something?) or should we wait until Go 1.9 with types aliasing becomes available on AppEngine Standard?
--
Alex

j...@google.com

unread,
Nov 3, 2017, 1:47:12 PM11/3/17
to google-appengine-go

Is it possible at all now (am I missing something?) or should we wait until Go 1.9 with types aliasing becomes available on AppEngine Standard?


You should wait. 

Ashley Finney

unread,
Nov 6, 2017, 9:08:44 AM11/6/17
to google-appengine-go
This is what I've done...


err := datastore.RunInTransaction(ctx, func(tctx oldContext.Context) error {
}, &datastore.TransactionOptions{Attempts: 1})

Ash.

Alexander Trakhimenok

unread,
Nov 6, 2017, 9:46:32 AM11/6/17
to google-appengine-go
It’s not clear how it solves the migration problem. AppEngine package still uses old context that is not compatible with new one in Go 1.8

dho...@gmail.com

unread,
Nov 15, 2017, 6:55:36 PM11/15/17
to google-appengine-go
We have done this migration, and everything works great (except for the function type mentioned above).

Since context.Context is an interface, the old and new versions are interchangeable in most situations, the most notable exception is when they are used as part of compound type - like the function used for transactions.

In any case, I would expect that you're actually waiting for 1.10, not 1.9. AppEngine only uses even-versioned Go 1.x releases, and typically about a year after the official Go release. The Go 1.10 official release is currently due at the end of Jan 2018, so it might be quite a while coming!

Alexander Trakhimenok

unread,
Nov 20, 2017, 5:35:57 AM11/20/17
to google-appengine-go
Steve from Google mentioned they are working on pushing 1.9 to prod and it should take much less time then 1.8.

According to github commits SDK is already is tested against 1.9.

So fingers crossed!

Strom

unread,
Nov 21, 2017, 1:19:15 PM11/21/17
to google-appengine-go
That would be lovely and I'm rooting for it to happen. However Google has made several upgrade promises before which never materialized, e.g. Go 1.7 was promised quicker than Go 1.6, but in practice it never came out.
Reply all
Reply to author
Forward
0 new messages