Skip to content

Commit 6ca0d00

Browse files
committed
style changes to ./exchanges.go
1 parent ae05fa5 commit 6ca0d00

2 files changed

Lines changed: 33 additions & 28 deletions

File tree

example/generated/exchanges.go

Lines changed: 22 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -4,28 +4,27 @@ package stringsvc
44

55
import entity "github.com/devimteam/microgen/example/svc/entity"
66

7-
type UppercaseRequest struct {
8-
StringsMap map[string]string `json:"strings_map"`
9-
}
7+
type (
8+
UppercaseRequest struct {
9+
StringsMap map[string]string `json:"strings_map"`
10+
}
11+
UppercaseResponse struct {
12+
Ans string `json:"ans"`
13+
}
1014

11-
type UppercaseResponse struct {
12-
Ans string `json:"ans"`
13-
}
15+
CountRequest struct {
16+
Text string `json:"text"`
17+
Symbol string `json:"symbol"`
18+
}
19+
CountResponse struct {
20+
Count int `json:"count"`
21+
Positions []int `json:"positions"`
22+
}
1423

15-
type CountRequest struct {
16-
Text string `json:"text"`
17-
Symbol string `json:"symbol"`
18-
}
19-
20-
type CountResponse struct {
21-
Count int `json:"count"`
22-
Positions []int `json:"positions"`
23-
}
24-
25-
type TestCaseRequest struct {
26-
Comments []*entity.Comment `json:"comments"`
27-
}
28-
29-
type TestCaseResponse struct {
30-
Tree map[string]int `json:"tree"`
31-
}
24+
TestCaseRequest struct {
25+
Comments []*entity.Comment `json:"comments"`
26+
}
27+
TestCaseResponse struct {
28+
Tree map[string]int `json:"tree"`
29+
}
30+
)

generator/template/exchange.go

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,16 @@ func (t *exchangeTemplate) Render() write_strategy.Renderer {
4646
f.PackageComment(t.Info.FileHeader)
4747
f.PackageComment(`Please, do not edit.`)
4848

49+
if len(t.Info.Iface.Methods) > 0 {
50+
f.Type().Op("(")
51+
}
4952
for _, signature := range t.Info.Iface.Methods {
50-
f.Add(exchange(requestStructName(signature), RemoveContextIfFirst(signature.Args))).Line()
53+
f.Add(exchange(requestStructName(signature), RemoveContextIfFirst(signature.Args))) //.Line()
5154
f.Add(exchange(responseStructName(signature), removeErrorIfLast(signature.Results))).Line()
5255
}
56+
if len(t.Info.Iface.Methods) > 0 {
57+
f.Op(")")
58+
}
5359

5460
return f
5561
}
@@ -75,12 +81,12 @@ func (t *exchangeTemplate) ChooseStrategy() (write_strategy.Strategy, error) {
7581
func exchange(name string, params []types.Variable) Code {
7682
if len(params) == 0 {
7783
return Comment("Formal exchange type, please do not delete.").Line().
78-
Type().Id(name).Struct().
79-
Line()
84+
Id(name).Struct()
85+
//Line()
8086
}
81-
return Type().Id(name).StructFunc(func(g *Group) {
87+
return Id(name).StructFunc(func(g *Group) {
8288
for _, param := range params {
8389
g.Add(structField(&param))
8490
}
85-
}).Line()
91+
}) //.Line()
8692
}

0 commit comments

Comments
 (0)