本文整理匯總了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
}