func (cl *CanLine) Unmarshal(s string) error {
	s = strings.TrimSpace(s)

	// if the line is empty or starts with a comment character return nothing
	if s == "" || strings.HasPrefix(s, "#") || strings.HasPrefix(s, "//") || strings.HasPrefix(s, ";") {
		return ErrEmpty
	}

	// get the fields of the string
	fields := strings.Fields(s)
	fieldsLength := len(fields)

	// switch based on the length
	switch fieldsLength {
	case 0:
		return errors.Errorf("strings.Fields() unexpectedly returned 0-length slice")
	case 1:
		fields = []string{"", fields[0]}
	default:
		break
	}

	cl.Pattern = fields[0]
	cl.Canonical = fields[1]

	return nil
}
// Unmarshal reads a CanLine from a string
Unmarshal reads a CanLine from a string
// Unmarshal reads a CanLine from a string
func (cl *CanLine) Unmarshal(s string) error {
	s = strings.TrimSpace(s)
	if s == "" || strings.HasPrefix(s, "#") || strings.HasPrefix(s, "//") || strings.HasPrefix(s, ";") {
		return ErrEmpty
	}
	fields := strings.Fields(s)
	fieldsLength := len(fields)
	switch fieldsLength {
	case 0:
		return errors.Errorf("strings.Fields() unexpectedly returned 0-length slice")
	case 1:
		fields = []string{"", fields[0]}
	default:
		break
	}
	cl.Pattern = fields[0]
	cl.Canonical = fields[1]
	return nil
}
func ( cl * CanLine ) Unmarshal ( s string ) error { s = strings . TrimSpace ( s ) if s == " " || strings . HasPrefix ( s , " " ) || strings . HasPrefix ( s , " " ) || strings . HasPrefix ( s , " " ) { return ErrEmpty } fields := strings . Fields ( s ) fieldsLength := len ( fields ) switch fieldsLength { case 0 : return errors . Errorf ( " " ) case 1 : fields = [ ] string { " " , fields [ 0 ] } default : break } cl . Pattern = fields [ 0 ] cl . Canonical = fields [ 1 ] return nil }
Unmarshal reads a CanLine from a string
Unmarshal reads a CanLine from a string
// if the line is empty or starts with a comment character return nothing // get the fields of the string // switch based on the length