Skip to content

Strange behaviour of strings.TrimLeft #18160

Closed
@pikoscielniak

Description

@pikoscielniak

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' 

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions