Skip to content

Strange behaviour of strings.TrimLeft #18160

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
pikoscielniak opened this issue Dec 2, 2016 · 2 comments
Closed

Strange behaviour of strings.TrimLeft #18160

pikoscielniak opened this issue Dec 2, 2016 · 2 comments

Comments

@pikoscielniak
Copy link

Please answer these questions before submitting your issue. Thanks!

What version of Go are you using (go version)?

go1.7.3

What operating system and processor architecture are you using (go env)?

windows/amd64

What did you do?

I executed following test:

import (
	"testing"
	"strings"
)

func TestTrimLeft(t *testing.T) {
	trimed := strings.TrimLeft("record:edocument", "record:")

	if trimed != "edocument" {
		t.Fatalf("Expected 'edocument' got '%s' ", trimed)
	}
}

What did you expect to see?

This test failed. I wouldn't expect this. Could someone explain this to me?

What did you see instead?

I got following output from this test:

Expected 'edocument' got 'ument' 
@myitcv
Copy link
Member

myitcv commented Dec 2, 2016

@pikoscielniak you want TrimPrefix and not TrimLeft

Please also consider asking questions like this in the go-nuts mailing list or other help forums as a first port of call. If the behaviour you are seeing is then confirmed as a bug/issue it can easily be re-raised here in the issue tracker.

@bradfitz bradfitz closed this as completed Dec 2, 2016
@pikoscielniak
Copy link
Author

Thanks a lot. This is what I was looking for.

@golang golang locked and limited conversation to collaborators Dec 2, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants