Skip to content
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

Strange behaviour of strings.TrimLeft #18160

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

@pikoscielniak pikoscielniak commented Dec 2, 2016

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 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 Dec 2, 2016
@pikoscielniak
Copy link
Author

@pikoscielniak pikoscielniak commented Dec 2, 2016

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
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
4 participants