forked from markbates/pkger
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcreate.go
More file actions
51 lines (42 loc) · 832 Bytes
/
Copy pathcreate.go
File metadata and controls
51 lines (42 loc) · 832 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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
package parser
import (
"encoding/json"
"go/token"
"os"
)
var _ Decl = CreateDecl{}
type CreateDecl struct {
file *File
pos token.Position
value string
}
func (d CreateDecl) String() string {
b, _ := json.Marshal(d)
return string(b)
}
func (d CreateDecl) MarshalJSON() ([]byte, error) {
return json.Marshal(map[string]interface{}{
"type": "pkger.Create",
"file": d.file,
"pos": d.pos,
"value": d.value,
})
}
func (d CreateDecl) File() (*File, error) {
if d.file == nil {
return nil, os.ErrNotExist
}
return d.file, nil
}
func (d CreateDecl) Position() (token.Position, error) {
return d.pos, nil
}
func (d CreateDecl) Value() (string, error) {
if d.value == "" {
return "", os.ErrNotExist
}
return d.value, nil
}
func (d CreateDecl) VirtualPaths() []string {
return []string{d.value}
}