pathsMatch compares two executable paths, resolving symlinks and absolutizing both
(candidate, target string)
| 293 | |
| 294 | // pathsMatch compares two executable paths, resolving symlinks and absolutizing both |
| 295 | func pathsMatch(candidate, target string) bool { |
| 296 | if candidate == "" || target == "" { |
| 297 | return false |
| 298 | } |
| 299 | |
| 300 | candidateAbs, err := filepath.Abs(candidate) |
| 301 | if err != nil { |
| 302 | return false |
| 303 | } |
| 304 | targetAbs, err := filepath.Abs(target) |
| 305 | if err != nil { |
| 306 | return false |
| 307 | } |
| 308 | |
| 309 | if candidateAbs == targetAbs { |
| 310 | return true |
| 311 | } |
| 312 | |
| 313 | candidateReal, errA := filepath.EvalSymlinks(candidateAbs) |
| 314 | targetReal, errB := filepath.EvalSymlinks(targetAbs) |
| 315 | if errA == nil && errB == nil && candidateReal == targetReal { |
| 316 | return true |
| 317 | } |
| 318 | |
| 319 | return false |
| 320 | } |
no outgoing calls
no test coverage detected