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

Function parsePort

cli/portforward.go:338–348  ·  view source on GitHub ↗
(in string)

Source from the content-addressed store, hash-verified

336}
337
338func parsePort(in string) (uint16, error) {
339 port, err := strconv.ParseUint(strings.TrimSpace(in), 10, 16)
340 if err != nil {
341 return 0, xerrors.Errorf("parse port %q: %w", in, err)
342 }
343 if port == 0 {
344 return 0, xerrors.New("port cannot be 0")
345 }
346
347 return uint16(port), nil
348}
349
350// specRegexp matches port specs. It handles all the following formats:
351//

Callers 1

parsePortRangeFunction · 0.85

Calls 2

NewMethod · 0.65
ErrorfMethod · 0.45

Tested by

no test coverage detected