From 4bb230d9abf5d2d23d28b498ae22b4300a05f029 Mon Sep 17 00:00:00 2001 From: hiveminded Date: Wed, 27 Sep 2017 15:40:45 +0300 Subject: [PATCH] add a second type aliases section at README for new gophers :ab: Former-commit-id: 3e2abd4e0b322021f3a22db4dcdccc61fc76f15d --- README.md | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/README.md b/README.md index f9480eda..6f74d85b 100644 --- a/README.md +++ b/README.md @@ -136,6 +136,28 @@ $ go run main.go > Application started. Press CTRL+C to shut down. ``` +### 💎 Type aliases + +Go version 1.9 introduced the [type alias](https://golang.org/doc/go1.9#language) feature. + +Iris uses the `type alias` feature to help you writing less code by omitting some package imports. The examples and documentation are written using Go 1.9 as well. + +If you build your Go app with Go 1.9 you can, optionally, use all Iris web framework's features by importing one single package, the `github.com/kataras/iris`. + +Available type aliases; + + +| Go 1.8 | Go 1.8 usage | Go 1.9 (Optionally) | Go 1.9 usage | +| -----------|--------|--------|--------| +| `import "github.com/kataras/iris/context"` | `func(context.Context) {}`, `context.Handler`, `context.Map` | `import "github.com/kataras/iris"` | `func(iris.Context) {}`, `iris.Handler`, `iris.Map` | +| `import "github.com/kataras/iris/mvc"` | `type MyController struct { mvc.Controller }` , `mvc.SessionController` | `import "github.com/kataras/iris"` | `type MyController struct { iris.Controller }`, `iris.SessionController` | +| `import "github.com/kataras/iris/core/router"` | `app.PartyFunc("/users", func(p router.Party) {})` | `import "github.com/kataras/iris"` | `app.PartyFunc("/users", func(p iris.Party) {})` | +| `import "github.com/kataras/iris/core/host"` | `app.ConfigureHost(func(s *host.Supervisor) {})` | `import "github.com/kataras/iris"` | `app.ConfigureHost(func(s *iris.Supervisor) {})` | + +You can find all type aliases and their original package import statements at the [./context.go file](context.go). + +> Remember; this doesn't mean that you have to use those type alias, you can continue import the original packages as you did with Go version 1.8. +
Hello World with Go 1.8