🗑️ deprecate: go 1.14 & go 1.15 support deprecation (#2172)

* 🗑️ deprecate: go 1.14 & go 1.15 support deprecation
https://github.com/valyala/fasthttp/pull/1379

* fix tests
pull/2171/head
M. Efe Çetin 2022-10-26 12:51:50 +03:00 committed by GitHub
parent eb692727c5
commit 691d2e6ad5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
45 changed files with 201 additions and 206 deletions

2
.github/README.md vendored
View File

@ -148,7 +148,7 @@ Fiber is **inspired** by Express, the most popular web framework on the Internet
We **listen** to our users in [issues](https://github.com/gofiber/fiber/issues), Discord [channel](https://gofiber.io/discord) _and all over the Internet_ to create a **fast**, **flexible** and **friendly** Go web framework for **any** task, **deadline** and developer **skill**! Just like Express does in the JavaScript world.
## ⚠️ Limitations
* Due to Fiber's usage of unsafe, the library may not always be compatible with the latest Go version. Fiber 2.29.0 has been tested with Go versions 1.14 to 1.19.
* Due to Fiber's usage of unsafe, the library may not always be compatible with the latest Go version. Fiber 2.40.0 has been tested with Go versions 1.16 to 1.19.
* Fiber is not compatible with net/http interfaces. This means you will not be able to use projects like gqlgen, go-swagger, or any others which are part of the net/http ecosystem.
## 👀 Examples

View File

@ -142,7 +142,7 @@ Neue Gopher, welche von [Node.js](https://nodejs.org/en/about/) zu [Go](https://
Fiber ist **inspiriert** von Express.js, dem beliebtesten Web-Framework im Internet. Wir haben die **Leichtigkeit** von Express und die **Rohleistung** von Go kombiniert. Wenn du jemals eine Webanwendung mit Node.js implementiert hast (_mit Express.js oder ähnlichem_), werden dir viele Methoden und Prinzipien **sehr vertraut** vorkommen.
## ⚠️ Limitations
* Due to Fiber's usage of unsafe, the library may not always be compatible with the latest Go version. Fiber 2.29.0 has been tested with Go versions 1.14 to 1.19.
* Due to Fiber's usage of unsafe, the library may not always be compatible with the latest Go version. Fiber 2.40.0 has been tested with Go versions 1.16 to 1.19.
* Fiber is not compatible with net/http interfaces. This means you will not be able to use projects like gqlgen, go-swagger, or any others which are part of the net/http ecosystem.
## 👀 Beispiele

View File

@ -142,7 +142,7 @@ Los nuevos gophers que hacen el cambio de [Node.js](https://nodejs.org/en/about/
Fiber está **inspirado** en Expressjs, el framework web más popular en Internet. Combinamos la **facilidad** de Express y **el rendimiento bruto** de Go. Si alguna vez ha implementado una aplicación web en Node.js ( _utilizando Express.js o similar_ ), muchos métodos y principios le parecerán **muy comunes** .
## ⚠️ Limitantes
* Debido a que Fiber utiliza unsafe, la biblioteca no siempre será compatible con la última versión de Go. Fiber 2.29.0 ha sido probado con las versiones de Go 1.14 a 1.19.
* Debido a que Fiber utiliza unsafe, la biblioteca no siempre será compatible con la última versión de Go. Fiber 2.40.0 ha sido probado con las versiones de Go 1.16 a 1.19.
* Fiber no es compatible con interfaces net/http. Esto significa que no lo podrá usar en proyectos como qglgen, go-swagger, u otros que son parte del ecosistema net/http.
## 👀 Ejemplos

View File

@ -182,7 +182,7 @@ Fiber از Express <b>الهام گرفته</b>, که محبوب ترین فری
</p>
## ⚠️ محدودیت ها
* به دلیل استفاده ناامن از Fiber, ممکن است کتابخانه همیشه با آخرین نسخه Go سازگار نباشد. Fiber 2.29.0 با زبان گو نسخه ۱.۱۴ تا ۱.۱۷ تست شده است.
* به دلیل استفاده ناامن از Fiber, ممکن است کتابخانه همیشه با آخرین نسخه Go سازگار نباشد. Fiber 2.40.0 با زبان گو نسخه 1.16 تا 1.19 تست شده است.
* فریمورک Fiber با پکیج net/http سازگار نیست. این بدان معناست شما نمی توانید از پکیج های مانند go-swagger, gqlgen یا سایر پروژه هایی که بخشی از اکوسیستم net/http هستند استفاده کنید.
<br>

View File

@ -142,7 +142,7 @@ Les nouveaux gophers qui passent de [Node.js](https://nodejs.org/en/about/) à [
Fiber est **inspiré** par Express, le framework web le plus populaire d'Internet. Nous avons combiné la **facilité** d'Express, et la **performance brute** de Go. Si vous avez déja développé une application web en Node.js (_en utilisant Express ou équivalent_), alors de nombreuses méthodes et principes vous sembleront **familiers**.
## ⚠️ Limitations
* Due to Fiber's usage of unsafe, the library may not always be compatible with the latest Go version. Fiber 2.29.0 has been tested with Go versions 1.14 to 1.19.
* Due to Fiber's usage of unsafe, the library may not always be compatible with the latest Go version. Fiber 2.40.0 has been tested with Go versions 1.16 to 1.19.
* Fiber is not compatible with net/http interfaces. This means you will not be able to use projects like gqlgen, go-swagger, or any others which are part of the net/http ecosystem.
## 👀 Exemples

View File

@ -187,7 +187,7 @@ Fiber נוצרה **בהשראת** Express, ה-web framework הפופולרית
<div dir="rtl">
## ⚠️ Limitations
* Due to Fiber's usage of unsafe, the library may not always be compatible with the latest Go version. Fiber 2.29.0 has been tested with Go versions 1.14 to 1.19.
* Due to Fiber's usage of unsafe, the library may not always be compatible with the latest Go version. Fiber 2.40.0 has been tested with Go versions 1.16 to 1.19.
* Fiber is not compatible with net/http interfaces. This means you will not be able to use projects like gqlgen, go-swagger, or any others which are part of the net/http ecosystem.
## 👀 דוגמאות

View File

@ -145,7 +145,7 @@ Kami **mendengarkan** para pengguna di [GitHub Issues](https://github.com/gofibe
## ⚠️ Limitasi
* Karena penggunaan Fiber yang tidak aman, perpustakaan mungkin tidak selalu kompatibel dengan versi Go terbaru. Fiber 2.29.0 telah diuji dengan Go versi 1.14 hingga 1.19.
* Karena penggunaan Fiber yang tidak aman, perpustakaan mungkin tidak selalu kompatibel dengan versi Go terbaru. Fiber 2.40.0 telah diuji dengan Go versi 1.16 hingga 1.19.
* Fiber tidak kompatibel dengan antarmuka net/http. Ini berarti kamu tidak akan dapat menggunakan proyek seperti gqlgen, go-swagger, atau lainnya yang merupakan bagian dari ekosistem net/http.
## 👀 Contoh

View File

@ -143,7 +143,7 @@ Fiber è **ispirato** da Express, il web framework più popolare su internet. Ab
## ⚠️ Limitazioni
* Dato che Fiber utilizza unsafe, la libreria non sempre potrebbe essere compatibile con l'ultima versione di Go. Fiber 2.29.0 è stato testato con la versioni 1.14 alla 1.19 di Go.
* Dato che Fiber utilizza unsafe, la libreria non sempre potrebbe essere compatibile con l'ultima versione di Go. Fiber 2.40.0 è stato testato con la versioni 1.16 alla 1.19 di Go.
* Fiber non è compatibile con le interfacce net/http. Questo significa che non è possibile utilizzare progetti come qglgen, go-swagger, o altri che fanno parte dell'ecosistema net/http.
## 👀 Esempi

View File

@ -147,7 +147,7 @@ Fiber は人気の高い Web フレームワークである Expressjs に**イ
## ⚠️ 制限事項
- Fiber は unsafe パッケージを使用しているため、最新の Go バージョンと互換性がない場合があります。Fiber 2.29.0 は、Go のバージョン 1.14 から 1.19 でテストされています。
- Fiber は unsafe パッケージを使用しているため、最新の Go バージョンと互換性がない場合があります。Fiber 2.40.0 は、Go のバージョン 1.16 から 1.19 でテストされています。
- Fiber は net/http インターフェースと互換性がありません。つまり、gqlgen や go-swagger など、net/http のエコシステムの一部であるプロジェクトを使用することができません。
## 👀 例

View File

@ -144,7 +144,7 @@ Fiber는 인터넷에서 가장 인기있는 웹 프레임워크인 Express에
우리는 **어떤한** 작업, **마감일정**, 개발자의 **기술**이던간에 **빠르고**, **유연하고**, **익숙한** Go 웹 프레임워크를 만들기 위해 사용자들의 [이슈들](https://github.com/gofiber/fiber/issues)을(그리고 모든 인터넷을 통해) **듣고 있습니다**! Express가 자바스크립트 세계에서 하는 것 처럼요.
## ⚠️ 한계점
* Fiber는 unsafe 패키지를 사용하기 때문에 최신 Go버전과 호환되지 않을 수 있습니다.Fiber 2.29.0은 Go 버전 1.14에서 1.19로 테스트되고 있습니다.
* Fiber는 unsafe 패키지를 사용하기 때문에 최신 Go버전과 호환되지 않을 수 있습니다.Fiber 2.40.0은 Go 버전 1.16에서 1.19로 테스트되고 있습니다.
* Fiber는 net/http 인터페이스와 호환되지 않습니다.즉, gqlgen이나 go-swagger 등 net/http 생태계의 일부인 프로젝트를 사용할 수 없습니다.
## 👀 예제

View File

@ -144,7 +144,7 @@ Fiber is **geïnspireerd** door Express, het populairste webframework op interne
We **luisteren** naar onze gebruikers in [issues](https://github.com/gofiber/fiber/issues) (_en overal op het internet_) om een **snelle**, **flexibele** en **vriendelijk** Go web framework te maken voor **elke** taak, **deadline** en ontwikkelaar **vaardigheid**! Net zoals Express dat doet in de JavaScript-wereld.
## ⚠️ Limitations
* Due to Fiber's usage of unsafe, the library may not always be compatible with the latest Go version. Fiber 2.29.0 has been tested with Go versions 1.14 to 1.19.
* Due to Fiber's usage of unsafe, the library may not always be compatible with the latest Go version. Fiber 2.40.0 has been tested with Go versions 1.16 to 1.19.
* Fiber is not compatible with net/http interfaces. This means you will not be able to use projects like gqlgen, go-swagger, or any others which are part of the net/http ecosystem.
## 👀 Voorbeelden

View File

@ -142,7 +142,7 @@ Os novos gophers que mudaram do [Node.js](https://nodejs.org/en/about/) para o [
O Fiber é **inspirado** no Express, o framework web mais popular da Internet. Combinamos a **facilidade** do Express e com o **desempenho bruto** do Go. Se você já implementou um aplicativo web com Node.js ( _usando Express.js ou similar_ ), então muitos métodos e princípios parecerão **muito familiares** para você.
## ⚠️ Limitations
* Due to Fiber's usage of unsafe, the library may not always be compatible with the latest Go version. Fiber 2.29.0 has been tested with Go versions 1.14 to 1.19.
* Due to Fiber's usage of unsafe, the library may not always be compatible with the latest Go version. Fiber 2.40.0 has been tested with Go versions 1.16 to 1.19.
* Fiber is not compatible with net/http interfaces. This means you will not be able to use projects like gqlgen, go-swagger, or any others which are part of the net/http ecosystem.
## 👀 Exemplos

View File

@ -144,7 +144,7 @@ Fiber **вдохновлен** Express, самым популярным веб
Мы **прислушиваемся** к нашим пользователям в [issues](https://github.com/gofiber/fiber/issues), Discord [канале](https://gofiber.io/discord) _и в остальном Интернете_, чтобы создать **быстрый**, **гибкий** и **дружелюбный** веб фреймворк на Go для **любых** задач, **дедлайнов** и **уровней** разработчиков! Как это делает Express в мире JavaScript.
## ⚠️ Limitations
* Due to Fiber's usage of unsafe, the library may not always be compatible with the latest Go version. Fiber 2.29.0 has been tested with Go versions 1.14 to 1.19.
* Due to Fiber's usage of unsafe, the library may not always be compatible with the latest Go version. Fiber 2.40.0 has been tested with Go versions 1.16 to 1.19.
* Fiber is not compatible with net/http interfaces. This means you will not be able to use projects like gqlgen, go-swagger, or any others which are part of the net/http ecosystem.
## 👀 Примеры

View File

@ -158,7 +158,7 @@ Fiber هو **مستوحى** من Express, إطار الويب الأكثر شع
** و تطوير **مهارات**! فقط مثل Express تفعل لـ JavaScript عالم.
## ⚠️ Limitations
* Due to Fiber's usage of unsafe, the library may not always be compatible with the latest Go version. Fiber 2.29.0 has been tested with Go versions 1.14 to 1.19.
* Due to Fiber's usage of unsafe, the library may not always be compatible with the latest Go version. Fiber 2.40.0 has been tested with Go versions 1.16 to 1.19.
* Fiber is not compatible with net/http interfaces. This means you will not be able to use projects like gqlgen, go-swagger, or any others which are part of the net/http ecosystem.
## 👀 أمثلة

View File

@ -143,7 +143,7 @@ Fiber, internet üzerinde en popüler web framework'ü olan Express'ten **esinle
## ⚠️ Sınırlamalar
- Fiber unsafe kullanımı sebebiyle Go'nun son sürümüyle her zaman uyumlu olmayabilir. Fiber 2.29.0, Go 1.14 ile 1.19 sürümleriyle test edildi.
- Fiber unsafe kullanımı sebebiyle Go'nun son sürümüyle her zaman uyumlu olmayabilir. Fiber 2.40.0, Go 1.14 ile 1.19 sürümleriyle test edildi.
- Fiber net/http arabirimiyle uyumlu değildir. Yani gqlgen veya go-swagger gibi net/http ekosisteminin parçası olan projeleri kullanamazsınız.
## 👀 Örnekler

View File

@ -144,7 +144,7 @@ go get -u github.com/gofiber/fiber/v2
我们会**倾听**用户在[issues](https://github.com/gofiber/fiber/issues)和 Discord [channel](https://gofiber.io/discord)和在互联网上的所有诉求为了创建一个能让有着任何技术栈的开发者都能在deadline前完成任务的**迅速****灵活**以及**友好**的`Go web`框架,就像`Express`在`JavaScript`世界中一样。
## ⚠️ 限制
* 由于 Fiber 使用了 unsafe 特性,导致其可能与最新的 Go 版本不兼容。Fiber 2.29.0 已经在 Go 1.14 到 1.19 上测试过。
* 由于 Fiber 使用了 unsafe 特性,导致其可能与最新的 Go 版本不兼容。Fiber 2.40.0 已经在 Go 1.16 到 1.19 上测试过。
* Fiber 与 net/http 接口不兼容。也就是说你无法使用 gqlengo-swagger 或者任何其他属于 net/http 生态的项目。
## 👀 示例

View File

@ -144,7 +144,7 @@ Fiber **受到** 網路上最流行的 Web 框架 ExpressJS**啟發**,結合 E
有什麼問題請發[issues](https://github.com/gofiber/fiber/issues)或加入 Discord [channel](https://gofiber.io/discord)討論,我們想要創造**快速**、**彈性**、**友善**的社群給**任何人**使用!就像 Express 那樣。
## 限制
* 由於 Fiber 使用了 unsafe該庫可能並不總是與最新的 Go 版本兼容。 Fiber 2.29.0 已經用 Go 版本 1.14 到 1.19 進行了測試。
* 由於 Fiber 使用了 unsafe該庫可能並不總是與最新的 Go 版本兼容。 Fiber 2.40.0 已經用 Go 版本 1.16 到 1.19 進行了測試。
* Fiber 與 net/http 接口不兼容。 這意味著您將無法使用 gqlgen、go-swagger 或任何其他屬於 net/http 生態系統的項目。
## 👀 範例

View File

@ -8,7 +8,7 @@ jobs:
Build:
strategy:
matrix:
go-version: [1.14.x, 1.16.x, 1.19.x]
go-version: [1.16.x, 1.17.x, 1.19.x]
platform: [ubuntu-latest, windows-latest, macos-latest]
runs-on: ${{ matrix.platform }}
steps:

View File

@ -10,7 +10,6 @@ import (
"errors"
"fmt"
"io"
"io/ioutil"
"mime/multipart"
"net"
"net/http"
@ -44,7 +43,7 @@ func testErrorResponse(t *testing.T, err error, resp *http.Response, expectedBod
utils.AssertEqual(t, nil, err, "app.Test(req)")
utils.AssertEqual(t, 500, resp.StatusCode, "Status code")
body, err := ioutil.ReadAll(resp.Body)
body, err := io.ReadAll(resp.Body)
utils.AssertEqual(t, nil, err)
utils.AssertEqual(t, expectedBodyError, string(body), "Response body")
}
@ -162,7 +161,7 @@ func Test_App_Errors(t *testing.T) {
utils.AssertEqual(t, nil, err, "app.Test(req)")
utils.AssertEqual(t, 500, resp.StatusCode, "Status code")
body, err := ioutil.ReadAll(resp.Body)
body, err := io.ReadAll(resp.Body)
utils.AssertEqual(t, nil, err)
utils.AssertEqual(t, "hi, i'm an error", string(body))
@ -187,7 +186,7 @@ func Test_App_ErrorHandler_Custom(t *testing.T) {
utils.AssertEqual(t, nil, err, "app.Test(req)")
utils.AssertEqual(t, 200, resp.StatusCode, "Status code")
body, err := ioutil.ReadAll(resp.Body)
body, err := io.ReadAll(resp.Body)
utils.AssertEqual(t, nil, err)
utils.AssertEqual(t, "hi, i'm an custom error", string(body))
}
@ -216,7 +215,7 @@ func Test_App_ErrorHandler_HandlerStack(t *testing.T) {
utils.AssertEqual(t, nil, err, "app.Test(req)")
utils.AssertEqual(t, 500, resp.StatusCode, "Status code")
body, err := ioutil.ReadAll(resp.Body)
body, err := io.ReadAll(resp.Body)
utils.AssertEqual(t, nil, err)
utils.AssertEqual(t, "1: USE error", string(body))
}
@ -241,7 +240,7 @@ func Test_App_ErrorHandler_RouteStack(t *testing.T) {
utils.AssertEqual(t, nil, err, "app.Test(req)")
utils.AssertEqual(t, 500, resp.StatusCode, "Status code")
body, err := ioutil.ReadAll(resp.Body)
body, err := io.ReadAll(resp.Body)
utils.AssertEqual(t, nil, err)
utils.AssertEqual(t, "1: USE error", string(body))
}
@ -328,7 +327,7 @@ func Test_App_Use_UnescapedPath(t *testing.T) {
utils.AssertEqual(t, nil, err, "app.Test(req)")
utils.AssertEqual(t, StatusOK, resp.StatusCode, "Status code")
body, err := ioutil.ReadAll(resp.Body)
body, err := io.ReadAll(resp.Body)
utils.AssertEqual(t, nil, err, "app.Test(req)")
// check the param result
utils.AssertEqual(t, "اختبار", app.getString(body))
@ -363,7 +362,7 @@ func Test_App_Use_CaseSensitive(t *testing.T) {
utils.AssertEqual(t, nil, err, "app.Test(req)")
utils.AssertEqual(t, StatusOK, resp.StatusCode, "Status code")
body, err := ioutil.ReadAll(resp.Body)
body, err := io.ReadAll(resp.Body)
utils.AssertEqual(t, nil, err, "app.Test(req)")
// check the detected path result
utils.AssertEqual(t, "/AbC", app.getString(body))
@ -534,7 +533,7 @@ func Test_App_Order(t *testing.T) {
utils.AssertEqual(t, nil, err, "app.Test(req)")
utils.AssertEqual(t, 200, resp.StatusCode, "Status code")
body, err := ioutil.ReadAll(resp.Body)
body, err := io.ReadAll(resp.Body)
utils.AssertEqual(t, nil, err)
utils.AssertEqual(t, "123", string(body))
}
@ -656,7 +655,7 @@ func Test_App_Static_Index_Default(t *testing.T) {
utils.AssertEqual(t, false, resp.Header.Get(HeaderContentLength) == "")
utils.AssertEqual(t, MIMETextHTMLCharsetUTF8, resp.Header.Get(HeaderContentType))
body, err := ioutil.ReadAll(resp.Body)
body, err := io.ReadAll(resp.Body)
utils.AssertEqual(t, nil, err)
utils.AssertEqual(t, true, strings.Contains(string(body), "Hello, World!"))
@ -666,7 +665,7 @@ func Test_App_Static_Index_Default(t *testing.T) {
utils.AssertEqual(t, false, resp.Header.Get(HeaderContentLength) == "")
utils.AssertEqual(t, MIMETextPlainCharsetUTF8, resp.Header.Get(HeaderContentType))
body, err = ioutil.ReadAll(resp.Body)
body, err = io.ReadAll(resp.Body)
utils.AssertEqual(t, nil, err)
utils.AssertEqual(t, "Cannot GET /not-found", string(body))
}
@ -683,7 +682,7 @@ func Test_App_Static_Direct(t *testing.T) {
utils.AssertEqual(t, false, resp.Header.Get(HeaderContentLength) == "")
utils.AssertEqual(t, MIMETextHTMLCharsetUTF8, resp.Header.Get(HeaderContentType))
body, err := ioutil.ReadAll(resp.Body)
body, err := io.ReadAll(resp.Body)
utils.AssertEqual(t, nil, err)
utils.AssertEqual(t, true, strings.Contains(string(body), "Hello, World!"))
@ -694,7 +693,7 @@ func Test_App_Static_Direct(t *testing.T) {
utils.AssertEqual(t, MIMEApplicationJSON, resp.Header.Get("Content-Type"))
utils.AssertEqual(t, "", resp.Header.Get(HeaderCacheControl), "CacheControl Control")
body, err = ioutil.ReadAll(resp.Body)
body, err = io.ReadAll(resp.Body)
utils.AssertEqual(t, nil, err)
utils.AssertEqual(t, true, strings.Contains(string(body), "testRoutes"))
}
@ -791,7 +790,7 @@ func Test_App_Static_Wildcard(t *testing.T) {
utils.AssertEqual(t, false, resp.Header.Get(HeaderContentLength) == "")
utils.AssertEqual(t, MIMETextHTMLCharsetUTF8, resp.Header.Get(HeaderContentType))
body, err := ioutil.ReadAll(resp.Body)
body, err := io.ReadAll(resp.Body)
utils.AssertEqual(t, nil, err)
utils.AssertEqual(t, true, strings.Contains(string(body), "Test file"))
}
@ -816,7 +815,7 @@ func Test_App_Static_Prefix_Wildcard(t *testing.T) {
utils.AssertEqual(t, false, resp.Header.Get(HeaderContentLength) == "")
utils.AssertEqual(t, MIMETextHTMLCharsetUTF8, resp.Header.Get(HeaderContentType))
body, err := ioutil.ReadAll(resp.Body)
body, err := io.ReadAll(resp.Body)
utils.AssertEqual(t, nil, err)
utils.AssertEqual(t, true, strings.Contains(string(body), "Test file"))
}
@ -919,7 +918,7 @@ func Test_App_Static_Next(t *testing.T) {
utils.AssertEqual(t, false, resp.Header.Get(HeaderContentLength) == "")
utils.AssertEqual(t, MIMETextPlainCharsetUTF8, resp.Header.Get(HeaderContentType))
body, err := ioutil.ReadAll(resp.Body)
body, err := io.ReadAll(resp.Body)
utils.AssertEqual(t, nil, err)
utils.AssertEqual(t, true, strings.Contains(string(body), "You've skipped app.Static"))
})
@ -933,7 +932,7 @@ func Test_App_Static_Next(t *testing.T) {
utils.AssertEqual(t, false, resp.Header.Get(HeaderContentLength) == "")
utils.AssertEqual(t, MIMETextHTMLCharsetUTF8, resp.Header.Get(HeaderContentType))
body, err := ioutil.ReadAll(resp.Body)
body, err := io.ReadAll(resp.Body)
utils.AssertEqual(t, nil, err)
utils.AssertEqual(t, true, strings.Contains(string(body), "Hello, World!"))
})
@ -964,7 +963,7 @@ func Test_App_Mixed_Routes_WithSameLen(t *testing.T) {
utils.AssertEqual(t, "TestValue", resp.Header.Get("TestHeader"))
utils.AssertEqual(t, "text/html", resp.Header.Get(HeaderContentType))
body, err := ioutil.ReadAll(resp.Body)
body, err := io.ReadAll(resp.Body)
utils.AssertEqual(t, nil, err)
utils.AssertEqual(t, "FOO_BAR", string(body))
@ -977,7 +976,7 @@ func Test_App_Mixed_Routes_WithSameLen(t *testing.T) {
utils.AssertEqual(t, "TestValue", resp.Header.Get("TestHeader"))
utils.AssertEqual(t, "text/html; charset=utf-8", resp.Header.Get(HeaderContentType))
body, err = ioutil.ReadAll(resp.Body)
body, err = io.ReadAll(resp.Body)
utils.AssertEqual(t, nil, err)
utils.AssertEqual(t, true, strings.Contains(string(body), "Hello, World!"), "Response: "+string(body))
utils.AssertEqual(t, true, strings.HasPrefix(string(body), "<!DOCTYPE html>"), "Response: "+string(body))
@ -1415,8 +1414,8 @@ func Test_App_ReadBodyStream(t *testing.T) {
testString := "this is a test"
resp, err := app.Test(httptest.NewRequest("POST", "/", bytes.NewBufferString(testString)))
utils.AssertEqual(t, nil, err, "app.Test(req)")
body, err := ioutil.ReadAll(resp.Body)
utils.AssertEqual(t, nil, err, "ioutil.ReadAll(resp.Body)")
body, err := io.ReadAll(resp.Body)
utils.AssertEqual(t, nil, err, "io.ReadAll(resp.Body)")
utils.AssertEqual(t, fmt.Sprintf("true %s", testString), string(body))
}
@ -1461,8 +1460,8 @@ func Test_App_DisablePreParseMultipartForm(t *testing.T) {
req.Header.Set("Content-Type", w.FormDataContentType())
resp, err := app.Test(req)
utils.AssertEqual(t, nil, err, "app.Test(req)")
body, err := ioutil.ReadAll(resp.Body)
utils.AssertEqual(t, nil, err, "ioutil.ReadAll(resp.Body)")
body, err := io.ReadAll(resp.Body)
utils.AssertEqual(t, nil, err, "io.ReadAll(resp.Body)")
utils.AssertEqual(t, testString, string(body))
}

View File

@ -7,7 +7,6 @@ import (
"encoding/xml"
"fmt"
"io"
"io/ioutil"
"mime/multipart"
"net"
"os"
@ -542,7 +541,7 @@ func (a *Agent) FileData(formFiles ...*FormFile) *Agent {
// SendFile reads file and appends it to multipart form request.
func (a *Agent) SendFile(filename string, fieldname ...string) *Agent {
content, err := ioutil.ReadFile(filepath.Clean(filename))
content, err := os.ReadFile(filepath.Clean(filename))
if err != nil {
a.errs = append(a.errs, err)
return a

View File

@ -8,9 +8,9 @@ import (
"errors"
"fmt"
"io"
"io/ioutil"
"mime/multipart"
"net"
"os"
"path/filepath"
"regexp"
"strings"
@ -811,7 +811,7 @@ func checkFormFile(t *testing.T, fh *multipart.FileHeader, filename string) {
basename := filepath.Base(filename)
utils.AssertEqual(t, fh.Filename, basename)
b1, err := ioutil.ReadFile(filename)
b1, err := os.ReadFile(filename)
utils.AssertEqual(t, nil, err)
b2 := make([]byte, fh.Size)

3
ctx.go
View File

@ -13,7 +13,6 @@ import (
"errors"
"fmt"
"io"
"io/ioutil"
"mime/multipart"
"net"
"net/http"
@ -1489,7 +1488,7 @@ func (c *Ctx) SaveFileToStorage(fileheader *multipart.FileHeader, path string, s
return err
}
content, err := ioutil.ReadAll(file)
content, err := io.ReadAll(file)
if err != nil {
return err
}

View File

@ -17,7 +17,6 @@ import (
"errors"
"fmt"
"io"
"io/ioutil"
"mime/multipart"
"net/http/httptest"
"net/url"
@ -670,7 +669,7 @@ func Test_Ctx_UserContext_Multiple_Requests(t *testing.T) {
utils.AssertEqual(t, nil, err, "Unexpected error from response")
utils.AssertEqual(t, StatusOK, resp.StatusCode, "context.Context returned from c.UserContext() is reused")
b, err := ioutil.ReadAll(resp.Body)
b, err := io.ReadAll(resp.Body)
utils.AssertEqual(t, nil, err, "Unexpected error from reading response body")
utils.AssertEqual(t, fmt.Sprintf("resp_%d_returned", i), string(b), "response text incorrect")
})
@ -1129,7 +1128,7 @@ func Test_Ctx_PortInHandler(t *testing.T) {
utils.AssertEqual(t, nil, err, "app.Test(req)")
utils.AssertEqual(t, StatusOK, resp.StatusCode, "Status code")
body, err := ioutil.ReadAll(resp.Body)
body, err := io.ReadAll(resp.Body)
utils.AssertEqual(t, nil, err)
utils.AssertEqual(t, "0", string(body))
}
@ -1527,7 +1526,7 @@ func Test_Ctx_ClientHelloInfo(t *testing.T) {
// Test without TLS handler
resp, _ := app.Test(httptest.NewRequest(MethodGet, "/ServerName", nil))
body, _ := ioutil.ReadAll(resp.Body)
body, _ := io.ReadAll(resp.Body)
utils.AssertEqual(t, []byte("ClientHelloInfo is nil"), body)
// Test with TLS Handler
@ -1543,17 +1542,17 @@ func Test_Ctx_ClientHelloInfo(t *testing.T) {
// Test ServerName
resp, _ = app.Test(httptest.NewRequest(MethodGet, "/ServerName", nil))
body, _ = ioutil.ReadAll(resp.Body)
body, _ = io.ReadAll(resp.Body)
utils.AssertEqual(t, []byte("example.golang"), body)
// Test SignatureSchemes
resp, _ = app.Test(httptest.NewRequest(MethodGet, "/SignatureSchemes", nil))
body, _ = ioutil.ReadAll(resp.Body)
body, _ = io.ReadAll(resp.Body)
utils.AssertEqual(t, "["+strconv.Itoa(PSSWithSHA256)+"]", string(body))
// Test SupportedVersions
resp, _ = app.Test(httptest.NewRequest(MethodGet, "/SupportedVersions", nil))
body, _ = ioutil.ReadAll(resp.Body)
body, _ = io.ReadAll(resp.Body)
utils.AssertEqual(t, "["+strconv.Itoa(VersionTLS13)+"]", string(body))
}
@ -2106,14 +2105,14 @@ func Test_Ctx_SaveFile(t *testing.T) {
fh, err := c.FormFile("file")
utils.AssertEqual(t, nil, err)
tempFile, err := ioutil.TempFile(os.TempDir(), "test-")
tempFile, err := os.CreateTemp(os.TempDir(), "test-")
utils.AssertEqual(t, nil, err)
defer os.Remove(tempFile.Name())
err = c.SaveFile(fh, tempFile.Name())
utils.AssertEqual(t, nil, err)
bs, err := ioutil.ReadFile(tempFile.Name())
bs, err := os.ReadFile(tempFile.Name())
utils.AssertEqual(t, nil, err)
utils.AssertEqual(t, "hello world", string(bs))
return nil
@ -2257,7 +2256,7 @@ func Test_Ctx_Download(t *testing.T) {
utils.AssertEqual(t, nil, err)
defer f.Close()
expect, err := ioutil.ReadAll(f)
expect, err := io.ReadAll(f)
utils.AssertEqual(t, nil, err)
utils.AssertEqual(t, expect, c.Response().Body())
utils.AssertEqual(t, `attachment; filename="Awesome+File%21"`, string(c.Response().Header.Peek(HeaderContentDisposition)))
@ -2275,7 +2274,7 @@ func Test_Ctx_SendFile(t *testing.T) {
f, err := os.Open("./ctx.go")
utils.AssertEqual(t, nil, err)
defer f.Close()
expectFileContent, err := ioutil.ReadAll(f)
expectFileContent, err := io.ReadAll(f)
utils.AssertEqual(t, nil, err)
// fetch file info for the not modified test case
fI, err := os.Stat("./ctx.go")
@ -3278,7 +3277,7 @@ func Test_Ctx_Render_Engine_Error(t *testing.T) {
func Test_Ctx_Render_Go_Template(t *testing.T) {
t.Parallel()
file, err := ioutil.TempFile(os.TempDir(), "fiber")
file, err := os.CreateTemp(os.TempDir(), "fiber")
utils.AssertEqual(t, nil, err)
defer os.Remove(file.Name())

View File

@ -12,7 +12,6 @@ import (
"context"
"errors"
"fmt"
"io/ioutil"
"log"
"net/url"
"os"
@ -84,7 +83,7 @@ func (i FakeInvoke) Command(name string, arg ...string) ([]byte, error) {
fpath += "_" + i.Suffix
}
if PathExists(fpath) {
return ioutil.ReadFile(fpath)
return os.ReadFile(fpath)
}
return []byte{}, fmt.Errorf("could not find testdata: %s", fpath)
}
@ -97,7 +96,7 @@ var ErrNotImplementedError = errors.New("not implemented yet")
// ReadFile reads contents from a file
func ReadFile(filename string) (string, error) {
content, err := ioutil.ReadFile(filename)
content, err := os.ReadFile(filename)
if err != nil {
return "", err

View File

@ -5,7 +5,7 @@ package load
import (
"context"
"io/ioutil"
"os"
"strconv"
"strings"
"syscall"
@ -76,7 +76,7 @@ func Misc() (*MiscStat, error) {
func MiscWithContext(ctx context.Context) (*MiscStat, error) {
filename := common.HostProc("stat")
out, err := ioutil.ReadFile(filename)
out, err := os.ReadFile(filename)
if err != nil {
return nil, err
}
@ -126,7 +126,7 @@ func getProcsTotal() (int64, error) {
func readLoadAvgFromFile() ([]string, error) {
loadavgFilename := common.HostProc("loadavg")
line, err := ioutil.ReadFile(loadavgFilename)
line, err := os.ReadFile(loadavgFilename)
if err != nil {
return nil, err
}

View File

@ -10,7 +10,6 @@ import (
"errors"
"fmt"
"io"
"io/ioutil"
"net"
"os"
"strconv"
@ -637,7 +636,7 @@ func (p *process) getUids() ([]int32, error) {
func (p *process) fillFromStatus() error {
pid := p.Pid
statPath := common.HostProc(strconv.Itoa(int(pid)), "status")
contents, err := ioutil.ReadFile(statPath)
contents, err := os.ReadFile(statPath)
if err != nil {
return err
}
@ -759,7 +758,7 @@ func processInet(file string, kind netConnectionKindType, inodes map[string][]in
// This minimizes duplicates in the returned connections
// For more info:
// https://github.com/shirou/gopsutil/pull/361
contents, err := ioutil.ReadFile(file)
contents, err := os.ReadFile(file)
if err != nil {
return nil, err
}
@ -820,7 +819,7 @@ func processUnix(file string, kind netConnectionKindType, inodes map[string][]in
// This minimizes duplicates in the returned connections
// For more info:
// https://github.com/shirou/gopsutil/pull/361
contents, err := ioutil.ReadFile(file)
contents, err := os.ReadFile(file)
if err != nil {
return nil, err
}

View File

@ -9,7 +9,6 @@ import (
"context"
"encoding/json"
"fmt"
"io/ioutil"
"math"
"os"
"path/filepath"
@ -190,7 +189,7 @@ func (p *Process) ForegroundWithContext(ctx context.Context) (bool, error) {
// see https://github.com/shirou/gopsutil/issues/596#issuecomment-432707831 for implementation details
pid := p.Pid
statPath := common.HostProc(strconv.Itoa(int(pid)), "stat")
contents, err := ioutil.ReadFile(statPath)
contents, err := os.ReadFile(statPath)
if err != nil {
return false, err
}
@ -566,7 +565,7 @@ func (p *Process) MemoryMapsWithContext(ctx context.Context, grouped bool) (*[]M
ret = make([]MemoryMapsStat, 1)
}
smapsPath := common.HostProc(strconv.Itoa(int(pid)), "smaps")
contents, err := ioutil.ReadFile(smapsPath)
contents, err := os.ReadFile(smapsPath)
if err != nil {
return nil, err
}
@ -830,7 +829,7 @@ func (p *Process) fillFromExeWithContext(ctx context.Context) (string, error) {
func (p *Process) fillFromCmdlineWithContext(ctx context.Context) (string, error) {
pid := p.Pid
cmdPath := common.HostProc(strconv.Itoa(int(pid)), "cmdline")
cmdline, err := ioutil.ReadFile(cmdPath)
cmdline, err := os.ReadFile(cmdPath)
if err != nil {
return "", err
}
@ -847,7 +846,7 @@ func (p *Process) fillFromCmdlineWithContext(ctx context.Context) (string, error
func (p *Process) fillSliceFromCmdlineWithContext(ctx context.Context) ([]string, error) {
pid := p.Pid
cmdPath := common.HostProc(strconv.Itoa(int(pid)), "cmdline")
cmdline, err := ioutil.ReadFile(cmdPath)
cmdline, err := os.ReadFile(cmdPath)
if err != nil {
return nil, err
}
@ -870,7 +869,7 @@ func (p *Process) fillSliceFromCmdlineWithContext(ctx context.Context) ([]string
func (p *Process) fillFromIOWithContext(ctx context.Context) (*IOCountersStat, error) {
pid := p.Pid
ioPath := common.HostProc(strconv.Itoa(int(pid)), "io")
ioline, err := ioutil.ReadFile(ioPath)
ioline, err := os.ReadFile(ioPath)
if err != nil {
return nil, err
}
@ -909,7 +908,7 @@ func (p *Process) fillFromIOWithContext(ctx context.Context) (*IOCountersStat, e
func (p *Process) fillFromStatmWithContext(ctx context.Context) (*MemoryInfoStat, *MemoryInfoExStat, error) {
pid := p.Pid
memPath := common.HostProc(strconv.Itoa(int(pid)), "statm")
contents, err := ioutil.ReadFile(memPath)
contents, err := os.ReadFile(memPath)
if err != nil {
return nil, nil, err
}
@ -961,7 +960,7 @@ func (p *Process) fillFromStatmWithContext(ctx context.Context) (*MemoryInfoStat
func (p *Process) fillFromStatusWithContext(ctx context.Context) error {
pid := p.Pid
statPath := common.HostProc(strconv.Itoa(int(pid)), "status")
contents, err := ioutil.ReadFile(statPath)
contents, err := os.ReadFile(statPath)
if err != nil {
return err
}
@ -1147,7 +1146,7 @@ func (p *Process) fillFromTIDStatWithContext(ctx context.Context, tid int32) (ui
statPath = common.HostProc(strconv.Itoa(int(pid)), "task", strconv.Itoa(int(tid)), "stat")
}
contents, err := ioutil.ReadFile(statPath)
contents, err := os.ReadFile(statPath)
if err != nil {
return 0, 0, nil, 0, 0, 0, nil, err
}

View File

@ -4,7 +4,7 @@
package msgp
import (
"io/ioutil"
"io"
"os"
)
@ -21,7 +21,7 @@ func ReadFile(dst Unmarshaler, file *os.File) error {
return u.DecodeMsg(NewReader(file))
}
data, err := ioutil.ReadAll(file)
data, err := io.ReadAll(file)
if err != nil {
return err
}

View File

@ -1,7 +1,7 @@
package utils
import (
"io/ioutil"
"io"
"net/http"
"os"
pathpkg "path"
@ -30,9 +30,9 @@ func ReadFile(path string, fs http.FileSystem) ([]byte, error) {
return nil, err
}
defer file.Close()
return ioutil.ReadAll(file)
return io.ReadAll(file)
}
return ioutil.ReadFile(path)
return os.ReadFile(path)
}
// readDirNames reads the directory named by dirname and returns

View File

@ -9,7 +9,6 @@ import (
"crypto/x509"
"errors"
"fmt"
"io/ioutil"
"net"
"os"
"path/filepath"
@ -154,7 +153,7 @@ func (app *App) ListenMutualTLS(addr, certFile, keyFile, clientCertFile string)
return fmt.Errorf("tls: cannot load TLS key pair from certFile=%q and keyFile=%q: %s", certFile, keyFile, err)
}
clientCACert, err := ioutil.ReadFile(filepath.Clean(clientCertFile))
clientCACert, err := os.ReadFile(filepath.Clean(clientCertFile))
if err != nil {
return err
}

View File

@ -2,7 +2,7 @@ package basicauth
import (
"fmt"
"io/ioutil"
"io"
"net/http/httptest"
"testing"
@ -82,7 +82,7 @@ func Test_Middleware_BasicAuth(t *testing.T) {
resp, err := app.Test(req)
utils.AssertEqual(t, nil, err)
body, err := ioutil.ReadAll(resp.Body)
body, err := io.ReadAll(resp.Body)
utils.AssertEqual(t, nil, err)
utils.AssertEqual(t, tt.statusCode, resp.StatusCode)

View File

@ -6,17 +6,17 @@ import (
"bytes"
"fmt"
"io"
"io/ioutil"
"math"
"net/http"
"net/http/httptest"
"os"
"strconv"
"testing"
"time"
"github.com/gofiber/fiber/v2"
"github.com/gofiber/fiber/v2/middleware/etag"
"github.com/gofiber/fiber/v2/internal/storage/memory"
"github.com/gofiber/fiber/v2/middleware/etag"
"github.com/gofiber/fiber/v2/utils"
"github.com/valyala/fasthttp"
)
@ -55,7 +55,7 @@ func Test_Cache_Expired(t *testing.T) {
resp, err := app.Test(httptest.NewRequest("GET", "/", nil))
utils.AssertEqual(t, nil, err)
body, err := ioutil.ReadAll(resp.Body)
body, err := io.ReadAll(resp.Body)
utils.AssertEqual(t, nil, err)
// Sleep until the cache is expired
@ -63,7 +63,7 @@ func Test_Cache_Expired(t *testing.T) {
respCached, err := app.Test(httptest.NewRequest("GET", "/", nil))
utils.AssertEqual(t, nil, err)
bodyCached, err := ioutil.ReadAll(respCached.Body)
bodyCached, err := io.ReadAll(respCached.Body)
utils.AssertEqual(t, nil, err)
if bytes.Equal(body, bodyCached) {
@ -73,7 +73,7 @@ func Test_Cache_Expired(t *testing.T) {
// Next response should be also cached
respCachedNextRound, err := app.Test(httptest.NewRequest("GET", "/", nil))
utils.AssertEqual(t, nil, err)
bodyCachedNextRound, err := ioutil.ReadAll(respCachedNextRound.Body)
bodyCachedNextRound, err := io.ReadAll(respCachedNextRound.Body)
utils.AssertEqual(t, nil, err)
if !bytes.Equal(bodyCachedNextRound, bodyCached) {
@ -100,9 +100,9 @@ func Test_Cache(t *testing.T) {
cachedResp, err := app.Test(cachedReq)
utils.AssertEqual(t, nil, err)
body, err := ioutil.ReadAll(resp.Body)
body, err := io.ReadAll(resp.Body)
utils.AssertEqual(t, nil, err)
cachedBody, err := ioutil.ReadAll(cachedResp.Body)
cachedBody, err := io.ReadAll(cachedResp.Body)
utils.AssertEqual(t, nil, err)
utils.AssertEqual(t, cachedBody, body)
@ -123,7 +123,7 @@ func Test_Cache_WithNoCacheRequestDirective(t *testing.T) {
req := httptest.NewRequest("GET", "/", nil)
resp, err := app.Test(req)
defer resp.Body.Close()
body, _ := ioutil.ReadAll(resp.Body)
body, _ := io.ReadAll(resp.Body)
utils.AssertEqual(t, nil, err)
utils.AssertEqual(t, cacheMiss, resp.Header.Get("X-Cache"))
utils.AssertEqual(t, []byte("1"), body)
@ -133,7 +133,7 @@ func Test_Cache_WithNoCacheRequestDirective(t *testing.T) {
cachedReq := httptest.NewRequest("GET", "/?id=2", nil)
cachedResp, err := app.Test(cachedReq)
defer cachedResp.Body.Close()
cachedBody, _ := ioutil.ReadAll(cachedResp.Body)
cachedBody, _ := io.ReadAll(cachedResp.Body)
utils.AssertEqual(t, nil, err)
utils.AssertEqual(t, cacheHit, cachedResp.Header.Get("X-Cache"))
utils.AssertEqual(t, []byte("1"), cachedBody)
@ -144,7 +144,7 @@ func Test_Cache_WithNoCacheRequestDirective(t *testing.T) {
noCacheReq.Header.Set(fiber.HeaderCacheControl, noCache)
noCacheResp, err := app.Test(noCacheReq)
defer noCacheResp.Body.Close()
noCacheBody, _ := ioutil.ReadAll(noCacheResp.Body)
noCacheBody, _ := io.ReadAll(noCacheResp.Body)
utils.AssertEqual(t, nil, err)
utils.AssertEqual(t, cacheMiss, noCacheResp.Header.Get("X-Cache"))
utils.AssertEqual(t, []byte("2"), noCacheBody)
@ -156,7 +156,7 @@ func Test_Cache_WithNoCacheRequestDirective(t *testing.T) {
noCacheReq1.Header.Set(fiber.HeaderCacheControl, noCache)
noCacheResp1, err := app.Test(noCacheReq1)
defer noCacheResp1.Body.Close()
noCacheBody1, _ := ioutil.ReadAll(noCacheResp1.Body)
noCacheBody1, _ := io.ReadAll(noCacheResp1.Body)
utils.AssertEqual(t, nil, err)
utils.AssertEqual(t, cacheMiss, noCacheResp1.Header.Get("X-Cache"))
utils.AssertEqual(t, []byte("2"), noCacheBody1)
@ -166,7 +166,7 @@ func Test_Cache_WithNoCacheRequestDirective(t *testing.T) {
cachedReq1 := httptest.NewRequest("GET", "/", nil)
cachedResp1, err := app.Test(cachedReq1)
defer cachedResp1.Body.Close()
cachedBody1, _ := ioutil.ReadAll(cachedResp1.Body)
cachedBody1, _ := io.ReadAll(cachedResp1.Body)
utils.AssertEqual(t, nil, err)
utils.AssertEqual(t, cacheHit, cachedResp1.Header.Get("X-Cache"))
utils.AssertEqual(t, []byte("2"), cachedBody1)
@ -255,7 +255,7 @@ func Test_Cache_WithNoStoreRequestDirective(t *testing.T) {
noStoreReq.Header.Set(fiber.HeaderCacheControl, noStore)
noStoreResp, err := app.Test(noStoreReq)
defer noStoreResp.Body.Close()
noStoreBody, _ := ioutil.ReadAll(noStoreResp.Body)
noStoreBody, _ := io.ReadAll(noStoreResp.Body)
utils.AssertEqual(t, nil, err)
utils.AssertEqual(t, []byte("2"), noStoreBody)
// Response not cached, returns updated response
@ -286,7 +286,7 @@ func Test_Cache_WithSeveralRequests(t *testing.T) {
utils.AssertEqual(t, nil, err)
}(rsp.Body)
idFromServ, err := ioutil.ReadAll(rsp.Body)
idFromServ, err := io.ReadAll(rsp.Body)
utils.AssertEqual(t, nil, err)
a, err := strconv.Atoi(string(idFromServ))
@ -319,9 +319,9 @@ func Test_Cache_Invalid_Expiration(t *testing.T) {
cachedResp, err := app.Test(cachedReq)
utils.AssertEqual(t, nil, err)
body, err := ioutil.ReadAll(resp.Body)
body, err := io.ReadAll(resp.Body)
utils.AssertEqual(t, nil, err)
cachedBody, err := ioutil.ReadAll(cachedResp.Body)
cachedBody, err := io.ReadAll(cachedResp.Body)
utils.AssertEqual(t, nil, err)
utils.AssertEqual(t, cachedBody, body)
@ -344,25 +344,25 @@ func Test_Cache_Get(t *testing.T) {
resp, err := app.Test(httptest.NewRequest("POST", "/?cache=123", nil))
utils.AssertEqual(t, nil, err)
body, err := ioutil.ReadAll(resp.Body)
body, err := io.ReadAll(resp.Body)
utils.AssertEqual(t, nil, err)
utils.AssertEqual(t, "123", string(body))
resp, err = app.Test(httptest.NewRequest("POST", "/?cache=12345", nil))
utils.AssertEqual(t, nil, err)
body, err = ioutil.ReadAll(resp.Body)
body, err = io.ReadAll(resp.Body)
utils.AssertEqual(t, nil, err)
utils.AssertEqual(t, "12345", string(body))
resp, err = app.Test(httptest.NewRequest("GET", "/get?cache=123", nil))
utils.AssertEqual(t, nil, err)
body, err = ioutil.ReadAll(resp.Body)
body, err = io.ReadAll(resp.Body)
utils.AssertEqual(t, nil, err)
utils.AssertEqual(t, "123", string(body))
resp, err = app.Test(httptest.NewRequest("GET", "/get?cache=12345", nil))
utils.AssertEqual(t, nil, err)
body, err = ioutil.ReadAll(resp.Body)
body, err = io.ReadAll(resp.Body)
utils.AssertEqual(t, nil, err)
utils.AssertEqual(t, "123", string(body))
}
@ -386,25 +386,25 @@ func Test_Cache_Post(t *testing.T) {
resp, err := app.Test(httptest.NewRequest("POST", "/?cache=123", nil))
utils.AssertEqual(t, nil, err)
body, err := ioutil.ReadAll(resp.Body)
body, err := io.ReadAll(resp.Body)
utils.AssertEqual(t, nil, err)
utils.AssertEqual(t, "123", string(body))
resp, err = app.Test(httptest.NewRequest("POST", "/?cache=12345", nil))
utils.AssertEqual(t, nil, err)
body, err = ioutil.ReadAll(resp.Body)
body, err = io.ReadAll(resp.Body)
utils.AssertEqual(t, nil, err)
utils.AssertEqual(t, "123", string(body))
resp, err = app.Test(httptest.NewRequest("GET", "/get?cache=123", nil))
utils.AssertEqual(t, nil, err)
body, err = ioutil.ReadAll(resp.Body)
body, err = io.ReadAll(resp.Body)
utils.AssertEqual(t, nil, err)
utils.AssertEqual(t, "123", string(body))
resp, err = app.Test(httptest.NewRequest("GET", "/get?cache=12345", nil))
utils.AssertEqual(t, nil, err)
body, err = ioutil.ReadAll(resp.Body)
body, err = io.ReadAll(resp.Body)
utils.AssertEqual(t, nil, err)
utils.AssertEqual(t, "12345", string(body))
}
@ -422,14 +422,14 @@ func Test_Cache_NothingToCache(t *testing.T) {
resp, err := app.Test(httptest.NewRequest("GET", "/", nil))
utils.AssertEqual(t, nil, err)
body, err := ioutil.ReadAll(resp.Body)
body, err := io.ReadAll(resp.Body)
utils.AssertEqual(t, nil, err)
time.Sleep(500 * time.Millisecond)
respCached, err := app.Test(httptest.NewRequest("GET", "/", nil))
utils.AssertEqual(t, nil, err)
bodyCached, err := ioutil.ReadAll(respCached.Body)
bodyCached, err := io.ReadAll(respCached.Body)
utils.AssertEqual(t, nil, err)
if bytes.Equal(body, bodyCached) {
@ -459,12 +459,12 @@ func Test_Cache_CustomNext(t *testing.T) {
resp, err := app.Test(httptest.NewRequest("GET", "/", nil))
utils.AssertEqual(t, nil, err)
body, err := ioutil.ReadAll(resp.Body)
body, err := io.ReadAll(resp.Body)
utils.AssertEqual(t, nil, err)
respCached, err := app.Test(httptest.NewRequest("GET", "/", nil))
utils.AssertEqual(t, nil, err)
bodyCached, err := ioutil.ReadAll(respCached.Body)
bodyCached, err := io.ReadAll(respCached.Body)
utils.AssertEqual(t, nil, err)
utils.AssertEqual(t, true, bytes.Equal(body, bodyCached))
utils.AssertEqual(t, true, respCached.Header.Get(fiber.HeaderCacheControl) != "")
@ -526,9 +526,9 @@ func Test_CustomExpiration(t *testing.T) {
cachedResp, err := app.Test(httptest.NewRequest("GET", "/", nil))
utils.AssertEqual(t, nil, err)
body, err := ioutil.ReadAll(resp.Body)
body, err := io.ReadAll(resp.Body)
utils.AssertEqual(t, nil, err)
cachedBody, err := ioutil.ReadAll(cachedResp.Body)
cachedBody, err := io.ReadAll(cachedResp.Body)
utils.AssertEqual(t, nil, err)
if bytes.Equal(body, cachedBody) {
@ -538,7 +538,7 @@ func Test_CustomExpiration(t *testing.T) {
// Next response should be cached
cachedRespNextRound, err := app.Test(httptest.NewRequest("GET", "/", nil))
utils.AssertEqual(t, nil, err)
cachedBodyNextRound, err := ioutil.ReadAll(cachedRespNextRound.Body)
cachedBodyNextRound, err := io.ReadAll(cachedRespNextRound.Body)
utils.AssertEqual(t, nil, err)
if !bytes.Equal(cachedBodyNextRound, cachedBody) {
@ -632,9 +632,9 @@ func Test_Cache_WithHead(t *testing.T) {
utils.AssertEqual(t, nil, err)
utils.AssertEqual(t, cacheHit, cachedResp.Header.Get("X-Cache"))
body, err := ioutil.ReadAll(resp.Body)
body, err := io.ReadAll(resp.Body)
utils.AssertEqual(t, nil, err)
cachedBody, err := ioutil.ReadAll(cachedResp.Body)
cachedBody, err := io.ReadAll(cachedResp.Body)
utils.AssertEqual(t, nil, err)
utils.AssertEqual(t, cachedBody, body)
@ -651,28 +651,28 @@ func Test_Cache_WithHeadThenGet(t *testing.T) {
headResp, err := app.Test(httptest.NewRequest("HEAD", "/?cache=123", nil))
utils.AssertEqual(t, nil, err)
headBody, err := ioutil.ReadAll(headResp.Body)
headBody, err := io.ReadAll(headResp.Body)
utils.AssertEqual(t, nil, err)
utils.AssertEqual(t, "", string(headBody))
utils.AssertEqual(t, cacheMiss, headResp.Header.Get("X-Cache"))
headResp, err = app.Test(httptest.NewRequest("HEAD", "/?cache=123", nil))
utils.AssertEqual(t, nil, err)
headBody, err = ioutil.ReadAll(headResp.Body)
headBody, err = io.ReadAll(headResp.Body)
utils.AssertEqual(t, nil, err)
utils.AssertEqual(t, "", string(headBody))
utils.AssertEqual(t, cacheHit, headResp.Header.Get("X-Cache"))
getResp, err := app.Test(httptest.NewRequest("GET", "/?cache=123", nil))
utils.AssertEqual(t, nil, err)
getBody, err := ioutil.ReadAll(getResp.Body)
getBody, err := io.ReadAll(getResp.Body)
utils.AssertEqual(t, nil, err)
utils.AssertEqual(t, "123", string(getBody))
utils.AssertEqual(t, cacheMiss, getResp.Header.Get("X-Cache"))
getResp, err = app.Test(httptest.NewRequest("GET", "/?cache=123", nil))
utils.AssertEqual(t, nil, err)
getBody, err = ioutil.ReadAll(getResp.Body)
getBody, err = io.ReadAll(getResp.Body)
utils.AssertEqual(t, nil, err)
utils.AssertEqual(t, "123", string(getBody))
utils.AssertEqual(t, cacheHit, getResp.Header.Get("X-Cache"))
@ -785,7 +785,7 @@ func Benchmark_Cache(b *testing.B) {
app.Use(New())
app.Get("/demo", func(c *fiber.Ctx) error {
data, _ := ioutil.ReadFile("../../.github/README.md")
data, _ := os.ReadFile("../../.github/README.md")
return c.Status(fiber.StatusTeapot).Send(data)
})
@ -815,7 +815,7 @@ func Benchmark_Cache_Storage(b *testing.B) {
}))
app.Get("/demo", func(c *fiber.Ctx) error {
data, _ := ioutil.ReadFile("../../.github/README.md")
data, _ := os.ReadFile("../../.github/README.md")
return c.Status(fiber.StatusTeapot).Send(data)
})

View File

@ -3,8 +3,9 @@ package compress
import (
"errors"
"fmt"
"io/ioutil"
"io"
"net/http/httptest"
"os"
"testing"
"github.com/gofiber/fiber/v2"
@ -14,7 +15,7 @@ import (
var filedata []byte
func init() {
dat, err := ioutil.ReadFile("../../.github/README.md")
dat, err := os.ReadFile("../../.github/README.md")
if err != nil {
panic(err)
}
@ -41,7 +42,7 @@ func Test_Compress_Gzip(t *testing.T) {
utils.AssertEqual(t, "gzip", resp.Header.Get(fiber.HeaderContentEncoding))
// Validate that the file size has shrunk
body, err := ioutil.ReadAll(resp.Body)
body, err := io.ReadAll(resp.Body)
utils.AssertEqual(t, nil, err)
utils.AssertEqual(t, true, len(body) < len(filedata))
}
@ -69,7 +70,7 @@ func Test_Compress_Different_Level(t *testing.T) {
utils.AssertEqual(t, "gzip", resp.Header.Get(fiber.HeaderContentEncoding))
// Validate that the file size has shrunk
body, err := ioutil.ReadAll(resp.Body)
body, err := io.ReadAll(resp.Body)
utils.AssertEqual(t, nil, err)
utils.AssertEqual(t, true, len(body) < len(filedata))
})
@ -94,7 +95,7 @@ func Test_Compress_Deflate(t *testing.T) {
utils.AssertEqual(t, "deflate", resp.Header.Get(fiber.HeaderContentEncoding))
// Validate that the file size has shrunk
body, err := ioutil.ReadAll(resp.Body)
body, err := io.ReadAll(resp.Body)
utils.AssertEqual(t, nil, err)
utils.AssertEqual(t, true, len(body) < len(filedata))
}
@ -117,7 +118,7 @@ func Test_Compress_Brotli(t *testing.T) {
utils.AssertEqual(t, "br", resp.Header.Get(fiber.HeaderContentEncoding))
// Validate that the file size has shrunk
body, err := ioutil.ReadAll(resp.Body)
body, err := io.ReadAll(resp.Body)
utils.AssertEqual(t, nil, err)
utils.AssertEqual(t, true, len(body) < len(filedata))
}
@ -140,7 +141,7 @@ func Test_Compress_Disabled(t *testing.T) {
utils.AssertEqual(t, "", resp.Header.Get(fiber.HeaderContentEncoding))
// Validate the file size is not shrunk
body, err := ioutil.ReadAll(resp.Body)
body, err := io.ReadAll(resp.Body)
utils.AssertEqual(t, nil, err)
utils.AssertEqual(t, true, len(body) == len(filedata))
}
@ -162,7 +163,7 @@ func Test_Compress_Next_Error(t *testing.T) {
utils.AssertEqual(t, 500, resp.StatusCode, "Status code")
utils.AssertEqual(t, "", resp.Header.Get(fiber.HeaderContentEncoding))
body, err := ioutil.ReadAll(resp.Body)
body, err := io.ReadAll(resp.Body)
utils.AssertEqual(t, nil, err)
utils.AssertEqual(t, "next error", string(body))
}

View File

@ -2,7 +2,7 @@ package envvar
import (
"encoding/json"
"io/ioutil"
"io"
"net/http"
"os"
"testing"
@ -48,7 +48,7 @@ func TestEnvVarHandler(t *testing.T) {
resp, err := app.Test(req)
utils.AssertEqual(t, nil, err)
respBody, err := ioutil.ReadAll(resp.Body)
respBody, err := io.ReadAll(resp.Body)
utils.AssertEqual(t, nil, err)
utils.AssertEqual(t, expectedEnvVarResponse, respBody)
@ -68,7 +68,7 @@ func TestEnvVarHandlerNotMatched(t *testing.T) {
resp, err := app.Test(req)
utils.AssertEqual(t, nil, err)
respBody, err := ioutil.ReadAll(resp.Body)
respBody, err := io.ReadAll(resp.Body)
utils.AssertEqual(t, nil, err)
utils.AssertEqual(t, []byte("OK"), respBody)
@ -85,7 +85,7 @@ func TestEnvVarHandlerDefaultConfig(t *testing.T) {
resp, err := app.Test(req)
utils.AssertEqual(t, nil, err)
respBody, err := ioutil.ReadAll(resp.Body)
respBody, err := io.ReadAll(resp.Body)
utils.AssertEqual(t, nil, err)
var envVars EnvVar
@ -118,7 +118,7 @@ func TestEnvVarHandlerSpecialValue(t *testing.T) {
resp, err := app.Test(req)
utils.AssertEqual(t, nil, err)
respBody, err := ioutil.ReadAll(resp.Body)
respBody, err := io.ReadAll(resp.Body)
utils.AssertEqual(t, nil, err)
var envVars EnvVar
@ -130,7 +130,7 @@ func TestEnvVarHandlerSpecialValue(t *testing.T) {
resp, err = app.Test(req)
utils.AssertEqual(t, nil, err)
respBody, err = ioutil.ReadAll(resp.Body)
respBody, err = io.ReadAll(resp.Body)
utils.AssertEqual(t, nil, err)
var envVarsExport EnvVar

View File

@ -2,7 +2,7 @@ package etag
import (
"bytes"
"io/ioutil"
"io"
"net/http/httptest"
"testing"
@ -114,7 +114,7 @@ func testETagNewEtag(t *testing.T, headerIfNoneMatch, matched bool) {
if matched {
utils.AssertEqual(t, fiber.StatusNotModified, resp.StatusCode)
b, err := ioutil.ReadAll(resp.Body)
b, err := io.ReadAll(resp.Body)
utils.AssertEqual(t, nil, err)
utils.AssertEqual(t, 0, len(b))
}
@ -164,7 +164,7 @@ func testETagWeakEtag(t *testing.T, headerIfNoneMatch, matched bool) {
if matched {
utils.AssertEqual(t, fiber.StatusNotModified, resp.StatusCode)
b, err := ioutil.ReadAll(resp.Body)
b, err := io.ReadAll(resp.Body)
utils.AssertEqual(t, nil, err)
utils.AssertEqual(t, 0, len(b))
}
@ -218,7 +218,7 @@ func testETagCustomEtag(t *testing.T, headerIfNoneMatch, matched bool) {
if matched {
utils.AssertEqual(t, fiber.StatusNotModified, resp.StatusCode)
b, err := ioutil.ReadAll(resp.Body)
b, err := io.ReadAll(resp.Body)
utils.AssertEqual(t, nil, err)
utils.AssertEqual(t, 0, len(b))
}

View File

@ -2,7 +2,7 @@ package expvar
import (
"bytes"
"io/ioutil"
"io"
"net/http/httptest"
"testing"
@ -23,7 +23,7 @@ func Test_Non_Expvar_Path(t *testing.T) {
utils.AssertEqual(t, nil, err)
utils.AssertEqual(t, 200, resp.StatusCode)
b, err := ioutil.ReadAll(resp.Body)
b, err := io.ReadAll(resp.Body)
utils.AssertEqual(t, nil, err)
utils.AssertEqual(t, "escaped", string(b))
}
@ -42,7 +42,7 @@ func Test_Expvar_Index(t *testing.T) {
utils.AssertEqual(t, 200, resp.StatusCode)
utils.AssertEqual(t, fiber.MIMEApplicationJSONCharsetUTF8, resp.Header.Get(fiber.HeaderContentType))
b, err := ioutil.ReadAll(resp.Body)
b, err := io.ReadAll(resp.Body)
utils.AssertEqual(t, nil, err)
utils.AssertEqual(t, true, bytes.Contains(b, []byte("cmdline")))
utils.AssertEqual(t, true, bytes.Contains(b, []byte("memstat")))
@ -62,7 +62,7 @@ func Test_Expvar_Filter(t *testing.T) {
utils.AssertEqual(t, 200, resp.StatusCode)
utils.AssertEqual(t, fiber.MIMEApplicationJSONCharsetUTF8, resp.Header.Get(fiber.HeaderContentType))
b, err := ioutil.ReadAll(resp.Body)
b, err := io.ReadAll(resp.Body)
utils.AssertEqual(t, nil, err)
utils.AssertEqual(t, true, bytes.Contains(b, []byte("cmdline")))
utils.AssertEqual(t, false, bytes.Contains(b, []byte("memstat")))

View File

@ -1,8 +1,9 @@
package favicon
import (
"io/ioutil"
"io"
"net/http"
"os"
"strconv"
"github.com/gofiber/fiber/v2"
@ -80,10 +81,10 @@ func New(config ...Config) fiber.Handler {
if err != nil {
panic(err)
}
if icon, err = ioutil.ReadAll(f); err != nil {
if icon, err = io.ReadAll(f); err != nil {
panic(err)
}
} else if icon, err = ioutil.ReadFile(cfg.File); err != nil {
} else if icon, err = os.ReadFile(cfg.File); err != nil {
panic(err)
}

View File

@ -1,7 +1,7 @@
package limiter
import (
"io/ioutil"
"io"
"net/http"
"net/http/httptest"
"sync"
@ -37,7 +37,7 @@ func Test_Limiter_Concurrency_Store(t *testing.T) {
utils.AssertEqual(t, nil, err)
utils.AssertEqual(t, fiber.StatusOK, resp.StatusCode)
body, err := ioutil.ReadAll(resp.Body)
body, err := io.ReadAll(resp.Body)
utils.AssertEqual(t, nil, err)
utils.AssertEqual(t, "Hello tester!", string(body))
}
@ -82,7 +82,7 @@ func Test_Limiter_Concurrency(t *testing.T) {
utils.AssertEqual(t, nil, err)
utils.AssertEqual(t, fiber.StatusOK, resp.StatusCode)
body, err := ioutil.ReadAll(resp.Body)
body, err := io.ReadAll(resp.Body)
utils.AssertEqual(t, nil, err)
utils.AssertEqual(t, "Hello tester!", string(body))
}

View File

@ -3,7 +3,7 @@ package logger
import (
"errors"
"fmt"
"io/ioutil"
"io"
"net/http"
"net/http/httptest"
"os"
@ -268,7 +268,7 @@ func Benchmark_Logger(b *testing.B) {
app.Use(New(Config{
Format: "${bytesReceived} ${bytesSent} ${status}",
Output: ioutil.Discard,
Output: io.Discard,
}))
app.Get("/", func(c *fiber.Ctx) error {
return c.SendString("Hello, World!")

View File

@ -3,7 +3,7 @@ package monitor
import (
"bytes"
"fmt"
"io/ioutil"
"io"
"net/http/httptest"
"testing"
"time"
@ -38,7 +38,7 @@ func Test_Monitor_Html(t *testing.T) {
utils.AssertEqual(t, 200, resp.StatusCode)
utils.AssertEqual(t, fiber.MIMETextHTMLCharsetUTF8,
resp.Header.Get(fiber.HeaderContentType))
buf, err := ioutil.ReadAll(resp.Body)
buf, err := io.ReadAll(resp.Body)
utils.AssertEqual(t, nil, err)
utils.AssertEqual(t, true, bytes.Contains(buf, []byte("<title>"+defaultTitle+"</title>")))
timeoutLine := fmt.Sprintf("setTimeout(fetchJSON, %d)",
@ -54,7 +54,7 @@ func Test_Monitor_Html(t *testing.T) {
utils.AssertEqual(t, 200, resp.StatusCode)
utils.AssertEqual(t, fiber.MIMETextHTMLCharsetUTF8,
resp.Header.Get(fiber.HeaderContentType))
buf, err = ioutil.ReadAll(resp.Body)
buf, err = io.ReadAll(resp.Body)
utils.AssertEqual(t, nil, err)
utils.AssertEqual(t, true, bytes.Contains(buf, []byte("<title>"+conf.Title+"</title>")))
timeoutLine = fmt.Sprintf("setTimeout(fetchJSON, %d)",
@ -74,7 +74,7 @@ func Test_Monitor_Html_CustomCodes(t *testing.T) {
utils.AssertEqual(t, 200, resp.StatusCode)
utils.AssertEqual(t, fiber.MIMETextHTMLCharsetUTF8,
resp.Header.Get(fiber.HeaderContentType))
buf, err := ioutil.ReadAll(resp.Body)
buf, err := io.ReadAll(resp.Body)
utils.AssertEqual(t, nil, err)
utils.AssertEqual(t, true, bytes.Contains(buf, []byte("<title>"+defaultTitle+"</title>")))
timeoutLine := fmt.Sprintf("setTimeout(fetchJSON, %d)",
@ -94,7 +94,7 @@ func Test_Monitor_Html_CustomCodes(t *testing.T) {
utils.AssertEqual(t, 200, resp.StatusCode)
utils.AssertEqual(t, fiber.MIMETextHTMLCharsetUTF8,
resp.Header.Get(fiber.HeaderContentType))
buf, err = ioutil.ReadAll(resp.Body)
buf, err = io.ReadAll(resp.Body)
utils.AssertEqual(t, nil, err)
utils.AssertEqual(t, true, bytes.Contains(buf, []byte("<title>"+conf.Title+"</title>")))
utils.AssertEqual(t, true, bytes.Contains(buf, []byte("https://cdnjs.com/libraries/Chart.js")))
@ -121,7 +121,7 @@ func Test_Monitor_JSON(t *testing.T) {
utils.AssertEqual(t, 200, resp.StatusCode)
utils.AssertEqual(t, fiber.MIMEApplicationJSON, resp.Header.Get(fiber.HeaderContentType))
b, err := ioutil.ReadAll(resp.Body)
b, err := io.ReadAll(resp.Body)
utils.AssertEqual(t, nil, err)
utils.AssertEqual(t, true, bytes.Contains(b, []byte("pid")))
utils.AssertEqual(t, true, bytes.Contains(b, []byte("os")))
@ -189,7 +189,7 @@ func Test_Monitor_APIOnly(t *testing.T) {
utils.AssertEqual(t, 200, resp.StatusCode)
utils.AssertEqual(t, fiber.MIMEApplicationJSON, resp.Header.Get(fiber.HeaderContentType))
b, err := ioutil.ReadAll(resp.Body)
b, err := io.ReadAll(resp.Body)
utils.AssertEqual(t, nil, err)
utils.AssertEqual(t, true, bytes.Contains(b, []byte("pid")))
utils.AssertEqual(t, true, bytes.Contains(b, []byte("os")))

View File

@ -2,7 +2,7 @@ package pprof
import (
"bytes"
"io/ioutil"
"io"
"net/http/httptest"
"testing"
@ -23,7 +23,7 @@ func Test_Non_Pprof_Path(t *testing.T) {
utils.AssertEqual(t, nil, err)
utils.AssertEqual(t, 200, resp.StatusCode)
b, err := ioutil.ReadAll(resp.Body)
b, err := io.ReadAll(resp.Body)
utils.AssertEqual(t, nil, err)
utils.AssertEqual(t, "escaped", string(b))
}
@ -42,7 +42,7 @@ func Test_Pprof_Index(t *testing.T) {
utils.AssertEqual(t, 200, resp.StatusCode)
utils.AssertEqual(t, fiber.MIMETextHTMLCharsetUTF8, resp.Header.Get(fiber.HeaderContentType))
b, err := ioutil.ReadAll(resp.Body)
b, err := io.ReadAll(resp.Body)
utils.AssertEqual(t, nil, err)
utils.AssertEqual(t, true, bytes.Contains(b, []byte("<title>/debug/pprof/</title>")))
}

View File

@ -2,7 +2,7 @@ package proxy
import (
"crypto/tls"
"io/ioutil"
"io"
"net"
"net/http"
"net/http/httptest"
@ -174,7 +174,7 @@ func Test_Proxy_Forward(t *testing.T) {
utils.AssertEqual(t, nil, err)
utils.AssertEqual(t, fiber.StatusOK, resp.StatusCode)
b, err := ioutil.ReadAll(resp.Body)
b, err := io.ReadAll(resp.Body)
utils.AssertEqual(t, nil, err)
utils.AssertEqual(t, "forwarded", string(b))
}
@ -234,7 +234,7 @@ func Test_Proxy_Modify_Response(t *testing.T) {
utils.AssertEqual(t, nil, err)
utils.AssertEqual(t, fiber.StatusOK, resp.StatusCode)
b, err := ioutil.ReadAll(resp.Body)
b, err := io.ReadAll(resp.Body)
utils.AssertEqual(t, nil, err)
utils.AssertEqual(t, "modified response", string(b))
}
@ -261,7 +261,7 @@ func Test_Proxy_Modify_Request(t *testing.T) {
utils.AssertEqual(t, nil, err)
utils.AssertEqual(t, fiber.StatusOK, resp.StatusCode)
b, err := ioutil.ReadAll(resp.Body)
b, err := io.ReadAll(resp.Body)
utils.AssertEqual(t, nil, err)
utils.AssertEqual(t, "modified request", string(b))
}
@ -285,7 +285,7 @@ func Test_Proxy_Timeout_Slow_Server(t *testing.T) {
utils.AssertEqual(t, nil, err)
utils.AssertEqual(t, fiber.StatusOK, resp.StatusCode)
b, err := ioutil.ReadAll(resp.Body)
b, err := io.ReadAll(resp.Body)
utils.AssertEqual(t, nil, err)
utils.AssertEqual(t, "fiber is awesome", string(b))
}
@ -309,7 +309,7 @@ func Test_Proxy_With_Timeout(t *testing.T) {
utils.AssertEqual(t, nil, err)
utils.AssertEqual(t, fiber.StatusInternalServerError, resp.StatusCode)
b, err := ioutil.ReadAll(resp.Body)
b, err := io.ReadAll(resp.Body)
utils.AssertEqual(t, nil, err)
utils.AssertEqual(t, "timeout", string(b))
}
@ -388,7 +388,7 @@ func Test_Proxy_Do_HTTP_Prefix_URL(t *testing.T) {
resp, err := app.Test(httptest.NewRequest(http.MethodGet, "/http://"+addr, nil))
utils.AssertEqual(t, nil, err)
s, err := ioutil.ReadAll(resp.Body)
s, err := io.ReadAll(resp.Body)
utils.AssertEqual(t, nil, err)
utils.AssertEqual(t, "hello world", string(s))
}

View File

@ -6,7 +6,7 @@ package fiber
import (
"errors"
"io/ioutil"
"io"
"net/http/httptest"
"testing"
@ -216,7 +216,7 @@ func Test_App_UseMountedErrorHandlerForBestPrefixMatch(t *testing.T) {
utils.AssertEqual(t, nil, err, "/api/sub req")
utils.AssertEqual(t, 200, resp.StatusCode, "Status code")
b, err := ioutil.ReadAll(resp.Body)
b, err := io.ReadAll(resp.Body)
utils.AssertEqual(t, nil, err, "iotuil.ReadAll()")
utils.AssertEqual(t, "hi, i'm a custom sub fiber error", string(b), "Response body")
@ -224,7 +224,7 @@ func Test_App_UseMountedErrorHandlerForBestPrefixMatch(t *testing.T) {
utils.AssertEqual(t, nil, err, "/api/sub/third req")
utils.AssertEqual(t, 200, resp.StatusCode, "Status code")
b, err = ioutil.ReadAll(resp2.Body)
b, err = io.ReadAll(resp2.Body)
utils.AssertEqual(t, nil, err, "iotuil.ReadAll()")
utils.AssertEqual(t, "hi, i'm a custom sub sub fiber error", string(b), "Third fiber Response body")
}
@ -250,7 +250,7 @@ func Test_Ctx_Render_Mount(t *testing.T) {
utils.AssertEqual(t, StatusOK, resp.StatusCode, "Status code")
utils.AssertEqual(t, nil, err, "app.Test(req)")
body, err := ioutil.ReadAll(resp.Body)
body, err := io.ReadAll(resp.Body)
utils.AssertEqual(t, nil, err)
utils.AssertEqual(t, "<h1>Hello a!</h1>", string(body))
}
@ -302,7 +302,7 @@ func Test_Ctx_Render_Mount_ParentOrSubHasViews(t *testing.T) {
utils.AssertEqual(t, StatusOK, resp.StatusCode, "Status code")
utils.AssertEqual(t, nil, err, "app.Test(req)")
body, err := ioutil.ReadAll(resp.Body)
body, err := io.ReadAll(resp.Body)
utils.AssertEqual(t, nil, err)
utils.AssertEqual(t, "<h1>Hello a!</h1>", string(body))
@ -310,7 +310,7 @@ func Test_Ctx_Render_Mount_ParentOrSubHasViews(t *testing.T) {
utils.AssertEqual(t, StatusOK, resp.StatusCode, "Status code")
utils.AssertEqual(t, nil, err, "app.Test(req)")
body, err = ioutil.ReadAll(resp.Body)
body, err = io.ReadAll(resp.Body)
utils.AssertEqual(t, nil, err)
utils.AssertEqual(t, "<h1>Hello, World!</h1>", string(body))
@ -318,7 +318,7 @@ func Test_Ctx_Render_Mount_ParentOrSubHasViews(t *testing.T) {
utils.AssertEqual(t, StatusOK, resp.StatusCode, "Status code")
utils.AssertEqual(t, nil, err, "app.Test(req)")
body, err = ioutil.ReadAll(resp.Body)
body, err = io.ReadAll(resp.Body)
utils.AssertEqual(t, nil, err)
utils.AssertEqual(t, "<h1>I'm Bruh</h1>", string(body))
@ -345,7 +345,7 @@ func Test_Ctx_Render_MountGroup(t *testing.T) {
utils.AssertEqual(t, nil, err, "app.Test(req)")
utils.AssertEqual(t, 200, resp.StatusCode, "Status code")
body, err := ioutil.ReadAll(resp.Body)
body, err := io.ReadAll(resp.Body)
utils.AssertEqual(t, nil, err)
utils.AssertEqual(t, "<h1>Hello doe!</h1>", string(body))
}

View File

@ -6,7 +6,7 @@ package fiber
import (
"crypto/tls"
"io/ioutil"
"io"
"os"
"testing"
"time"
@ -83,7 +83,7 @@ func Test_App_Prefork_Child_Process_Never_Show_Startup_Message(t *testing.T) {
utils.AssertEqual(t, nil, w.Close())
out, err := ioutil.ReadAll(r)
out, err := io.ReadAll(r)
utils.AssertEqual(t, nil, err)
utils.AssertEqual(t, 0, len(out))
}

View File

@ -10,8 +10,9 @@ import (
"encoding/json"
"errors"
"fmt"
"io/ioutil"
"io"
"net/http/httptest"
"os"
"strings"
"testing"
@ -22,7 +23,7 @@ import (
var routesFixture = routeJSON{}
func init() {
dat, err := ioutil.ReadFile("./.github/testdata/testRoutes.json")
dat, err := os.ReadFile("./.github/testdata/testRoutes.json")
if err != nil {
panic(err)
}
@ -42,7 +43,7 @@ func Test_Route_Match_SameLength(t *testing.T) {
utils.AssertEqual(t, nil, err, "app.Test(req)")
utils.AssertEqual(t, 200, resp.StatusCode, "Status code")
body, err := ioutil.ReadAll(resp.Body)
body, err := io.ReadAll(resp.Body)
utils.AssertEqual(t, nil, err, "app.Test(req)")
utils.AssertEqual(t, ":param", app.getString(body))
@ -51,7 +52,7 @@ func Test_Route_Match_SameLength(t *testing.T) {
utils.AssertEqual(t, nil, err, "app.Test(req)")
utils.AssertEqual(t, 200, resp.StatusCode, "Status code")
body, err = ioutil.ReadAll(resp.Body)
body, err = io.ReadAll(resp.Body)
utils.AssertEqual(t, nil, err, "app.Test(req)")
utils.AssertEqual(t, "test", app.getString(body))
}
@ -67,7 +68,7 @@ func Test_Route_Match_Star(t *testing.T) {
utils.AssertEqual(t, nil, err, "app.Test(req)")
utils.AssertEqual(t, 200, resp.StatusCode, "Status code")
body, err := ioutil.ReadAll(resp.Body)
body, err := io.ReadAll(resp.Body)
utils.AssertEqual(t, nil, err, "app.Test(req)")
utils.AssertEqual(t, "*", app.getString(body))
@ -76,7 +77,7 @@ func Test_Route_Match_Star(t *testing.T) {
utils.AssertEqual(t, nil, err, "app.Test(req)")
utils.AssertEqual(t, 200, resp.StatusCode, "Status code")
body, err = ioutil.ReadAll(resp.Body)
body, err = io.ReadAll(resp.Body)
utils.AssertEqual(t, nil, err, "app.Test(req)")
utils.AssertEqual(t, "test", app.getString(body))
@ -113,7 +114,7 @@ func Test_Route_Match_Root(t *testing.T) {
utils.AssertEqual(t, nil, err, "app.Test(req)")
utils.AssertEqual(t, 200, resp.StatusCode, "Status code")
body, err := ioutil.ReadAll(resp.Body)
body, err := io.ReadAll(resp.Body)
utils.AssertEqual(t, nil, err, "app.Test(req)")
utils.AssertEqual(t, "root", app.getString(body))
}
@ -131,7 +132,7 @@ func Test_Route_Match_Parser(t *testing.T) {
utils.AssertEqual(t, nil, err, "app.Test(req)")
utils.AssertEqual(t, 200, resp.StatusCode, "Status code")
body, err := ioutil.ReadAll(resp.Body)
body, err := io.ReadAll(resp.Body)
utils.AssertEqual(t, nil, err, "app.Test(req)")
utils.AssertEqual(t, "bar", app.getString(body))
@ -140,7 +141,7 @@ func Test_Route_Match_Parser(t *testing.T) {
utils.AssertEqual(t, nil, err, "app.Test(req)")
utils.AssertEqual(t, 200, resp.StatusCode, "Status code")
body, err = ioutil.ReadAll(resp.Body)
body, err = io.ReadAll(resp.Body)
utils.AssertEqual(t, nil, err, "app.Test(req)")
utils.AssertEqual(t, "test", app.getString(body))
}
@ -156,7 +157,7 @@ func Test_Route_Match_Middleware(t *testing.T) {
utils.AssertEqual(t, nil, err, "app.Test(req)")
utils.AssertEqual(t, 200, resp.StatusCode, "Status code")
body, err := ioutil.ReadAll(resp.Body)
body, err := io.ReadAll(resp.Body)
utils.AssertEqual(t, nil, err, "app.Test(req)")
utils.AssertEqual(t, "*", app.getString(body))
@ -165,7 +166,7 @@ func Test_Route_Match_Middleware(t *testing.T) {
utils.AssertEqual(t, nil, err, "app.Test(req)")
utils.AssertEqual(t, 200, resp.StatusCode, "Status code")
body, err = ioutil.ReadAll(resp.Body)
body, err = io.ReadAll(resp.Body)
utils.AssertEqual(t, nil, err, "app.Test(req)")
utils.AssertEqual(t, "bar/fasel", app.getString(body))
}
@ -181,7 +182,7 @@ func Test_Route_Match_UnescapedPath(t *testing.T) {
utils.AssertEqual(t, nil, err, "app.Test(req)")
utils.AssertEqual(t, StatusOK, resp.StatusCode, "Status code")
body, err := ioutil.ReadAll(resp.Body)
body, err := io.ReadAll(resp.Body)
utils.AssertEqual(t, nil, err, "app.Test(req)")
utils.AssertEqual(t, "test", app.getString(body))
// without special chars
@ -217,7 +218,7 @@ func Test_Route_Match_WithEscapeChar(t *testing.T) {
utils.AssertEqual(t, nil, err, "app.Test(req)")
utils.AssertEqual(t, StatusOK, resp.StatusCode, "Status code")
body, err := ioutil.ReadAll(resp.Body)
body, err := io.ReadAll(resp.Body)
utils.AssertEqual(t, nil, err, "app.Test(req)")
utils.AssertEqual(t, "static", app.getString(body))
@ -226,7 +227,7 @@ func Test_Route_Match_WithEscapeChar(t *testing.T) {
utils.AssertEqual(t, nil, err, "app.Test(req)")
utils.AssertEqual(t, StatusOK, resp.StatusCode, "Status code")
body, err = ioutil.ReadAll(resp.Body)
body, err = io.ReadAll(resp.Body)
utils.AssertEqual(t, nil, err, "app.Test(req)")
utils.AssertEqual(t, "group", app.getString(body))
@ -235,7 +236,7 @@ func Test_Route_Match_WithEscapeChar(t *testing.T) {
utils.AssertEqual(t, nil, err, "app.Test(req)")
utils.AssertEqual(t, StatusOK, resp.StatusCode, "Status code")
body, err = ioutil.ReadAll(resp.Body)
body, err = io.ReadAll(resp.Body)
utils.AssertEqual(t, nil, err, "app.Test(req)")
utils.AssertEqual(t, "awesome", app.getString(body))
}
@ -251,7 +252,7 @@ func Test_Route_Match_Middleware_HasPrefix(t *testing.T) {
utils.AssertEqual(t, nil, err, "app.Test(req)")
utils.AssertEqual(t, 200, resp.StatusCode, "Status code")
body, err := ioutil.ReadAll(resp.Body)
body, err := io.ReadAll(resp.Body)
utils.AssertEqual(t, nil, err, "app.Test(req)")
utils.AssertEqual(t, "middleware", app.getString(body))
}
@ -267,7 +268,7 @@ func Test_Route_Match_Middleware_Root(t *testing.T) {
utils.AssertEqual(t, nil, err, "app.Test(req)")
utils.AssertEqual(t, 200, resp.StatusCode, "Status code")
body, err := ioutil.ReadAll(resp.Body)
body, err := io.ReadAll(resp.Body)
utils.AssertEqual(t, nil, err, "app.Test(req)")
utils.AssertEqual(t, "middleware", app.getString(body))
}
@ -339,7 +340,7 @@ func Test_Route_Static_Root(t *testing.T) {
utils.AssertEqual(t, nil, err, "app.Test(req)")
utils.AssertEqual(t, 200, resp.StatusCode, "Status code")
body, err := ioutil.ReadAll(resp.Body)
body, err := io.ReadAll(resp.Body)
utils.AssertEqual(t, nil, err, "app.Test(req)")
utils.AssertEqual(t, true, strings.Contains(app.getString(body), "color"))
@ -354,7 +355,7 @@ func Test_Route_Static_Root(t *testing.T) {
utils.AssertEqual(t, nil, err, "app.Test(req)")
utils.AssertEqual(t, 200, resp.StatusCode, "Status code")
body, err = ioutil.ReadAll(resp.Body)
body, err = io.ReadAll(resp.Body)
utils.AssertEqual(t, nil, err, "app.Test(req)")
utils.AssertEqual(t, true, strings.Contains(app.getString(body), "color"))
}
@ -378,7 +379,7 @@ func Test_Route_Static_HasPrefix(t *testing.T) {
utils.AssertEqual(t, nil, err, "app.Test(req)")
utils.AssertEqual(t, 200, resp.StatusCode, "Status code")
body, err := ioutil.ReadAll(resp.Body)
body, err := io.ReadAll(resp.Body)
utils.AssertEqual(t, nil, err, "app.Test(req)")
utils.AssertEqual(t, true, strings.Contains(app.getString(body), "color"))
@ -399,7 +400,7 @@ func Test_Route_Static_HasPrefix(t *testing.T) {
utils.AssertEqual(t, nil, err, "app.Test(req)")
utils.AssertEqual(t, 200, resp.StatusCode, "Status code")
body, err = ioutil.ReadAll(resp.Body)
body, err = io.ReadAll(resp.Body)
utils.AssertEqual(t, nil, err, "app.Test(req)")
utils.AssertEqual(t, true, strings.Contains(app.getString(body), "color"))
@ -418,7 +419,7 @@ func Test_Route_Static_HasPrefix(t *testing.T) {
utils.AssertEqual(t, nil, err, "app.Test(req)")
utils.AssertEqual(t, 200, resp.StatusCode, "Status code")
body, err = ioutil.ReadAll(resp.Body)
body, err = io.ReadAll(resp.Body)
utils.AssertEqual(t, nil, err, "app.Test(req)")
utils.AssertEqual(t, true, strings.Contains(app.getString(body), "color"))
@ -437,7 +438,7 @@ func Test_Route_Static_HasPrefix(t *testing.T) {
utils.AssertEqual(t, nil, err, "app.Test(req)")
utils.AssertEqual(t, 200, resp.StatusCode, "Status code")
body, err = ioutil.ReadAll(resp.Body)
body, err = io.ReadAll(resp.Body)
utils.AssertEqual(t, nil, err, "app.Test(req)")
utils.AssertEqual(t, true, strings.Contains(app.getString(body), "color"))
}