From 97aea5b272cdb683067f6b8cda2d49499003a8db Mon Sep 17 00:00:00 2001 From: Aykhan Shahsuvarov Date: Thu, 19 Sep 2024 01:00:50 +0400 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=A8=20Refactor=20config.go/Print=20and?= =?UTF-8?q?=20convert.go?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config/config.go | 2 +- utils/convert.go | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/config/config.go b/config/config.go index 58be045..9beb002 100644 --- a/config/config.go +++ b/config/config.go @@ -64,7 +64,7 @@ func (config *RequestConfig) Print() { t.AppendSeparator() t.AppendRow(table.Row{"Cookies", utils.MarshalJSON(config.Cookies, 3)}) t.AppendSeparator() - t.AppendRow(table.Row{"Proxies", utils.MarshalJSON(config.Proxies, 3)}) + t.AppendRow(table.Row{"Proxies Count", len(config.Proxies)}) t.AppendSeparator() t.AppendRow(table.Row{"Body", utils.MarshalJSON(config.Body, 3)}) diff --git a/utils/convert.go b/utils/convert.go index b97a9ff..4017861 100644 --- a/utils/convert.go +++ b/utils/convert.go @@ -2,8 +2,8 @@ package utils import ( "encoding/json" + "fmt" "reflect" - "strings" ) func MarshalJSON(v any, maxSliceSize uint) string { @@ -17,7 +17,7 @@ func MarshalJSON(v any, maxSliceSize uint) string { return "{}" } - return strings.Replace(string(data), `"..."`, "...", -1) + return string(data) } func truncateLists(v interface{}, maxItems int) interface{} { @@ -28,7 +28,7 @@ func truncateLists(v interface{}, maxItems int) interface{} { if rv.Len() > maxItems { newSlice := reflect.MakeSlice(rv.Type(), maxItems, maxItems) reflect.Copy(newSlice, rv.Slice(0, maxItems)) - newSlice = reflect.Append(newSlice, reflect.ValueOf("...")) + newSlice = reflect.Append(newSlice, reflect.ValueOf(fmt.Sprintf("...(%d more)", rv.Len()-maxItems))) return newSlice.Interface() } case reflect.Map: