本文整理汇总了Golang中v/io/v23/context.T.Errorf方法的典型用法代码示例。如果您正苦于以下问题:Golang T.Errorf方法的具体用法?Golang T.Errorf怎么用?Golang T.Errorf使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类v/io/v23/context.T
的用法示例。
在下文中一共展示了T.Errorf方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: Invoke
// Invoke calls the mojom service based on the suffix and converts the mojom
// results (a struct) to Vanadium results (a slice of *vom.RawBytes).
// Note: The argptrs from Prepare are reused here. The vom bytes should have
// been decoded into these argptrs, so there are actual values inside now.
func (fs fakeService) Invoke(ctx *context.T, call rpc.StreamServerCall, method string, argptrs []interface{}) (results []interface{}, _ error) {
// fs.suffix consists of the mojo url and the application/interface name.
// The last part should be the name; everything else is the url.
parts := strings.Split(fs.suffix, "/")
mojourl := strings.Join(parts[:len(parts)-1], "/") // e.g., mojo:go_remote_echo_server. May be defined in a BUILD.gn file.
mojoname := parts[len(parts)-1] // e.g., mojo::examples::RemoteEcho. Defined from the interface + module.
// Create the generic message pipe. r is a bindings.InterfaceRequest, and
// p is a bindings.InterfacePointer.
r, p := bindings.CreateMessagePipeForMojoInterface()
v := v23ServiceRequest{
request: r,
name: mojoname,
} // v is an application.ServiceRequest with mojoname
// Connect to the mojourl.
fs.appctx.ConnectToApplication(mojourl).ConnectToService(&v)
// Then assign a new router the FakeService.
// This will never conflict because each FakeService is only invoked once.
fs.router = bindings.NewRouter(p.PassMessagePipe(), bindings.GetAsyncWaiter())
defer fs.Close_Proxy()
ctx.Infof("Fake Service Invoke (Remote Signature: %q -- %q)", mojourl, mojoname)
// Vanadium relies on type information, so we will retrieve that first.
mojomInterface, desc, err := fs.callRemoteSignature(mojourl, mojoname)
if err != nil {
return nil, err
}
ctx.Infof("Fake Service Invoke Signature %v", mojomInterface)
ctx.Infof("Fake Service Invoke (Remote Method: %v)", method)
// With the type information, we can make the method call to the remote interface.
methodResults, err := fs.callRemoteMethod(ctx, method, mojomInterface, desc, argptrs)
if err != nil {
ctx.Errorf("Method called failed: %v", err)
return nil, err
}
ctx.Infof("Fake Service Invoke Results %v", methodResults)
// Convert methodResult to results.
results = make([]interface{}, len(methodResults))
for i := range methodResults {
results[i] = &methodResults[i]
}
return results, nil
}