func (t *Template) Reset(template, startTag, endTag string) error {
	// Keep these vars in t, so GC won't collect them and won't break
	// vars derived via unsafe*
	t.template = template
	t.startTag = startTag
	t.endTag = endTag
	t.texts = t.texts[:0]
	t.tags = t.tags[:0]

	if len(startTag) == 0 {
		panic("startTag cannot be empty")
	}
	if len(endTag) == 0 {
		panic("endTag cannot be empty")
	}

	s := unsafeString2Bytes(template)
	a := unsafeString2Bytes(startTag)
	b := unsafeString2Bytes(endTag)

	tagsCount := bytes.Count(s, a)
	if tagsCount == 0 {
		return nil
	}

	if tagsCount+1 > cap(t.texts) {
		t.texts = make([][]byte, 0, tagsCount+1)
	}
	if tagsCount > cap(t.tags) {
		t.tags = make([]string, 0, tagsCount)
	}

	for {
		n := bytes.Index(s, a)
		if n < 0 {
			t.texts = append(t.texts, s)
			break
		}
		t.texts = append(t.texts, s[:n])

		s = s[n+len(a):]
		n = bytes.Index(s, b)
		if n < 0 {
			return fmt.Errorf("Cannot find end tag=%q in the template=%q starting from %q", endTag, template, s)
		}

		t.tags = append(t.tags, unsafeBytes2String(s[:n]))
		s = s[n+len(b):]
	}

	return nil
}
func (t *Template) Reset(template, startTag, endTag string) error {
	
	
	t.template = template
	t.startTag = startTag
	t.endTag = endTag
	t.texts = t.texts[:0]
	t.tags = t.tags[:0]

	if len(startTag) == 0 {
		panic("startTag cannot be empty")
	}
	if len(endTag) == 0 {
		panic("endTag cannot be empty")
	}

	s := unsafeString2Bytes(template)
	a := unsafeString2Bytes(startTag)
	b := unsafeString2Bytes(endTag)

	tagsCount := bytes.Count(s, a)
	if tagsCount == 0 {
		return nil
	}

	if tagsCount+1 > cap(t.texts) {
		t.texts = make([][]byte, 0, tagsCount+1)
	}
	if tagsCount > cap(t.tags) {
		t.tags = make([]string, 0, tagsCount)
	}

	for {
		n := bytes.Index(s, a)
		if n < 0 {
			t.texts = append(t.texts, s)
			break
		}
		t.texts = append(t.texts, s[:n])

		s = s[n+len(a):]
		n = bytes.Index(s, b)
		if n < 0 {
			return fmt.Errorf("Cannot find end tag=%q in the template=%q starting from %q", endTag, template, s)
		}

		t.tags = append(t.tags, unsafeBytes2String(s[:n]))
		s = s[n+len(b):]
	}

	return nil
}
func ( t * Template ) Reset ( template , startTag , endTag string ) error { // Keep these vars in t, so GC won't collect them and won't break // vars derived via unsafe* t . template = template t . startTag = startTag t . endTag = endTag t . texts = t . texts [ : 0 ] t . tags = t . tags [ : 0 ] if len ( startTag ) == 0 { panic ( " " ) } if len ( endTag ) == 0 { panic ( " " ) } s := unsafeString2Bytes ( template ) a := unsafeString2Bytes ( startTag ) b := unsafeString2Bytes ( endTag ) tagsCount := bytes . Count ( s , a ) if tagsCount == 0 { return nil } if tagsCount + 1 > cap ( t . texts ) { t . texts = make ( [ ] [ ] byte , 0 , tagsCount + 1 ) } if tagsCount > cap ( t . tags ) { t . tags = make ( [ ] string , 0 , tagsCount ) } for { n := bytes . Index ( s , a ) if n < 0 { t . texts = append ( t . texts , s ) break } t . texts = append ( t . texts , s [ : n ] ) s = s [ n + len ( a ) : ] n = bytes . Index ( s , b ) if n < 0 { return fmt . Errorf ( " " , endTag , template , s ) } t . tags = append ( t . tags , unsafeBytes2String ( s [ : n ] ) ) s = s [ n + len ( b ) : ] } return nil }
// Reset resets the template t to new one defined by
// template, startTag and endTag.
//
// Reset allows Template object re-use.
//
// Reset may be called only if no other goroutines call t methods at the moment.
Reset resets the template t to new one defined by template startTag and endTag . Reset allows Template object re - use . Reset may be called only if no other goroutines call t methods at the moment .