forked from nsf/gocode
-
Notifications
You must be signed in to change notification settings - Fork 1
/
object_go14.go
53 lines (43 loc) · 889 Bytes
/
object_go14.go
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
// Search for objects with go1.4 and prior extensions
//go:build !go1.5
// +build !go1.5
package gocode
import "github.com/charlievieth/gocode/fs"
func (m *package_file_cache) find_file() string {
if file_exists(m.name) {
return m.name
}
n := len(m.name)
filename := m.name[:n-1] + "6"
if file_exists(filename) {
return filename
}
filename = m.name[:n-1] + "8"
if file_exists(filename) {
return filename
}
filename = m.name[:n-1] + "5"
if file_exists(filename) {
return filename
}
return m.name
}
func (m *package_file_cache) update_cache() {
if m.mtime == -1 {
return
}
fname := m.find_file()
stat, err := fs.Stat(fname)
if err != nil {
return
}
statmtime := stat.ModTime().UnixNano()
if m.mtime != statmtime {
m.mtime = statmtime
data, err := file_reader.read_file(fname)
if err != nil {
return
}
m.process_package_data(data)
}
}