it seems that there is an issue with the split method in path/filepath
I have looked at the debugger and it seems like it does not split the path into sections
go version:1.19
debugger output:https://i.stack.imgur.com/5NHZ0.jpg
case fsnotify.Rename:
dir, filename := path.Split(event.Name)
fileIndex := indexOfFile(filename, s.LoggedFiles[dir])
if fileIndex == -1 {
errChannel <- errors.New("file path does not exist in map")
break
}
s.LoggedFiles[dir] = append(s.LoggedFiles[dir], s.LoggedFiles[dir][fileIndex])
fmt.Println(s.LoggedFiles[dir])
}
The path.Split() uses the
/separator. To split OS specific directories you should use the path/filepath.Split() that uses the os.PathSeparator.