From dcdee48bb0e6a57295747fb0caea091e85e1fbf9 Mon Sep 17 00:00:00 2001 From: potassium Date: Fri, 20 Oct 2023 23:16:28 +0300 Subject: [PATCH] empty string error handling --- go.mod | 2 +- go.sum | 2 ++ main.go | 3 ++- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/go.mod b/go.mod index 424e200..6397978 100644 --- a/go.mod +++ b/go.mod @@ -7,6 +7,6 @@ require github.com/bas24/googletranslatefree v0.0.0-20220326200502-05ed9e639439 require ( github.com/robertkrimen/otto v0.2.1 // indirect github.com/stretchr/testify v1.8.4 // indirect - golang.org/x/text v0.4.0 // indirect + golang.org/x/text v0.13.0 // indirect gopkg.in/sourcemap.v1 v1.0.5 // indirect ) diff --git a/go.sum b/go.sum index fa49345..669a103 100644 --- a/go.sum +++ b/go.sum @@ -10,6 +10,8 @@ github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcU github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= golang.org/x/text v0.4.0 h1:BrVqGRd7+k1DiOgtnFvAkoQEWQvBc25ouMJM6429SFg= golang.org/x/text v0.4.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= +golang.org/x/text v0.13.0 h1:ablQoSUd0tRdKxZewP80B+BaqeKJuVhuRxj/dkrun3k= +golang.org/x/text v0.13.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= gopkg.in/sourcemap.v1 v1.0.5 h1:inv58fC9f9J3TK2Y2R1NPntXEn3/wjWHkonhIUODNTI= gopkg.in/sourcemap.v1 v1.0.5/go.mod h1:2RlvNNSMglmRrcvhfuzp4hQHwOtjxlbjX7UPY/GXb78= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= diff --git a/main.go b/main.go index a24df76..b2cecf8 100644 --- a/main.go +++ b/main.go @@ -40,8 +40,9 @@ func main() { panic(err) } } + text = strings.Trim(text, "\n") if len(text) == 0 { - os.Exit(1) + continue } result, err := gt.Translate(text, source, into) if err != nil {