[#77] protogen: Initial implementation
Some checks failed
DCO action / DCO (pull_request) Successful in 43s
Tests and linters / Tests (1.19) (pull_request) Successful in 42s
Tests and linters / Lint (pull_request) Failing after 52s
Tests and linters / Tests (1.20) (pull_request) Successful in 50s
Tests and linters / Tests with -race (pull_request) Successful in 1m10s
Some checks failed
DCO action / DCO (pull_request) Successful in 43s
Tests and linters / Tests (1.19) (pull_request) Successful in 42s
Tests and linters / Lint (pull_request) Failing after 52s
Tests and linters / Tests (1.20) (pull_request) Successful in 50s
Tests and linters / Tests with -race (pull_request) Successful in 1m10s
Signed-off-by: Evgenii Stratonikov <e.stratonikov@yadro.com>
This commit is contained in:
parent
5febaebbd7
commit
6e8a0e09af
115 changed files with 36087 additions and 20397 deletions
14
util/protogen/internal_gengo/getter.go
Normal file
14
util/protogen/internal_gengo/getter.go
Normal file
|
@ -0,0 +1,14 @@
|
|||
package internal_gengo
|
||||
|
||||
import "google.golang.org/protobuf/compiler/protogen"
|
||||
|
||||
func emitGetterSetter(g *protogen.GeneratedFile, typeName string, fieldName string, fieldType string, defaultValue string) {
|
||||
g.P("func (x *", typeName, ") Get", fieldName, "() ", fieldType, " {")
|
||||
g.P("if x != nil { return x.", fieldName, "}")
|
||||
g.P("return ", defaultValue)
|
||||
g.P("}")
|
||||
|
||||
g.P("func (x *", typeName, ") Set", fieldName, "(v ", fieldType, ") {")
|
||||
g.P("x.", fieldName, " = v")
|
||||
g.P("}")
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue