-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathextern.go
48 lines (39 loc) · 1 KB
/
extern.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
package errgoengine
import (
"fmt"
"io/fs"
)
type ExternSymbol struct {
Name string `json:"name"`
Type string `json:"type"`
ReturnType string `json:"returnType"`
Paremeters []ExternSymbol `json:"parameters"`
}
type ExternFile struct {
Name string `json:"name"`
Package string `json:"package"`
Constructors []ExternSymbol `json:"constructors"`
Methods []ExternSymbol `json:"methods"`
}
func ImportExternSymbols(externFs fs.ReadFileFS) (map[string]*SymbolTree, error) {
if externFs == nil {
return nil, nil
}
symbols := make(map[string]*SymbolTree)
matches, err := fs.Glob(externFs, "**/*.json")
if err != nil {
return nil, err
}
for _, match := range matches {
if err := compileExternSymbol(externFs, match); err != nil {
return symbols, err
}
}
return symbols, nil
}
func compileExternSymbol(externFs fs.FS, path string) error {
if externFs == nil {
return fmt.Errorf("externFs must not be nil")
}
return nil
}