Skip to content

strings: TrimLeft() returns unexpected value #67149

@keisku

Description

@keisku

What is the URL of the page with the issue?

https://go.dev/play/p/5iv2wx09xc9

What is your user agent?

Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/124.0.0.0 Safari/537.36

Screenshot

2024-05-03_14-51-31

What did you do?

During debugging my program, I've noticed this unexpected behavior.

What did you see happen?

func main() {
	fmt.Println(strings.TrimLeft(
		"/kubernetes/kubernetes/release-1.30/api/openapi-spec/v3/apis__authentication.k8s.io__v1_openapi.json",
		"/kubernetes/kubernetes/release-1.30/api/openapi-spec/v3/",
	))
	// Expected: "apis__authentication.k8s.io__v1_openapi.json"
	// Actual:   "__authentication.k8s.io__v1_openapi.json"
}

What did you expect to see?

Wrote in the "What did you see happen?" section.

Now I am using filepath.Base() instead.
https://go.dev/play/p/sIBOz9OmLuV

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