MCPcopy Index your code
hub / github.com/coder/coder / parsePortRange

Function parsePortRange

cli/portforward.go:410–430  ·  view source on GitHub ↗
(s, e string)

Source from the content-addressed store, hash-verified

408}
409
410func parsePortRange(s, e string) ([]uint16, error) {
411 start, err := parsePort(s)
412 if err != nil {
413 return nil, xerrors.Errorf("parse range start port from %q: %w", s, err)
414 }
415 end := start
416 if len(e) != 0 {
417 end, err = parsePort(e)
418 if err != nil {
419 return nil, xerrors.Errorf("parse range end port from %q: %w", e, err)
420 }
421 }
422 if end < start {
423 return nil, xerrors.Errorf("range end port %v is less than start port %v", end, start)
424 }
425 var ports []uint16
426 for i := start; i <= end; i++ {
427 ports = append(ports, i)
428 }
429 return ports, nil
430}

Callers 1

parseSrcDestPortsFunction · 0.85

Calls 2

parsePortFunction · 0.85
ErrorfMethod · 0.45

Tested by

no test coverage detected