diff --git a/cmd/configure/helper.go b/cmd/configure/helper.go index 82b5129fd..b60bc3fdc 100644 --- a/cmd/configure/helper.go +++ b/cmd/configure/helper.go @@ -303,7 +303,7 @@ func (c *CmdConfigure) configureMQTT(templateItem templates.Template) (map[strin required: false}) fmt.Println() - fmt.Println("-------------------------------------------") + fmt.Println("--------------------------------------------") broker := fmt.Sprintf("%s:%s", host, port) diff --git a/cmd/configure/survey.go b/cmd/configure/survey.go index 941a6d362..00e2b57fd 100644 --- a/cmd/configure/survey.go +++ b/cmd/configure/survey.go @@ -41,18 +41,15 @@ func (c *CmdConfigure) askConfigFailureNextStep() bool { // select item from list func (c *CmdConfigure) askSelection(message string, items []string) (string, int, error) { - selection := "" prompt := &survey.Select{ Message: message, Options: items, } + var selection string err := c.surveyAskOne(prompt, &selection) - if err == nil { - return selection, funk.IndexOf(items, selection), nil - } - return "", 0, err + return selection, funk.IndexOf(items, selection), err } // selectItem selects item from list @@ -91,13 +88,12 @@ func (c *CmdConfigure) askChoice(label string, choices []string) (int, string) { // askYesNo asks yes/no question, return true if yes is selected func (c *CmdConfigure) askYesNo(label string) bool { - confirmation := false prompt := &survey.Confirm{ Message: label, } - err := c.surveyAskOne(prompt, &confirmation) - if err != nil { + var confirmation bool + if err := c.surveyAskOne(prompt, &confirmation); err != nil { c.log.FATAL.Fatal(err) } @@ -155,10 +151,6 @@ func (c *CmdConfigure) askValue(q question) string { return chargingModes[modeChoice] } - input := "" - - var err error - validate := func(val interface{}) error { value := val.(string) if q.invalidValues != nil && funk.ContainsString(q.invalidValues, value) { @@ -217,23 +209,22 @@ func (c *CmdConfigure) askValue(q question) string { help += fmt.Sprintf(" ("+c.localizedString("Value_Sample", nil)+": %s)", q.exampleValue) } + var prompt survey.Prompt if q.mask { - prompt := &survey.Password{ + prompt = &survey.Password{ Message: q.label, Help: help, } - err = c.surveyAskOne(prompt, &input, survey.WithValidator(validate)) - } else { - prompt := &survey.Input{ + prompt = &survey.Input{ Message: q.label, Default: q.defaultValue, Help: help, } - err = c.surveyAskOne(prompt, &input, survey.WithValidator(validate)) } - if err != nil { + var input string + if err := c.surveyAskOne(prompt, &input, survey.WithValidator(validate)); err != nil { c.log.FATAL.Fatal(err) } diff --git a/cmd/detect.go b/cmd/detect.go index 335218781..e4a759bd6 100644 --- a/cmd/detect.go +++ b/cmd/detect.go @@ -80,7 +80,7 @@ func display(res []tasks.Result) { continue default: - host := "" + var host string hosts, err := net.LookupAddr(hit.ResultDetails.IP) if err == nil && len(hosts) > 0 { host = strings.TrimSuffix(hosts[0], ".")