note:
1:This removes bytes from strings. If your string has characters that are encoded as multiple bytes in UTF-8, then slicing single bytes out will produce undesired results. Let us know if you need to support that.
2:If you need to remove multiple bytes at multiple indexes, there is a more efficient way to do that, too!
package main
import (
"fmt"
)
func strRemoveAt(s string, index, length int) string {
return s[:index] + s[index+length:]
}
func main() {
result:=strRemoveAt("charliec", 0, 1)
fmt.Println(result)
}
Top comments (0)