本文整理匯總了Golang中github.com/HeinOldewage/Hyades.Work.Index方法的典型用法代碼示例。如果您正苦於以下問題:Golang Work.Index方法的具體用法?Golang Work.Index怎麽用?Golang Work.Index使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/HeinOldewage/Hyades.Work
的用法示例。
在下文中一共展示了Work.Index方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: SaveResult
func (ws *WorkServer) SaveResult(w *Hyades.Work, res *Hyades.WorkResult) error {
//Get Job work was part of, Get person Job belonged to and then save under
//Person.JobFolder\Job.JobID\Work.partID\
//Save 3 parts
//Env.zip -- iff len(Env) > 0
//StdOut.txt
//ErrOut.txtlogFile
folder := filepath.Join(ws.dataPath, w.PartOf().JobFolder, w.PartOf().Name+fmt.Sprint(w.PartOf().Id), strconv.Itoa(w.Index()))
err := os.MkdirAll(folder, os.ModeDir|os.ModePerm)
if err != nil {
ws.Log.Println(err)
return err
}
if res.EnvLength > 0 {
envfile, err := os.Create(filepath.Join(folder, "Env.zip"))
if err != nil {
ws.Log.Println(err)
}
defer envfile.Close()
_, err = io.CopyN(envfile, res.GetEnv(), int64(res.EnvLength))
if err != nil {
ws.Log.Println(err)
log.Println("SaveResult", err)
return err
}
}
stdout, err := os.Create(filepath.Join(folder, "StdOut.txt"))
if err != nil {
ws.Log.Println(err)
return err
}
defer stdout.Close()
stdout.Write(res.StdOutStream)
errout, err := os.Create(filepath.Join(folder, "ErrOut.txt"))
if err != nil {
ws.Log.Println(err)
}
defer errout.Close()
errout.Write(res.ErrOutStream)
return nil
}