mirror of
https://github.com/chai2010/advanced-go-programming-book.git
synced 2025-05-24 12:32:21 +00:00
commit
eabbf3598c
@ -285,18 +285,16 @@ func (p *netrpcPlugin) buildServiceSpec(svc *descriptor.ServiceDescriptorProto)
|
|||||||
|
|
||||||
```go
|
```go
|
||||||
func (p *netrpcPlugin) genServiceCode(svc *descriptor.ServiceDescriptorProto) {
|
func (p *netrpcPlugin) genServiceCode(svc *descriptor.ServiceDescriptorProto) {
|
||||||
for _, svc := range file.Service {
|
spec := p.buildServiceSpec(svc)
|
||||||
spec := p.buildServiceSpec(svc)
|
|
||||||
|
|
||||||
var buf bytes.Buffer
|
var buf bytes.Buffer
|
||||||
t := template.Must(template.New("").Parse(tmplService))
|
t := template.Must(template.New("").Parse(tmplService))
|
||||||
err := t.Execute(&buf, spec)
|
err := t.Execute(&buf, spec)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
|
||||||
|
|
||||||
p.P(buf.String())
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
p.P(buf.String())
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user