From cf8d587d3b848b82571b82584d3b7f2133de659e Mon Sep 17 00:00:00 2001 From: Martin Hebnes Pedersen Date: Mon, 30 Dec 2024 22:10:05 +0100 Subject: [PATCH] Cleanup --- http.go | 6 +++--- prompt_hub.go | 2 +- rmslist.go | 7 ++++--- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/http.go b/http.go index 4240b39f..d0e11f6d 100644 --- a/http.go +++ b/http.go @@ -448,15 +448,15 @@ func bandwidthsHandler(w http.ResponseWriter, req *http.Request) { } mode := strings.ToLower(req.FormValue("mode")) resp := BandwidthResponse{Mode: mode, Bandwidths: []string{}} - switch { - case mode == MethodArdop: + switch mode { + case MethodArdop: for _, bw := range ardop.Bandwidths() { resp.Bandwidths = append(resp.Bandwidths, bw.String()) } if bw := config.Ardop.ARQBandwidth; !bw.IsZero() { resp.Default = bw.String() } - case mode == MethodVaraHF: + case MethodVaraHF: resp.Bandwidths = vara.Bandwidths() if bw := config.VaraHF.Bandwidth; bw != 0 { resp.Default = fmt.Sprintf("%d", bw) diff --git a/prompt_hub.go b/prompt_hub.go index 053f75fa..1d24e07a 100644 --- a/prompt_hub.go +++ b/prompt_hub.go @@ -38,7 +38,7 @@ func (p *PromptHub) loop() { p.c = make(chan *Prompt) p.rc = make(chan PromptResponse) for prompt := range p.c { - timeout := time.After(prompt.Deadline.Sub(time.Now())) + timeout := time.After(time.Until(prompt.Deadline)) select { case <-timeout: prompt.resp <- PromptResponse{ID: prompt.ID, Err: fmt.Errorf("deadline reached")} diff --git a/rmslist.go b/rmslist.go index ff2caf7f..98182511 100644 --- a/rmslist.go +++ b/rmslist.go @@ -144,7 +144,7 @@ func ReadRMSList(ctx context.Context, forceDownload bool, filterFn func(rms RMS) return nil, err } - var slice = []RMS{} + slice := []RMS{} for _, gw := range status.Gateways { for _, channel := range gw.Channels { r := RMS{ @@ -181,11 +181,12 @@ func toURL(gc cmsapi.GatewayChannel, targetCall string) *url.URL { func addBandwidth(gc cmsapi.GatewayChannel, chURL *url.URL) { bw := "" modeF := strings.Fields(gc.SupportedModes) - if modeF[0] == "ARDOP" { + switch modeF[0] { + case "ARDOP": if len(modeF) > 1 { bw = modeF[1] + "MAX" } - } else if modeF[0] == "VARA" { + case "VARA": if len(modeF) > 1 && modeF[1] == "FM" { // VARA FM should not set bandwidth in connect URL or sent over the command port, // it's set in the VARA Setup dialog