frostfs-sdk-go/api/util/protogen/internalgengo/getter.go
Pavel Pogodaev 6ce73790ea
All checks were successful
DCO / DCO (pull_request) Successful in 38s
Tests and linters / Tests (pull_request) Successful in 1m13s
Tests and linters / Lint (pull_request) Successful in 2m36s
[#276] Merge repo with frostfs-api-go
Signed-off-by: Pavel Pogodaev <p.pogodaev@yadro.com>
2024-10-22 14:05:12 +00:00

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