From d98da25ffb308368b64ee1a49206f1981f440731 Mon Sep 17 00:00:00 2001 From: "Gerasimos (Makis) Maropoulos" Date: Thu, 2 Aug 2018 01:58:46 +0300 Subject: [PATCH] add a README note about the known issues for Go inside code editors/IDEs Former-commit-id: a4be78e746f5675291bab5a1b3e62eaf42cbd98c --- README.md | 19 +++++++++++++++++++ .../server-side-events/main.go | 9 +++++++-- .../server-side-events/optional.sse.js.html | 2 +- 3 files changed, 27 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index e54d9670..5baf23ef 100644 --- a/README.md +++ b/README.md @@ -33,6 +33,25 @@ _Updated at: [Tuesday, 21 November 2017](_benchmarks/README_UNIX.md)_ +
+Known issues for code editors and IDEs at general + +### VS Code + +For some reason the latest [vscode-go language extension](https://github.com/Microsoft/vscode-go) does not provide enough intelligence for the `iris.Context` type alias (input parameters documentation and definition navigation). +Probably you have already experienced this issue with other Go libraries too, it is not an iris-specific issue, it is a general issue for all Golang type aliases. + +Therefore if you use [VS Code](https://code.visualstudio.com/) and you need these editor's features, import the original path; add an extra import statement of the original path of the `Context`, that will do it: + +```go +import ( + "github.com/kataras/iris" + "github.com/kataras/iris/context" // <- HERE +) +``` + +
+ ## Philosophy The Iris philosophy is to provide robust tooling for HTTP, making it a great solution for single page applications, web sites, hybrids, or public HTTP APIs. Keep note that, so far, iris is the fastest web framework ever created in terms of performance. diff --git a/_examples/http_responsewriter/server-side-events/main.go b/_examples/http_responsewriter/server-side-events/main.go index b9de5544..f094c8cb 100644 --- a/_examples/http_responsewriter/server-side-events/main.go +++ b/_examples/http_responsewriter/server-side-events/main.go @@ -10,7 +10,12 @@ import ( "time" "github.com/kataras/golog" + "github.com/kataras/iris" + // Note: + // For some reason the latest vscode-go language extension does not provide enough intelligence (parameters documentation and go to definition features) + // for the `iris.Context` alias, therefore if you use VS Code, import the original import path of the `Context`, that will do it: + "github.com/kataras/iris/context" ) // A Broker holds open client connections, @@ -73,7 +78,7 @@ func (b *Broker) listen() { } } -func (b *Broker) ServeHTTP(ctx iris.Context) { +func (b *Broker) ServeHTTP(ctx context.Context) { // Make sure that the writer supports flushing. // flusher, ok := ctx.ResponseWriter().(http.Flusher) @@ -84,7 +89,7 @@ func (b *Broker) ServeHTTP(ctx iris.Context) { } // Set the headers related to event streaming, you can omit the "application/json" if you send plain text. - // If you developer a go client, you must have: "Accept" : "application/json, text/event-stream" header as well. + // If you develop a go client, you must have: "Accept" : "application/json, text/event-stream" header as well. ctx.ContentType("application/json, text/event-stream") ctx.Header("Cache-Control", "no-cache") ctx.Header("Connection", "keep-alive") diff --git a/_examples/http_responsewriter/server-side-events/optional.sse.js.html b/_examples/http_responsewriter/server-side-events/optional.sse.js.html index 8f0307f1..a69078b9 100644 --- a/_examples/http_responsewriter/server-side-events/optional.sse.js.html +++ b/_examples/http_responsewriter/server-side-events/optional.sse.js.html @@ -12,6 +12,6 @@ -

Open the browser's console(F12) and watch for icoming event messages

+

Open the browser's console(F12) and watch for incoming event messages

\ No newline at end of file