代码拉取完成,页面将自动刷新
package packr
import (
"fmt"
"github.com/gobuffalo/packr/v2/file/resolver"
"github.com/gobuffalo/packr/v2/jam/parser"
"github.com/gobuffalo/packr/v2/plog"
"github.com/markbates/safe"
)
var boxes = &boxMap{}
var _ = safe.Run(func() {
p, err := parser.NewFromRoots([]string{}, nil)
if err != nil {
plog.Logger.Error(err)
return
}
boxes, err := p.Run()
if err != nil {
plog.Logger.Error(err)
return
}
for _, box := range boxes {
b := construct(box.Name, box.AbsPath)
_, err = placeBox(b)
if err != nil {
plog.Logger.Error(err)
return
}
}
})
func findBox(name string) (*Box, error) {
key := resolver.Key(name)
plog.Debug("packr", "findBox", "name", name, "key", key)
b, ok := boxes.Load(key)
if !ok {
plog.Debug("packr", "findBox", "name", name, "key", key, "found", ok)
return nil, fmt.Errorf("could not find box %s", name)
}
plog.Debug(b, "found", "box", b)
return b, nil
}
func placeBox(b *Box) (*Box, error) {
key := resolver.Key(b.Name)
eb, _ := boxes.LoadOrStore(key, b)
plog.Debug("packr", "placeBox", "name", eb.Name, "path", eb.Path, "resolution directory", eb.ResolutionDir)
return eb, nil
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。