[#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

Signed-off-by: Evgenii Stratonikov <e.stratonikov@yadro.com>
This commit is contained in:
Evgenii Stratonikov 2024-04-25 15:13:10 +03:00
parent 5febaebbd7
commit 6e8a0e09af
115 changed files with 36087 additions and 20397 deletions

View 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("}")
}