本文整理匯總了Golang中code/google/com/p/govt/vt/vtsrv.Req類的典型用法代碼示例。如果您正苦於以下問題:Golang Req類的具體用法?Golang Req怎麽用?Golang Req使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了Req類的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: Write
func (srv *Grande) Write(req *vtsrv.Req) {
var f *os.File
var n int
s := srv.calcScore(req.Tc.Data)
dname := fmt.Sprintf("%s/%02x/%02x", srv.topDir, s[0], s[1])
err := os.MkdirAll(dname, 0777)
if err != nil {
req.RespondError(err.Error())
return
}
f, err = os.OpenFile(srv.Name(s), os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0666)
if err != nil {
req.RespondError(err.Error())
return
}
defer f.Close()
n, err = f.Write(req.Tc.Data)
if err != nil {
req.RespondError(err.Error())
return
}
if n != len(req.Tc.Data) {
req.RespondError("short write")
return
}
req.RespondWrite(s)
}
示例2: Read
func (srv *Vtmap) Read(req *vtsrv.Req) {
srv.Lock()
strscore := string([]byte(req.Tc.Score))
b := srv.htbl[strscore]
srv.Unlock()
if b == nil {
req.RespondError("not found")
} else {
req.RespondRead(b)
}
}
示例3: Read
func (srv *Vtram) Read(req *vtsrv.Req) {
b := srv.getBlock(req.Tc.Score)
if b == nil {
req.RespondError("not found")
} else {
n := int(req.Tc.Count)
if n > len(b.data) {
n = len(b.data)
}
req.RespondRead(b.data[0:n])
}
}
示例4: Write
func (srv *Vtmap) Write(req *vtsrv.Req) {
score := srv.calcScore(req.Tc.Data)
strscore := string([]byte(score))
srv.Lock()
if srv.htbl[strscore] == nil {
block, err := srv.f.WriteBlock(req.Tc.Data)
if err != nil {
srv.Unlock()
req.RespondError(err.Error())
return
}
srv.htbl[strscore] = block
}
srv.Unlock()
req.RespondWrite(score)
}
示例5: Read
func (srv *Grande) Read(req *vtsrv.Req) {
var n int
bname := srv.Name(req.Tc.Score)
f, err := os.Open(bname)
if err != nil {
req.RespondError(err.Error())
return
}
b := make([]byte, req.Tc.Count)
n, err = f.Read(b)
f.Close()
if err != nil {
req.RespondError(err.Error())
return
}
req.RespondRead(b[0:n])
}
示例6: Sync
func (srv *Vtmap) Sync(req *vtsrv.Req) {
srv.f.Sync()
req.RespondSync()
}
示例7: Hello
func (srv *Vtmap) Hello(req *vtsrv.Req) {
req.RespondHello("anonymous", 0, 0)
}
示例8: Write
func (srv *Vtram) Write(req *vtsrv.Req) {
b := srv.putBlock(req.Tc.Btype, req.Tc.Data)
req.RespondWrite(b.score)
}
示例9: Hello
func (srv *Grande) Hello(req *vtsrv.Req) {
req.RespondHello("anonymous", 0, 0)
}