From 1d4478bf0071f3652f659122bb3dae7bacd553b7 Mon Sep 17 00:00:00 2001 From: Fenny <25108519+Fenny@users.noreply.github.com> Date: Thu, 2 Jul 2020 13:51:10 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=A7=B9=F0=9F=A7=B9=20Cleanup?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app.go | 4 +++- ctx.go | 4 ++-- ctx_test.go | 4 ++-- path_test.go | 13 ------------- utils_test.go | 28 ---------------------------- 5 files changed, 7 insertions(+), 46 deletions(-) diff --git a/app.go b/app.go index a9866437..2dbc4bdc 100644 --- a/app.go +++ b/app.go @@ -24,7 +24,7 @@ import ( utils "github.com/gofiber/utils" colorable "github.com/mattn/go-colorable" - "github.com/mattn/go-isatty" + isatty "github.com/mattn/go-isatty" fasthttp "github.com/valyala/fasthttp" ) @@ -655,6 +655,8 @@ func (app *App) startupMessage(addr string, tls bool, pids string) { // colorable handles the escape sequence for stdout using ascii color codes var out *tabwriter.Writer // Check if colors are supported + fmt.Println(isatty.IsTerminal(os.Stdout.Fd())) + fmt.Println(isatty.IsCygwinTerminal(os.Stdout.Fd())) if os.Getenv("TERM") == "dumb" || (!isatty.IsTerminal(os.Stdout.Fd()) && !isatty.IsCygwinTerminal(os.Stdout.Fd())) { out = tabwriter.NewWriter(colorable.NewNonColorable(os.Stdout), 0, 0, 2, ' ', 0) diff --git a/ctx.go b/ctx.go index bc53afe0..ba688c96 100644 --- a/ctx.go +++ b/ctx.go @@ -203,7 +203,7 @@ func (ctx *Ctx) Attachment(filename ...string) { // BaseURL returns (protocol + host + base path). func (ctx *Ctx) BaseURL() string { - // TODO: avoid allocation 53.8 ns/op 32 B/op 1 allocs/op + // TODO: Could be improved: 53.8 ns/op 32 B/op 1 allocs/op // Should work like https://codeigniter.com/user_guide/helpers/url_helper.html return ctx.Protocol() + "://" + ctx.Hostname() } @@ -219,7 +219,7 @@ func (ctx *Ctx) Body() string { // It supports decoding the following content types based on the Content-Type header: // application/json, application/xml, application/x-www-form-urlencoded, multipart/form-data func (ctx *Ctx) BodyParser(out interface{}) error { - // TODO: Create benchmark ( Prolly need a sync pool ) + // TODO: Create benchmark ( Probably need a sync pool ) var schemaDecoderForm = schema.NewDecoder() var schemaDecoderQuery = schema.NewDecoder() schemaDecoderForm.SetAliasTag("form") diff --git a/ctx_test.go b/ctx_test.go index b502f341..a8b4bc68 100644 --- a/ctx_test.go +++ b/ctx_test.go @@ -414,7 +414,7 @@ func Benchmark_Ctx_Format_XML(b *testing.B) { // go test -run Test_Ctx_FormFile func Test_Ctx_FormFile(t *testing.T) { - // TODO: CLEAN THIS UP + // TODO: We should clean this up t.Parallel() app := New() @@ -791,7 +791,7 @@ func Test_Ctx_RouteNormalized(t *testing.T) { // go test -run Test_Ctx_SaveFile func Test_Ctx_SaveFile(t *testing.T) { - // TODO CLEAN THIS UP + // TODO We should clean this up t.Parallel() app := New() diff --git a/path_test.go b/path_test.go index e764e825..47f2cd61 100644 --- a/path_test.go +++ b/path_test.go @@ -197,16 +197,3 @@ func Test_Path_matchParams(t *testing.T) { {url: "xyz/", params: nil, match: false}, }) } - -////////////////////////////////////////////// -///////////////// BENCHMARKS ///////////////// -////////////////////////////////////////////// -// go test -v -run=^$ -bench=Benchmark_Path_ -benchmem -count=3 - -// func Benchmark_Path_paramsForPos(b *testing.B) { -// // TODO -// } - -// func Benchmark_Path_matchParams(b *testing.B) { -// // TODO -// } diff --git a/utils_test.go b/utils_test.go index 87eac653..ab6b97ea 100644 --- a/utils_test.go +++ b/utils_test.go @@ -73,26 +73,6 @@ func Test_Utils_getGroupPath(t *testing.T) { utils.AssertEqual(t, "/v1/api/", res) } -// func Test_Utils_getArgument(t *testing.T) { -// // TODO -// } - -// func Test_Utils_parseTokenList(t *testing.T) { -// // TODO -// } - -// func Test_Utils_getParams(t *testing.T) { -// // TODO -// } - -// func Test_Utils_getTrimmedParam(t *testing.T) { -// // TODO -// } - -// func Test_Utils_getCharPos(t *testing.T) { -// // TODO -// } - ////////////////////////////////////////////// ///////////////// BENCHMARKS ///////////////// ////////////////////////////////////////////// @@ -109,14 +89,6 @@ func Benchmark_Utils_getGroupPath(b *testing.B) { utils.AssertEqual(b, "/v1/api/register/:project", res) } -// func Benchmark_Utils_getArgument(b *testing.B) { -// // TODO -// } - -// func Benchmark_Utils_parseTokenList(b *testing.B) { -// // TODO -// } - func Benchmark_Utils_Unescape(b *testing.B) { unescaped := "" dst := make([]byte, 0)