本文整理汇总了Golang中github.com/MJKWoolnough/byteio.StickyWriter.WriteInt64方法的典型用法代码示例。如果您正苦于以下问题:Golang StickyWriter.WriteInt64方法的具体用法?Golang StickyWriter.WriteInt64怎么用?Golang StickyWriter.WriteInt64使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/MJKWoolnough/byteio.StickyWriter
的用法示例。
在下文中一共展示了StickyWriter.WriteInt64方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: generate
//.........这里部分代码省略.........
for n, g := range t.c.Generators.List {
gs[n] = *g
}
t.c.Generators.mu.RUnlock()
var g data.Generator
if len(gs) == 0 {
return errors.New("no generators installed")
} else if len(gs) == 1 {
g = gs[0]
} else {
w.WriteUint8(1)
w.WriteInt16(int16(len(gs)))
for _, tg := range gs {
data.WriteString(w, tg.Name)
}
if w.Err != nil {
return w.Err
}
gID := r.ReadInt16()
if r.Err != nil {
return r.Err
}
if gID < 0 || int(gID) >= len(gs) {
return errors.New("unknown generator")
}
g = gs[gID]
}
ms := DefaultMapSettings()
ms["level-type"] = minecraft.FlatGenerator
ms["generator-settings"] = "0"
ms["motd"] = name
j, err := os.Open(path.Join(g.Path, "data.gen"))
if err != nil {
return err
}
var gj data.GeneratorData
err = json.NewDecoder(j).Decode(&gj)
j.Close()
if err != nil {
return err
}
for k, v := range gj.Options {
ms[k] = v
}
pf, err := os.Create(path.Join(mapPath, "properties.map"))
if err != nil {
return err
}
if err = ms.WriteTo(pf); err != nil {
return err
}
pf.Close()
cmd := exec.Command(t.c.Settings().GeneratorExecutable)
cmd.ExtraFiles = append(cmd.ExtraFiles, f)
cmd.Dir, err = os.Getwd()
if err != nil {
return err
}
cmd.Stdout = w
pw, err := cmd.StdinPipe()
if err != nil {
return err
}
err = gp.Start(cmd)
if err != nil {
return err
}
defer gp.Remove(cmd)
pww := byteio.StickyWriter{Writer: &byteio.LittleEndianWriter{pw}}
pww.WriteUint64(t.c.Settings().GeneratorMaxMem)
pww.WriteInt64(size)
data.WriteString(&pww, g.Path)
data.WriteString(&pww, name)
data.WriteString(&pww, mapPath)
if pww.Err != nil {
return pww.Err
}
err = cmd.Wait()
if err != nil {
return err
}
done = true
mp.Lock()
mp.Server = -1
mp.Unlock()
return nil
}