本文整理汇总了Golang中github.com/janelia-flyem/dvid/datastore.Response.Output方法的典型用法代码示例。如果您正苦于以下问题:Golang Response.Output方法的具体用法?Golang Response.Output怎么用?Golang Response.Output使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/janelia-flyem/dvid/datastore.Response
的用法示例。
在下文中一共展示了Response.Output方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: put
// put handles a PUT command-line request.
func (d *Data) put(cmd datastore.Request, reply *datastore.Response) error {
if len(cmd.Command) < 5 {
return fmt.Errorf("The key name must be specified after 'put'")
}
if len(cmd.Input) == 0 {
return fmt.Errorf("No data was passed into standard input")
}
var uuidStr, dataName, cmdStr, keyStr string
cmd.CommandArgs(1, &uuidStr, &dataName, &cmdStr, &keyStr)
_, versionID, err := datastore.MatchingUUID(uuidStr)
if err != nil {
return err
}
// Store data
if !d.Versioned() {
// Map everything to root version.
versionID, err = datastore.GetRepoRootVersion(versionID)
if err != nil {
return err
}
}
ctx := datastore.NewVersionedCtx(d, versionID)
if err = d.PutData(ctx, keyStr, cmd.Input); err != nil {
return fmt.Errorf("Error on put to key %q for keyvalue %q: %v\n", keyStr, d.DataName(), err)
}
reply.Output = []byte(fmt.Sprintf("Put %d bytes into key %q for keyvalue %q, uuid %s\n",
len(cmd.Input), keyStr, d.DataName(), uuidStr))
return nil
}
示例2: Send
// Send transmits an RPC command if a server is available.
func (c *Client) Send(request datastore.Request) error {
var reply datastore.Response
if c.client != nil {
err := c.client.Call("RPCConnection.Do", request, &reply)
if err != nil {
return fmt.Errorf("RPC error for '%s': %v", request.Command, err)
}
} else {
reply.Output = []byte(fmt.Sprintf("No DVID server is available: %s\n", request.Command))
}
return reply.Write(os.Stdout)
}