diff --git a/action/basic.go b/action/basic.go index 289ae5dd..b599a95f 100644 --- a/action/basic.go +++ b/action/basic.go @@ -29,7 +29,7 @@ func Wait(action *recipe.Action) error { return err } - durSec = mathutil.BetweenF64(durSec, 0.01, 3600.0) + durSec = mathutil.Between(durSec, 0.01, 3600.0) time.Sleep(timeutil.SecondsToDuration(durSec)) diff --git a/action/fs.go b/action/fs.go index 382de2d0..ce116e44 100644 --- a/action/fs.go +++ b/action/fs.go @@ -604,7 +604,7 @@ func Cleanup(action *recipe.Action) error { err = os.RemoveAll(obj) if err != nil { - return fmt.Errorf("Can't remove object %q: %v", err) + return fmt.Errorf("Can't remove object %q: %v", obj, err) } } diff --git a/action/http.go b/action/http.go index 4f976c17..dc48b84c 100644 --- a/action/http.go +++ b/action/http.go @@ -297,16 +297,7 @@ func HTTPSetHeader(action *recipe.Action) error { // ////////////////////////////////////////////////////////////////////////////////// // -// isHTTPMethodSupported returns true if HTTP method is supported -func isHTTPMethodSupported(method string) bool { - switch method { - case req.GET, req.POST, req.DELETE, req.PUT, req.PATCH, req.HEAD: - return true - } - - return false -} - +// checkRequestData checks request data func checkRequestData(method, payload string) error { switch method { case req.GET, req.POST, req.DELETE, req.PUT, req.PATCH, req.HEAD: @@ -353,6 +344,6 @@ func makeHTTPRequest(action *recipe.Action, method, url, payload string) *req.Re // parseJSONQuery converts json query to slice func parseJSONQuery(q string) []string { - q = strings.Replace(q, "[", ".[", -1) + q = strings.ReplaceAll(q, "[", ".[") return strings.Split(q, ".") } diff --git a/action/io.go b/action/io.go index 3e809804..e22e350a 100644 --- a/action/io.go +++ b/action/io.go @@ -48,7 +48,7 @@ func Expect(action *recipe.Action, output *OutputContainer) error { } start := time.Now() - timeout = mathutil.BetweenF64(timeout, 0.01, 3600.0) + timeout = mathutil.Between(timeout, 0.01, 3600.0) timeoutDur := timeutil.SecondsToDuration(timeout) for range time.NewTicker(_DATA_READ_PERIOD).C { @@ -98,7 +98,7 @@ func Input(action *recipe.Action, input *os.File, output *OutputContainer) error } if !strings.HasSuffix(text, "\n") { - text = text + "\n" + text += "\n" } output.Purge() diff --git a/action/service.go b/action/service.go index 4124ed65..377fd9b8 100644 --- a/action/service.go +++ b/action/service.go @@ -109,7 +109,7 @@ func WaitService(action *recipe.Action) error { } start := time.Now() - timeout = mathutil.BetweenF64(timeout, 0.01, 3600.0) + timeout = mathutil.Between(timeout, 0.01, 3600.0) timeoutDur := timeutil.SecondsToDuration(timeout) for range time.NewTicker(time.Second / 2).C { diff --git a/action/system.go b/action/system.go index e83adc7c..f5370e7e 100644 --- a/action/system.go +++ b/action/system.go @@ -87,7 +87,7 @@ func WaitPID(action *recipe.Action) error { } start := time.Now() - timeout = mathutil.BetweenF64(timeout, 0.01, 3600.0) + timeout = mathutil.Between(timeout, 0.01, 3600.0) timeoutDur := timeutil.SecondsToDuration(timeout) for range time.NewTicker(25 * time.Millisecond).C { @@ -147,7 +147,7 @@ func WaitFS(action *recipe.Action) error { } start := time.Now() - timeout = mathutil.BetweenF64(timeout, 0.01, 3600.0) + timeout = mathutil.Between(timeout, 0.01, 3600.0) timeoutDur := timeutil.SecondsToDuration(timeout) for range time.NewTicker(25 * time.Millisecond).C { @@ -203,7 +203,7 @@ func WaitConnect(action *recipe.Action) error { } start := time.Now() - timeout = mathutil.BetweenF64(timeout, 0.01, 3600.0) + timeout = mathutil.Between(timeout, 0.01, 3600.0) timeoutDur := timeutil.SecondsToDuration(timeout) for range time.NewTicker(25 * time.Millisecond).C { @@ -264,7 +264,7 @@ func Connect(action *recipe.Action) error { timeout = 1.0 } - timeout = mathutil.BetweenF64(timeout, 0.01, 3600.0) + timeout = mathutil.Between(timeout, 0.01, 3600.0) timeoutDur := timeutil.SecondsToDuration(timeout) conn, err := net.DialTimeout(network, address, timeoutDur) diff --git a/cli/cli.go b/cli/cli.go index e0040272..92eac1fd 100644 --- a/cli/cli.go +++ b/cli/cli.go @@ -430,11 +430,11 @@ func printCompletion() int { switch options.GetS(OPT_COMPLETION) { case "bash": - fmt.Printf(bash.Generate(info, "bibop", "recipe")) + fmt.Print(bash.Generate(info, "bibop", "recipe")) case "fish": - fmt.Printf(fish.Generate(info, "bibop")) + fmt.Print(fish.Generate(info, "bibop")) case "zsh": - fmt.Printf(zsh.Generate(info, optMap, "bibop", "*.recipe")) + fmt.Print(zsh.Generate(info, optMap, "bibop", "*.recipe")) default: return 1 } diff --git a/cli/support/support.go b/cli/support/support.go index 0e38d77c..cfdd9493 100644 --- a/cli/support/support.go +++ b/cli/support/support.go @@ -140,7 +140,7 @@ func getHashColorBullet(v string) string { // printInfo formats and prints info record func printInfo(size int, name, value string) { - name = name + ":" + name += ":" size++ if value == "" { diff --git a/parser/parser.go b/parser/parser.go index 6fd04967..79b7c9a3 100644 --- a/parser/parser.go +++ b/parser/parser.go @@ -273,7 +273,7 @@ func getTokenInfo(keyword string) recipe.TokenInfo { // isUselessRecipeLine return if line doesn't contains recipe data func isUselessRecipeLine(line string) bool { // Skip empty lines - if line == "" || strings.Replace(line, " ", "", -1) == "" { + if line == "" || strings.ReplaceAll(line, " ", "") == "" { return true } diff --git a/render/renderer_terminal.go b/render/renderer_terminal.go index cc8a1820..8cb508f7 100644 --- a/render/renderer_terminal.go +++ b/render/renderer_terminal.go @@ -187,7 +187,7 @@ func (rr *TerminalRenderer) Result(passes, fails, skips int) { } d := rr.formatDuration(time.Since(rr.start), true) - d = strings.Replace(d, ".", "{s-}.", -1) + "{!}" + d = strings.ReplaceAll(d, ".", "{s-}.") + "{!}" fmtc.NewLine() fmtc.Println(" {*}Duration:{!} " + d) diff --git a/render/renderer_xml.go b/render/renderer_xml.go index f363e15d..e2b22599 100644 --- a/render/renderer_xml.go +++ b/render/renderer_xml.go @@ -150,9 +150,9 @@ func (rr *XMLRenderer) Result(passes, fails, skips int) { // ////////////////////////////////////////////////////////////////////////////////// // func (rr *XMLRenderer) escapeData(data string) string { - data = strings.Replace(data, "<", "<", -1) - data = strings.Replace(data, ">", ">", -1) - data = strings.Replace(data, "&", "&", -1) + data = strings.ReplaceAll(data, "<", "<") + data = strings.ReplaceAll(data, ">", ">") + data = strings.ReplaceAll(data, "&", "&") return data }