func ParseBase(s string, archs ...string) (Base, error) {
	var err error
	base := Base{}

	// Split the first forward-slash to get name and channel.
	// E.g. "os/track/risk/branch" => ["os", "track/risk/branch"]
	segments := strings.SplitN(s, "/", 2)
	base.Name = strings.ToLower(segments[0])
	channelName := ""
	if len(segments) == 2 {
		channelName = segments[1]
	}

	if channelName != "" {
		base.Channel, err = ParseChannelNormalize(channelName)
		if err != nil {
			return Base{}, errors.Annotatef(err, "malformed channel in base string %q", s)
		}
	}

	base.Architectures = make([]string, len(archs))
	for i, v := range archs {
		base.Architectures[i] = arch.NormaliseArch(v)
	}

	err = base.Validate()
	if err != nil {
		var a string
		if len(base.Architectures) > 0 {
			a = fmt.Sprintf(" with architectures %q", strings.Join(base.Architectures, ","))
		}
		return Base{}, errors.Annotatef(err, "invalid base string %q%s", s, a)
	}
	return base, nil
}
// ParseBase parses a base as string in the form "os/track/risk/branch"
// and an optional list of architectures
ParseBase parses a base as string in the form "os/track/risk/branch"
and an optional list of architectures
// ParseBase parses a base as string in the form " os / track / risk / branch " // and an optional list of architectures
func ParseBase(s string, archs ...string) (Base, error) {
	var err error
	base := Base{}
	segments := strings.SplitN(s, "/", 2)
	base.Name = strings.ToLower(segments[0])
	channelName := ""
	if len(segments) == 2 {
		channelName = segments[1]
	}
	if channelName != "" {
		base.Channel, err = ParseChannelNormalize(channelName)
		if err != nil {
			return Base{}, errors.Annotatef(err, "malformed channel in base string %q", s)
		}
	}
	base.Architectures = make([]string, len(archs))
	for i, v := range archs {
		base.Architectures[i] = arch.NormaliseArch(v)
	}
	err = base.Validate()
	if err != nil {
		var a string
		if len(base.Architectures) > 0 {
			a = fmt.Sprintf(" with architectures %q", strings.Join(base.Architectures, ","))
		}
		return Base{}, errors.Annotatef(err, "invalid base string %q%s", s, a)
	}
	return base, nil
}
func ParseBase ( s string , archs ... string ) ( Base , error ) { var err error base := Base { } segments := strings . SplitN ( s , " " , 2 ) base . Name = strings . ToLower ( segments [ 0 ] ) channelName := " " if len ( segments ) == 2 { channelName = segments [ 1 ] } if channelName != " " { base . Channel , err = ParseChannelNormalize ( channelName ) if err != nil { return Base { } , errors . Annotatef ( err , " " , s ) } } base . Architectures = make ( [ ] string , len ( archs ) ) for i , v := range archs { base . Architectures [ i ] = arch . NormaliseArch ( v ) } err = base . Validate ( ) if err != nil { var a string if len ( base . Architectures ) > 0 { a = fmt . Sprintf ( " " , strings . Join ( base . Architectures , " " ) ) } return Base { } , errors . Annotatef ( err , " " , s , a ) } return base , nil }
ParseBase parses a base as string in the form "os/track/risk/branch"
and an optional list of architectures
ParseBase parses a base as string in the form " os / track / risk / branch " and an optional list of architectures
// Split the first forward-slash to get name and channel. // E.g. "os/track/risk/branch" => ["os", "track/risk/branch"]