本文整理汇总了Golang中github.com/jpillora/archive.Archive.AddBytesMTime方法的典型用法代码示例。如果您正苦于以下问题:Golang Archive.AddBytesMTime方法的具体用法?Golang Archive.AddBytesMTime怎么用?Golang Archive.AddBytesMTime使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/jpillora/archive.Archive
的用法示例。
在下文中一共展示了Archive.AddBytesMTime方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: Build
// Build injects a script for loading the environment.
func (p *Plugin) Build(fn *function.Function, zip *archive.Archive) error {
if fn.Runtime != RuntimeCanonical || len(fn.Environment) == 0 {
return nil
}
fn.Log.Debug("injecting prelude")
var buf bytes.Buffer
file := strings.Split(fn.Handler, ".")[0]
method := strings.Split(fn.Handler, ".")[1]
err := prelude.Execute(&buf, struct {
EnvFile string
HandleFile string
HandleMethod string
}{
EnvFile: env.FileName,
HandleFile: file,
HandleMethod: method,
})
if err != nil {
return err
}
fn.Handler = "_apex_main.handle"
return zip.AddBytesMTime("_apex_main.py", buf.Bytes(), time.Unix(0, 0))
}
示例2: Build
// Build hook adds .env.json populate with Function.Enironment.
func (p *Plugin) Build(fn *function.Function, zip *archive.Archive) error {
if len(fn.Environment) == 0 {
return nil
}
fn.Log.WithField("env", fn.Environment).Debug("adding env")
env, err := json.Marshal(fn.Environment)
if err != nil {
return err
}
return zip.AddBytesMTime(FileName, env, time.Unix(0, 0))
}
示例3: Build
// Build adds the nodejs shim files.
func (p *Plugin) Build(fn *function.Function, zip *archive.Archive) error {
if fn.Shim {
fn.Log.Debug("add shim")
if err := zip.AddBytesMTime("index.js", shim.MustAsset("index.js"), time.Unix(0, 0)); err != nil {
return err
}
if err := zip.AddBytesMTime("byline.js", shim.MustAsset("byline.js"), time.Unix(0, 0)); err != nil {
return err
}
}
return nil
}