func ParseTerm(s string) (*TermsId, error) {
	tenant := ""
	termid := s
	if t := strings.SplitN(s, ":", 2); len(t) == 2 {
		tenant = t[0]
		termid = t[1]
	}

	tokens := strings.Split(termid, "/")
	var term TermsId
	switch len(tokens) {
	case 1: // "name"
		term = TermsId{
			Tenant: tenant,
			Name:   tokens[0],
		}
	case 2: // owner/name or name/123
		termRevision, err := strconv.Atoi(tokens[1])
		if err != nil { // owner/name
			term = TermsId{
				Tenant: tenant,
				Owner:  tokens[0],
				Name:   tokens[1],
			}
		} else { // name/123
			term = TermsId{
				Tenant:   tenant,
				Name:     tokens[0],
				Revision: termRevision,
			}
		}
	case 3: // owner/name/123
		termRevision, err := strconv.Atoi(tokens[2])
		if err != nil {
			return nil, errors.Errorf("invalid revision number %q %v", tokens[2], err)
		}
		term = TermsId{
			Tenant:   tenant,
			Owner:    tokens[0],
			Name:     tokens[1],
			Revision: termRevision,
		}
	default:
		return nil, errors.Errorf("unknown term id format %q", s)
	}
	if err := term.Validate(); err != nil {
		return nil, errors.Trace(err)
	}
	return &term, nil
}
// ParseTerm takes a termID as a string and parses it into a Term.
// A complete term is in the form:
// tenant:owner/name/revision
// This function accepts partially specified identifiers
// typically in one of the following forms:
// name
// owner/name
// owner/name/27 # Revision 27
// name/283 # Revision 283
// cs:owner/name # Tenant cs
ParseTerm takes a termID as a string and parses it into a Term.
A complete term is in the form:
tenant:owner/name/revision
This function accepts partially specified identifiers
typically in one of the following forms:
name
owner/name
owner/name/27 # Revision 27
name/283 # Revision 283
cs:owner/name # Tenant cs
// ParseTerm takes a termID as a string and parses it into a Term . // A complete term is in the form : // tenant : owner / name / revision // This function accepts partially specified identifiers // typically in one of the following forms : // name // owner / name // owner / name / 27 # Revision 27 // name / 283 # Revision 283 // cs : owner / name # Tenant cs
func ParseTerm(s string) (*TermsId, error) {
	tenant := ""
	termid := s
	if t := strings.SplitN(s, ":", 2); len(t) == 2 {
		tenant = t[0]
		termid = t[1]
	}
	tokens := strings.Split(termid, "/")
	var term TermsId
	switch len(tokens) {
	case 1: 
		term = TermsId{
			Tenant: tenant,
			Name:   tokens[0],
		}
	case 2: 
		termRevision, err := strconv.Atoi(tokens[1])
		if err != nil { 
			term = TermsId{
				Tenant: tenant,
				Owner:  tokens[0],
				Name:   tokens[1],
			}
		} else { 
			term = TermsId{
				Tenant:   tenant,
				Name:     tokens[0],
				Revision: termRevision,
			}
		}
	case 3: /123
		termRevision, err := strconv.Atoi(tokens[2])
		if err != nil {
			return nil, errors.Errorf("invalid revision number %q %v", tokens[2], err)
		}
		term = TermsId{
			Tenant:   tenant,
			Owner:    tokens[0],
			Name:     tokens[1],
			Revision: termRevision,
		}
	default:
		return nil, errors.Errorf("unknown term id format %q", s)
	}
	if err := term.Validate(); err != nil {
		return nil, errors.Trace(err)
	}
	return &term, nil
}
func ParseTerm ( s string ) ( * TermsId , error ) { tenant := " " termid := s if t := strings . SplitN ( s , " " , 2 ) ; len ( t ) == 2 { tenant = t [ 0 ] termid = t [ 1 ] } tokens := strings . Split ( termid , " " ) var term TermsId switch len ( tokens ) { case 1 : term = TermsId { Tenant : tenant , Name : tokens [ 0 ] , } case 2 : termRevision , err := strconv . Atoi ( tokens [ 1 ] ) if err != nil { term = TermsId { Tenant : tenant , Owner : tokens [ 0 ] , Name : tokens [ 1 ] , } } else { term = TermsId { Tenant : tenant , Name : tokens [ 0 ] , Revision : termRevision , } } case 3 : termRevision , err := strconv . Atoi ( tokens [ 2 ] ) if err != nil { return nil , errors . Errorf ( " " , tokens [ 2 ] , err ) } term = TermsId { Tenant : tenant , Owner : tokens [ 0 ] , Name : tokens [ 1 ] , Revision : termRevision , } default : return nil , errors . Errorf ( " " , s ) } if err := term . Validate ( ) ; err != nil { return nil , errors . Trace ( err ) } return & term , nil }
ParseTerm takes a termID as a string and parses it into a Term.
ParseTerm takes a termID as a string and parses it into a Term .
// "name" // owner/name or name/123 // owner/name // name/123 // owner/name/123