-
Notifications
You must be signed in to change notification settings - Fork 6
/
fs_embed_template.go
43 lines (39 loc) · 1013 Bytes
/
fs_embed_template.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
package noodle
var embedTemplate = `
// GetNoodle{{ .name }} returns an extracted EmbedBowl generated from {{ .src }}
func GetNoodle{{ .name }} () (noodle.EmbedBowel, error){
dirs := map[string]noodle.EmbedDir{
{{- range $path, $dir := .dir -}}
"{{ $path }}": {
FileInfo: noodle.FileInfo{
FileName: "{{ $dir.FileInfo.Name }}",
FileSize: {{ $dir.FileInfo.Size }},
FileMode: {{ printf "%#o" $dir.FileInfo.Mode }},
FileModTime: time.Unix({{$dir.FileInfo.ModTime.Unix }}, 0),
FileIsDir: {{ $dir.FileInfo.IsDir }},
},
Entries: []noodle.FileInfo{
{{- range $dir.Entries -}}
{
FileName: "{{ .Name }}",
FileSize: {{ .Size }},
FileMode: {{ printf "%#o" .Mode }},
FileModTime: time.Unix({{.ModTime.Unix }}, 0),
FileIsDir: {{ .IsDir }},
},
{{- end -}}
},
},
{{- end -}}
}
data := {{ printf "%#v" .data }}
bowl := noodle.EmbedBowel{
Dirs: dirs,
Data: data,
}
if err := bowl.ExtractFiles(); err != nil {
return bowl, err
}
return bowl, nil
}
`