Hello gophers, I’m having strange results with this code:
prefix := "/opt/research"
l := []string{
"/opt/research/comm/aa/bb/file1.xml",
"/opt/research/comm/cc/dd/file2.xml",
"/opt/research/non_comm/aa/bb/file1.xml",
"/opt/research/non_comm/cc/dd/file2.xml",
}
for _, v := range l {
fmt.Println(strings.TrimLeft(v, prefix))
}
(link to the playbook: https://play.golang.org/p/QhWN-MUk97Q)
I was expecting this:
comm/aa/bb/file1.xml
comm/cc/dd/file2.xml
non_comm/aa/bb/file1.xml
non_comm/cc/dd/file2.xml
but instead I got this:
mm/aa/bb/file1.xml
mm/cc/dd/file2.xml
non_comm/aa/bb/file1.xml
non_comm/cc/dd/file2.xml
The same happens with strings.Trim()
Any ideas of why that happens?