All checks were successful
DCO action / DCO (pull_request) Successful in 59s
Tests and linters / Tests (1.19) (pull_request) Successful in 55s
Tests and linters / Tests (1.20) (pull_request) Successful in 56s
Tests and linters / Tests with -race (pull_request) Successful in 1m15s
Tests and linters / Lint (pull_request) Successful in 1m24s
Signed-off-by: Evgenii Stratonikov <e.stratonikov@yadro.com>
14 lines
479 B
Go
14 lines
479 B
Go
package internalgengo
|
|
|
|
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("}")
|
|
}
|