move indexOf into the vbantxt package.

improve the warning message on invalid bps value
This commit is contained in:
2024-11-03 16:15:05 +00:00
parent 7a844e3624
commit ae170ca572
4 changed files with 16 additions and 14 deletions

View File

@@ -82,12 +82,12 @@ func main() {
}
}
func createClient(host string, port int, streamname string, bps int, channel, ratelimit int) (*vbantxt.VbanTxt, error) {
func createClient(host string, port int, streamname string, bps, channel, ratelimit int) (*vbantxt.VbanTxt, error) {
client, err := vbantxt.New(
host,
port,
streamname,
vbantxt.WithBPSOpt(indexOf(vbantxt.BpsOpts, bps)),
vbantxt.WithBPSOpt(bps),
vbantxt.WithChannel(channel),
vbantxt.WithRateLimit(time.Duration(ratelimit)*time.Millisecond))
if err != nil {

View File

@@ -15,12 +15,3 @@ func flagsPassed(flags []string) bool {
})
return found
}
func indexOf[T comparable](collection []T, e T) int {
for i, x := range collection {
if x == e {
return i
}
}
return -1
}