Skip to content

Commit ef2643b

Browse files
committed
replace ioutil with io package and other minor improvements
1 parent 20d2855 commit ef2643b

File tree

108 files changed

+1069
-1021
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

108 files changed

+1069
-1021
lines changed

HISTORY.md

+1
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ The codebase for Dependency Injection, Internationalization and localization and
2828

2929
## Fixes and Improvements
3030

31+
- Make the `Context.JSON` method customizable by modifying the `context.WriteJSON` package-level function.
3132
- Add new `iris.NewGuide` which helps you build a simple and nice JSON API with services as dependencies and better design pattern.
3233
- Make `Context.Domain()` customizable by letting developers to modify the `Context.GetDomain` package-level function.
3334
- Remove Request Context-based Transaction feature as its usage can be replaced with just the Iris Context (as of go1.7+) and better [project](_examples/project) structure.

LICENSE

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
Copyright (c) 2017-2022 The Iris Authors. All rights reserved.
1+
Copyright (c) 2017-2022, The Iris Authors. All rights reserved.
2+
3+
The Iris Authors:
4+
* Gerasimos (Makis) Maropoulos
25

36
Redistribution and use in source and binary forms, with or without
47
modification, are permitted provided that the following conditions are

README.md

+37-8
Original file line numberDiff line numberDiff line change
@@ -19,26 +19,27 @@
1919

2020
Iris is a fast, simple yet fully featured and very efficient web framework for Go.
2121

22-
It provides a [beautifully](iris_guide.go#L31-L44) expressive and easy to use foundation for your next website or API.
22+
It provides a beautifully expressive and easy to use foundation for your next website or API.
23+
2324

2425
```go
2526
package main
2627

2728
import "github.com/kataras/iris/v12"
2829

2930
func main() {
30-
app := iris.New()
31-
app.Use(iris.Compression)
31+
app := iris.New()
32+
app.Use(iris.Compression)
3233

33-
app.Get("/", func(ctx iris.Context) {
34-
ctx.HTML("Hello <strong>%s</strong>!", "World")
35-
})
34+
app.Get("/", func(ctx iris.Context) {
35+
ctx.HTML("Hello <strong>%s</strong>!", "World")
36+
})
3637

37-
app.Listen(":8080")
38+
app.Listen(":8080")
3839
}
3940
```
4041

41-
<details><summary>More with simple Handler</summary>
42+
<!-- <details><summary>More with simple Handler</summary>
4243
4344
```go
4445
package main
@@ -178,6 +179,34 @@ func main() {
178179
179180
<br/>
180181
182+
-->
183+
184+
As one [Go developer](https://twitter.com/dkuye/status/1532087942696554497) once said, **Iris got you covered all-round and standing strong over the years**.
185+
186+
Some of the features Iris offers:
187+
188+
* HTTP/2 (Push, even Embedded data)
189+
* Middleware (Accesslog, Basicauth, CORS, gRPC, Anti-Bot hCaptcha, JWT, MethodOverride, ModRevision, Monitor, PPROF, Ratelimit, Anti-Bot reCaptcha, Recovery, RequestID, Rewrite)
190+
* API Versioning
191+
* Model-View-Controller
192+
* Websockets
193+
* gRPC
194+
* Auto-HTTPS
195+
* Builtin support for ngrok to put your app on the internet, the fastest way
196+
* Unique Router with dynamic path as parameter with standard types like :uuid, :string, :int... and the ability to create your own
197+
* Compression
198+
* View Engines (HTML, Django, Amber, Handlebars, Pug/Jade and more)
199+
* Create your own File Server and host your own WebDAV server
200+
* Cache
201+
* Localization (i18n, sitemap)
202+
* Sessions
203+
* Rich Responses (HTML, Text, Markdown, XML, YAML, Binary, JSON, JSONP, Protocol Buffers, MessagePack, Content Negotiation, Streaming, Server-Sent Events and more)
204+
* Response Compression (gzip, deflate, brotli, snappy, s2)
205+
* Rich Requests (Bind URL Query, Headers, Form, Text, XML, YAML, Binary, JSON, Validation, Protocol Buffers, MessagePack and more)
206+
* Dependency Injection (MVC, Handlers, API Routers)
207+
* Testing Suite
208+
* And the most important... you get fast answers and support from the 1st day until now - that's six full years!
209+
181210
Learn what [others saying about Iris](https://www.iris-go.com/#review) and **[star](https://github.com/kataras/iris/stargazers)** this open-source project to support its potentials.
182211

183212
[![](https://iris-go.com/images/reviews.gif)](https://iris-go.com/testimonials/)

_examples/auth/jwt/tutorial/go-client/client.go

+1-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import (
55
"encoding/json"
66
"fmt"
77
"io"
8-
"io/ioutil"
98
"net/http"
109
"net/url"
1110
"strconv"
@@ -105,5 +104,5 @@ func BindResponse(resp *http.Response, dest interface{}) error {
105104
func RawResponse(resp *http.Response) ([]byte, error) {
106105
defer resp.Body.Close()
107106

108-
return ioutil.ReadAll(resp.Body)
107+
return io.ReadAll(resp.Body)
109108
}

_examples/compression/client-using-iris/main.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import (
44
"bytes"
55
"encoding/json"
66
"fmt"
7-
"io/ioutil"
7+
"io"
88
"net/http"
99

1010
"github.com/kataras/iris/v12/context"
@@ -51,7 +51,7 @@ func getExample() {
5151
}
5252
defer cr.Close()
5353

54-
body, err := ioutil.ReadAll(cr)
54+
body, err := io.ReadAll(cr)
5555
if err != nil {
5656
panic(err)
5757
}
@@ -103,7 +103,7 @@ func postExample() {
103103
}
104104
defer cr.Close()
105105

106-
body, err := ioutil.ReadAll(cr)
106+
body, err := io.ReadAll(cr)
107107
if err != nil {
108108
panic(err)
109109
}

_examples/compression/client/main.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import (
55
"compress/gzip"
66
"encoding/json"
77
"fmt"
8-
"io/ioutil"
8+
"io"
99
"net/http"
1010
)
1111

@@ -42,7 +42,7 @@ func getExample() {
4242
}
4343
defer r.Close()
4444

45-
body, err := ioutil.ReadAll(r)
45+
body, err := io.ReadAll(r)
4646
if err != nil {
4747
panic(err)
4848
}
@@ -93,7 +93,7 @@ func postExample() {
9393
}
9494
defer r.Close()
9595

96-
body, err := ioutil.ReadAll(r)
96+
body, err := io.ReadAll(r)
9797
if err != nil {
9898
panic(err)
9999
}

_examples/desktop/blink/main.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ import (
1111
const addr = "127.0.0.1:8080"
1212

1313
/*
14-
$ go build -mod=mod -ldflags -H=windowsgui -o myapp.exe
15-
$ ./myapp.exe # run the app
14+
$ go build -mod=mod -ldflags -H=windowsgui -o myapp.exe
15+
$ ./myapp.exe # run the app
1616
*/
1717
func main() {
1818
go runServer()

_examples/desktop/lorca/main.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ import (
88
const addr = "127.0.0.1:8080"
99

1010
/*
11-
$ go build -mod=mod -ldflags="-H windowsgui" -o myapp.exe # build for windows
12-
$ ./myapp.exe # run
11+
$ go build -mod=mod -ldflags="-H windowsgui" -o myapp.exe # build for windows
12+
$ ./myapp.exe # run
1313
*/
1414
func main() {
1515
go runServer()

_examples/desktop/webview/main.go

+15-15
Original file line numberDiff line numberDiff line change
@@ -8,21 +8,21 @@ import (
88
const addr = "127.0.0.1:8080"
99

1010
/*
11-
# Windows requires special linker flags for GUI apps.
12-
# It's also recommended to use TDM-GCC-64 compiler for CGo.
13-
# http://tdm-gcc.tdragon.net/download
14-
#
15-
#
16-
$ go build -mod=mod -ldflags="-H windowsgui" -o myapp.exe # build for windows
17-
$ ./myapp.exe # run
18-
#
19-
# MacOS uses app bundles for GUI apps
20-
$ mkdir -p example.app/Contents/MacOS
21-
$ go build -o example.app/Contents/MacOS/example
22-
$ open example.app # Or click on the app in Finder
23-
#
24-
# Note: if you see "use option -std=c99 or -std=gnu99 to compile your code"
25-
# please refer to: https://github.com/webview/webview/issues/188
11+
# Windows requires special linker flags for GUI apps.
12+
# It's also recommended to use TDM-GCC-64 compiler for CGo.
13+
# http://tdm-gcc.tdragon.net/download
14+
#
15+
#
16+
$ go build -mod=mod -ldflags="-H windowsgui" -o myapp.exe # build for windows
17+
$ ./myapp.exe # run
18+
#
19+
# MacOS uses app bundles for GUI apps
20+
$ mkdir -p example.app/Contents/MacOS
21+
$ go build -o example.app/Contents/MacOS/example
22+
$ open example.app # Or click on the app in Finder
23+
#
24+
# Note: if you see "use option -std=c99 or -std=gnu99 to compile your code"
25+
# please refer to: https://github.com/webview/webview/issues/188
2626
*/
2727
func main() {
2828
go runServer()

_examples/file-server/basic/main_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package main
22

33
import (
4-
"io/ioutil"
4+
"os"
55
"path/filepath"
66
"strings"
77
"testing"
@@ -47,7 +47,7 @@ func (r resource) loadFromBase(dir string, strip string) string {
4747

4848
fullpath := filepath.Join(dir, filename)
4949

50-
b, err := ioutil.ReadFile(fullpath)
50+
b, err := os.ReadFile(fullpath)
5151
if err != nil {
5252
panic(fullpath + " failed with error: " + err.Error())
5353
}

_examples/file-server/embedding-files-into-app/bindata.go

+9-8
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

_examples/file-server/embedding-files-into-app/main_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package main
22

33
import (
4-
"io/ioutil"
4+
"os"
55
"path/filepath"
66
"runtime"
77
"strings"
@@ -46,7 +46,7 @@ func (r resource) loadFromBase(dir string) string {
4646

4747
fullpath := filepath.Join(dir, filename)
4848

49-
b, err := ioutil.ReadFile(fullpath)
49+
b, err := os.ReadFile(fullpath)
5050
if err != nil {
5151
panic(fullpath + " failed with error: " + err.Error())
5252
}

_examples/file-server/embedding-gzipped-files-into-app/bindata.go

+9-8
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

_examples/file-server/embedding-gzipped-files-into-app/main_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ package main
22

33
import (
44
"bytes"
5-
"io/ioutil"
5+
"os"
66
"path/filepath"
77
"runtime"
88
"strings"
@@ -48,7 +48,7 @@ func (r resource) loadFromBase(dir string) string {
4848

4949
fullpath := filepath.Join(dir, filename)
5050

51-
b, err := ioutil.ReadFile(fullpath)
51+
b, err := os.ReadFile(fullpath)
5252
if err != nil {
5353
panic(fullpath + " failed with error: " + err.Error())
5454
}

0 commit comments

Comments
 (0)