-
Notifications
You must be signed in to change notification settings - Fork 26
Expand file tree
/
Copy pathutils.go
More file actions
31 lines (27 loc) · 703 Bytes
/
utils.go
File metadata and controls
31 lines (27 loc) · 703 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
package main
import (
"path/filepath"
"strings"
)
func starts(search string, line string) bool {
if len(line) < len(search) {
return false
}
return line[:len(search)] == search
}
func after(search string, line string) string {
if len(line) < len(search) {
return ""
}
line = line[len(search):]
line = strings.Replace(line, "\"", "", 2)
line = strings.Replace(line, ";", "", 2)
return filepath.Clean(line)
}
func trueFile(callFrom string, importName string) string {
importName = strings.Replace(importName, "\"", "", 2)
importName = strings.Replace(importName, ";", "", 2)
pos := strings.LastIndex(callFrom, "/")
ret := callFrom[:pos+1] + importName
return filepath.Clean(ret)
}