Below is the code of TrimRight, on latest Go version
I am observing a behavior, which maybe I am misunderstanding but as my understanding, the below code should throw output as
Hello
But the output is coming as
Hell
Why is that so ? Note, I have kept a space before the Gophers in cutset, so fundamentally it should remove the " Gophers" from the primary string, leaving behind just Hello
package main
import (
"fmt"
"strings"
)
func main() {
result := strings.TrimRight("Hello Gophers", " Gophers")
fmt.Println(result, len(result))
}