strings.TrimRight() has bug when trim some strings #14657
Comments
Trimright removes characters in the set e from b, starting from the right. It's not what you want. You want, n := b[:len(b)-len(e)] As you know that e is the suffix of b
|
Quote https://golang.org/pkg/strings/#TrimRight
func TrimRight(s string, cutset string) string
TrimRight returns a slice of the string s, with all trailing Unicode code
points contained in cutset removed.
What you want is probably https://golang.org/pkg/strings/#TrimSuffix
|
@davecheney, @minux thank you guys for your kindly replay :-] |
Please answer these questions before submitting your issue. Thanks!
go version
)?go1.6 darwin/amd64
go env
)?darwin/amd64
(Use play.golang.org to provide a runnable example, if possible.)
package main
import (
"fmt"
"path/filepath"
"strings"
)
func main() {
path := "Order.thrift"
}
Order
Orde
The text was updated successfully, but these errors were encountered: