Index() can return -1; maybe you wanted to do Index()+1
154func RenderSpecialLink(rawBytes []byte, urlPrefix string, metas map[string]string) []byte {
155 ms := MentionPattern.FindAll(rawBytes, -1)
156 for _, m := range ms {
157 m = m[bytes.Index(m, []byte("@")):]158 rawBytes = bytes.ReplaceAll(rawBytes, m, []byte(fmt.Sprintf(`<a href="%s/%s">%s</a>`, conf.Server.Subpath, m[1:], m)))
159 }
160
Description
An off-by-one error happens due to incorrectly handled edge-cases. It is recommended to carefully vet the program for off-by-one bugs.
Bad practice
arr[len(arr)]
Recommended
arr[len(array)-1]