Iris: undefined: iris.Context - has iris.Context changed to context.Context?

Created on 11 Sep 2017  路  2Comments  路  Source: kataras/iris

When registering routes on "iris.Application", I get "iris.Context" errors like ".../main.go:14 undefined: iris.Context" even though "github.com/kataras/iris" has been imported. Changing to import "github.com/kataras/iris/context" and using "context.Context" seems to fix this, but I haven't found any docs that explain this change... Is this just a oversight of refactoring, or am I missing something?

help-needed

Most helpful comment

I assume that you're using the go version 1.8 and try to use the new type alias iris.Context (introduced at go 1.9) instead of the context.Context from "github.com/kataras/iris/context".

The docs are updated to go 1.9, the real context is located at context.Context so use it as import "github.com/kataras/iris/context" BUT if you're using go version 1.9 you can use the iris.Context instead and omit the context import statement because it's a type alias, a new feature.

The iris.Context is described at the README.md under the Hello World with Go 1.8 section, if you're hosting from go 1.8 it tells you why you want to import the context package.

@krokite It was always context.Context the @adamjaso 's question was about docs because they see iris.Context but as I noted at the first paragraph: all docs and examples are updated to go 1.9 with the iris.Context type alias. Although we kept a section on README for new gophers who using the old go version and have no idea about type alias, as well.

At the end, both iris.Context and context.Context works exactly the same, it's the same type, so it's your choice if you want to import the context package or just use the iris.Context (if go >= 1.9). Simple enough.

All 2 comments

Yes, it is now context.Context

I assume that you're using the go version 1.8 and try to use the new type alias iris.Context (introduced at go 1.9) instead of the context.Context from "github.com/kataras/iris/context".

The docs are updated to go 1.9, the real context is located at context.Context so use it as import "github.com/kataras/iris/context" BUT if you're using go version 1.9 you can use the iris.Context instead and omit the context import statement because it's a type alias, a new feature.

The iris.Context is described at the README.md under the Hello World with Go 1.8 section, if you're hosting from go 1.8 it tells you why you want to import the context package.

@krokite It was always context.Context the @adamjaso 's question was about docs because they see iris.Context but as I noted at the first paragraph: all docs and examples are updated to go 1.9 with the iris.Context type alias. Although we kept a section on README for new gophers who using the old go version and have no idea about type alias, as well.

At the end, both iris.Context and context.Context works exactly the same, it's the same type, so it's your choice if you want to import the context package or just use the iris.Context (if go >= 1.9). Simple enough.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

stefanwuthrich picture stefanwuthrich  路  4Comments

Dexus picture Dexus  路  4Comments

AlbinoGeek picture AlbinoGeek  路  3Comments

ZetDeveloper picture ZetDeveloper  路  3Comments

zfanmy picture zfanmy  路  3Comments