func ParseChannel(s string) (Channel, error) {
	if s == "" {
		return Channel{}, errors.Errorf("channel cannot be empty")
	}

	p := strings.Split(s, "/")

	var risk, track, branch *string
	switch len(p) {
	case 1:
		if isRisk(p[0]) {
			risk = &p[0]
		} else {
			track = &p[0]
		}
	case 2:
		if isRisk(p[0]) {
			risk, branch = &p[0], &p[1]
		} else {
			track, risk = &p[0], &p[1]
		}
	case 3:
		track, risk, branch = &p[0], &p[1], &p[2]
	default:
		return Channel{}, errors.Errorf("channel is malformed and has too many components %q", s)
	}

	ch := Channel{}

	if risk != nil {
		if !isRisk(*risk) {
			return Channel{}, errors.NotValidf("risk in channel %q", s)
		}
		// We can lift this into a risk, as we've validated prior to this to
		// ensure it's a valid risk.
		ch.Risk = Risk(*risk)
	}
	if track != nil {
		if *track == "" {
			return Channel{}, errors.NotValidf("track in channel %q", s)
		}
		ch.Track = *track
	}
	if branch != nil {
		if *branch == "" {
			return Channel{}, errors.NotValidf("branch in channel %q", s)
		}
		ch.Branch = *branch
	}
	return ch, nil
}
// ParseChannel parses a string representing a store channel.
ParseChannel parses a string representing a store channel.
// ParseChannel parses a string representing a store channel .
func ParseChannel(s string) (Channel, error) {
	if s == "" {
		return Channel{}, errors.Errorf("channel cannot be empty")
	}
	p := strings.Split(s, "/")
	var risk, track, branch *string
	switch len(p) {
	case 1:
		if isRisk(p[0]) {
			risk = &p[0]
		} else {
			track = &p[0]
		}
	case 2:
		if isRisk(p[0]) {
			risk, branch = &p[0], &p[1]
		} else {
			track, risk = &p[0], &p[1]
		}
	case 3:
		track, risk, branch = &p[0], &p[1], &p[2]
	default:
		return Channel{}, errors.Errorf("channel is malformed and has too many components %q", s)
	}
	ch := Channel{}
	if risk != nil {
		if !isRisk(*risk) {
			return Channel{}, errors.NotValidf("risk in channel %q", s)
		}
		ch.Risk = Risk(*risk)
	}
	if track != nil {
		if *track == "" {
			return Channel{}, errors.NotValidf("track in channel %q", s)
		}
		ch.Track = *track
	}
	if branch != nil {
		if *branch == "" {
			return Channel{}, errors.NotValidf("branch in channel %q", s)
		}
		ch.Branch = *branch
	}
	return ch, nil
}
func ParseChannel ( s string ) ( Channel , error ) { if s == " " { return Channel { } , errors . Errorf ( " " ) } p := strings . Split ( s , " " ) var risk , track , branch * string switch len ( p ) { case 1 : if isRisk ( p [ 0 ] ) { risk = & p [ 0 ] } else { track = & p [ 0 ] } case 2 : if isRisk ( p [ 0 ] ) { risk , branch = & p [ 0 ] , & p [ 1 ] } else { track , risk = & p [ 0 ] , & p [ 1 ] } case 3 : track , risk , branch = & p [ 0 ] , & p [ 1 ] , & p [ 2 ] default : return Channel { } , errors . Errorf ( " " , s ) } ch := Channel { } if risk != nil { if ! isRisk ( * risk ) { return Channel { } , errors . NotValidf ( " " , s ) } ch . Risk = Risk ( * risk ) } if track != nil { if * track == " " { return Channel { } , errors . NotValidf ( " " , s ) } ch . Track = * track } if branch != nil { if * branch == " " { return Channel { } , errors . NotValidf ( " " , s ) } ch . Branch = * branch } return ch , nil }
ParseChannel parses a string representing a store channel.
ParseChannel parses a string representing a store channel .
// We can lift this into a risk, as we've validated prior to this to // ensure it's a valid risk.