// Port returns defaultPort if no port is set or is invalid,
// the real port otherwise
184142
func (a *NetAddr) Port(defaultPort int) int {
	_, port, err := net.SplitHostPort(a.Addr)
	if err != nil {
		return defaultPort
	}
	porti, err := strconv.Atoi(port)
	if err != nil {
		return defaultPort
	}
	return porti
}
1004465
func (c *Client) UsePort(port int) error {
	_, err := c.ExecCmd(NewCmd("use").WithArgs(NewArg("port", port)))
	return err
}
809718
func (p *Project) Port(ctx context.Context, index int, protocol, serviceName, privatePort string) (string, error) {
	service, err := p.CreateService(serviceName)
	if err != nil {
		return "", err
	}

	containers, err := service.Containers(ctx)
	if err != nil {
		return "", err
	}

	if index < 1 || index > len(containers) {
		return "", fmt.Errorf("Invalid index %d", index)
	}

	return containers[index-1].Port(ctx, fmt.Sprintf("%s/%s", privatePort, protocol))
}
929142
func (s *CreateEndpointInput) SetPort(v int64) *CreateEndpointInput {
	s.Port = &v
	return s
}
1247927
func Port(address string) (uint, error) {
	parts := strings.Split(address, ":")

	length := len(parts)
	if length < 2 {
		return 0, errors.New("Could not parse the port: malformated address")
	}

	port, err := strconv.Atoi(parts[length-1])
	if err != nil {
		return 0, err
	}
	if port < 0 {
		return 0, errors.New("Invalid port number")
	}

	return uint(port), nil
}
143325
func (s *OptionConfiguration) SetPort(v int64) *OptionConfiguration {
	s.Port = &v
	return s
}
479948
func (s *RemotePortDetails) SetPort(v int64) *RemotePortDetails {
	s.Port = &v
	return s
}
990442
func (s *Aloja) Port(p string) *Aloja {
	s.port = p
	return s
}
1145647
func (c *Container) Port(ctx context.Context, port string) (string, error) {
	return "", project.ErrUnsupported
}
610590
func (s *CreateListenerInput) SetPort(v int64) *CreateListenerInput {
	s.Port = &v
	return s
}
1245065
func (s *PlayerSession) SetPort(v int64) *PlayerSession {
	s.Port = &v
	return s
}
613460
func (s *LocalPortDetails) SetPort(v int64) *LocalPortDetails {
	s.Port = &v
	return s
}
469572
func (c *LinkManagerContext) Port(p uint32) LinkPort {
	for _, port := range c.Ports {
		if port.Port == p {
			return port
		}
	}

	return LinkPort{}
}
783255
func makePort(addr string) (uint16, error) {
	_, portString, err := net.SplitHostPort(addr)
	if err != nil {
		return 0, err
	}

	port64, err := strconv.ParseUint(portString, 10, 16)
	if err != nil {
		return 0, err
	}
	return uint16(port64), nil
}
800055
func (s *RestoreDBClusterFromS3Input) SetPort(v int64) *RestoreDBClusterFromS3Input {
	s.Port = &v
	return s
}
419528
func (r *Request) Port() string {
	_, port, err := net.SplitHostPort(r.W.RemoteAddr().String())
	if err != nil {
		return "0"
	}
	return port
}
752762
func (s *RestoreDBInstanceToPointInTimeInput) SetPort(v int64) *RestoreDBInstanceToPointInTimeInput {
	s.Port = &v
	return s
}