Skip to content

Commit

Permalink
trim spaces
Browse files Browse the repository at this point in the history
  • Loading branch information
nitram509 committed Mar 29, 2024
1 parent 7a8e880 commit 504e089
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions port_settings.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"github.com/PuerkitoBio/goquery"
"io"
"strconv"
"strings"
)

type PortCommand struct {
Expand Down Expand Up @@ -61,7 +62,8 @@ func prettyPrintPortSettings(format OutputFormat, settings []Port) {
func findPortSettingsInHtml(model NetgearModel, reader io.Reader) ([]Port, error) {
if isModel30x(model) {
return findPortSettingsInGs30xEPxHtml(reader)
} else if isModel316(model) {
}
if isModel316(model) {
return findPortSettingsInGs316EPxHtml(reader)
}
panic("model not supported")
Expand Down Expand Up @@ -105,23 +107,23 @@ func findPortSettingsInGs316EPxHtml(reader io.Reader) (ports []Port, err error)
})

s.Find("span.port-number").Each(func(i int, selection *goquery.Selection) {
var id64, _ = strconv.ParseInt(selection.Text(), 10, 8)
var id64, _ = strconv.ParseInt(strings.TrimSpace(selection.Text()), 10, 8)
ports[i].Index = int8(id64)
})
s.Find("span.port-name span.name").Each(func(i int, selection *goquery.Selection) {
ports[i].Name = selection.Text()
ports[i].Name = strings.TrimSpace(selection.Text())
})
s.Find("p.speed-text").Each(func(i int, selection *goquery.Selection) {
ports[i].Speed = selection.Text()
ports[i].Speed = strings.TrimSpace(selection.Text())
})
s.Find("p.ingress-text").Each(func(i int, selection *goquery.Selection) {
ports[i].IngressRateLimit = selection.Text()
ports[i].IngressRateLimit = strings.TrimSpace(selection.Text())
})
s.Find("p.egress-text").Each(func(i int, selection *goquery.Selection) {
ports[i].EgressRateLimit = selection.Text()
ports[i].EgressRateLimit = strings.TrimSpace(selection.Text())
})
s.Find("p.flow-text").Each(func(i int, selection *goquery.Selection) {
ports[i].FlowControl = selection.Text()
ports[i].FlowControl = strings.TrimSpace(selection.Text())
})
})

Expand Down

0 comments on commit 504e089

Please sign in to comment.