frostfs-api-go/util/protogen/internalgengo/getter.go

15 lines
479 B
Go
Raw Normal View History

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