You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: util.go
    path of file: ./repos/gotosocial/vendor/github.com/tdewolff/parse/v2/html
    
    the code of the file until where you have to start completion: package html

var (
	singleQuoteEntityBytes = []byte("&#39;")
	doubleQuoteEntityBytes = []byte("&#34;")
)

// EscapeAttrVal returns the escaped attribute value bytes with quotes. Either single or double quotes are used, whichever is shorter. If there are no quotes present in the value and the value is in HTML (not XML), it will return the value without quotes.
func EscapeAttrVal(buf *[]byte, b []byte, origQuote byte, mustQuote bool) []byte {
	singles := 0
	doubles := 0
	unquoted := true
	for _, c := range b {
		if charTable[c] {
			unquoted = false
			if c == '"' {
				doubles++
			} else if c == '\'' {
				singles++
			}
		}
	}
	if unquoted && (!mustQuote || origQuote == 0) {
		return b
	} else if singles == 0 && origQuote == '\'' || doubles == 0 && origQuote == '"' {
		if len(b)+2 > cap(*buf) {
			*buf = make([]byte, 0, len(b)+2)
		}
		t := (*buf)[:len(b)+2]
		t[0] = origQuote
		copy(t[1:], b)
		t[1+len(b)] = origQuote
		return t
	}

	n := len(b) + 2
	var quote byte
	var escapedQuote []byte
	if singles > doubles || singles == doubles && origQuote != '\'' {
		n += doubles * 4
		quote = '"'
		escapedQuote = doubleQuoteEntityBytes
    
func EscapeAttrVal(buf *[]byte, b []byte, origQuote byte, mustQuote bool) []byte {
	singles := 0
	doubles := 0
	unquoted := true
	for _, c := range b {
		if charTable[c] {
			unquoted = false
			if c == '"' {
				doubles++
			} else if c == '\'' {
				singles++
			}
		}
	}
	if unquoted && (!mustQuote || origQuote == 0) {
		return b
	} else if singles == 0 && origQuote == '\'' || doubles == 0 && origQuote == '"' {
		if len(b)+2 > cap(*buf) {
			*buf = make([]byte, 0, len(b)+2)
		}
		t := (*buf)[:len(b)+2]
		t[0] = origQuote
		copy(t[1:], b)
		t[1+len(b)] = origQuote
		return t
	}

	n := len(b) + 2
	var quote byte
	var escapedQuote []byte
	if singles > doubles || singles == doubles && origQuote != '\'' {
		n += doubles * 4
		quote = '"'
		escapedQuote = doubleQuoteEntityBytes
	} else {
		n += singles * 4
		quote = '\''
		escapedQuote = singleQuoteEntityBytes
	}
	if n > cap(*buf) {
		*buf = make([]byte, 0, n) // maximum size, not actual size
	}
	t := (*buf)[:n] // maximum size, not actual size
	t[0] = quote
	j := 1
	start := 0
	for i, c := range b {
		if c == quote {
			j += copy(t[j:], b[start:i])
			j += copy(t[j:], escapedQuote)
			start = i + 1
		}
	}
	j += copy(t[j:], b[start:])
	t[j] = quote
	return t[:j+1]
}