diff --git a/sdks/go/pkg/beam/transforms/stats/sum.go b/sdks/go/pkg/beam/transforms/stats/sum.go
index fa399e4bc4539..08a694f01a64c 100644
--- a/sdks/go/pkg/beam/transforms/stats/sum.go
+++ b/sdks/go/pkg/beam/transforms/stats/sum.go
@@ -21,6 +21,7 @@ import (
//go:generate specialize --input=sum_switch.tmpl --x=integers,floats
//go:generate gofmt -w sum_switch.go
+//go:generate go generate sum_switch.go
// Sum returns the sum of the elements in a PCollection as a singleton
// PCollection. It can only be used for numbers, such as int, uint16,
diff --git a/sdks/go/pkg/beam/transforms/stats/sum_switch.go b/sdks/go/pkg/beam/transforms/stats/sum_switch.go
index 4c80ec27b970a..d1e0a383f963e 100644
--- a/sdks/go/pkg/beam/transforms/stats/sum_switch.go
+++ b/sdks/go/pkg/beam/transforms/stats/sum_switch.go
@@ -20,24 +20,9 @@ package stats
import (
"fmt"
"reflect"
-
- "github.com/apache/beam/sdks/go/pkg/beam"
)
-func init() {
- beam.RegisterFunction(sumIntFn)
- beam.RegisterFunction(sumInt8Fn)
- beam.RegisterFunction(sumInt16Fn)
- beam.RegisterFunction(sumInt32Fn)
- beam.RegisterFunction(sumInt64Fn)
- beam.RegisterFunction(sumUintFn)
- beam.RegisterFunction(sumUint8Fn)
- beam.RegisterFunction(sumUint16Fn)
- beam.RegisterFunction(sumUint32Fn)
- beam.RegisterFunction(sumUint64Fn)
- beam.RegisterFunction(sumFloat32Fn)
- beam.RegisterFunction(sumFloat64Fn)
-}
+//go:generate starcgen --inputs=sum_switch.go --output=sum_switch.shims.go --identifiers=sumIntFn,sumInt8Fn,sumInt16Fn,sumInt32Fn,sumInt64Fn,sumUintFn,sumUint8Fn,sumUint16Fn,sumUint32Fn,sumUint64Fn,sumFloat32Fn,sumFloat64Fn
func findSumFn(t reflect.Type) interface{} {
switch t.String() {
diff --git a/sdks/go/pkg/beam/transforms/stats/sum_switch.shims.go b/sdks/go/pkg/beam/transforms/stats/sum_switch.shims.go
new file mode 100644
index 0000000000000..41b917fb6269d
--- /dev/null
+++ b/sdks/go/pkg/beam/transforms/stats/sum_switch.shims.go
@@ -0,0 +1,371 @@
+// Licensed to the Apache Software Foundation (ASF) under one or more
+// contributor license agreements. See the NOTICE file distributed with
+// this work for additional information regarding copyright ownership.
+// The ASF licenses this file to You under the Apache License, Version 2.0
+// (the "License"); you may not use this file except in compliance with
+// the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+// Code generated by starcgen. DO NOT EDIT.
+// File: sum_switch.shims.go
+
+package stats
+
+import (
+ "reflect"
+
+ // Library imports
+ "github.com/apache/beam/sdks/go/pkg/beam/core/runtime"
+ "github.com/apache/beam/sdks/go/pkg/beam/core/util/reflectx"
+)
+
+func init() {
+ runtime.RegisterFunction(sumFloat32Fn)
+ runtime.RegisterFunction(sumFloat64Fn)
+ runtime.RegisterFunction(sumInt16Fn)
+ runtime.RegisterFunction(sumInt32Fn)
+ runtime.RegisterFunction(sumInt64Fn)
+ runtime.RegisterFunction(sumInt8Fn)
+ runtime.RegisterFunction(sumIntFn)
+ runtime.RegisterFunction(sumUint16Fn)
+ runtime.RegisterFunction(sumUint32Fn)
+ runtime.RegisterFunction(sumUint64Fn)
+ runtime.RegisterFunction(sumUint8Fn)
+ runtime.RegisterFunction(sumUintFn)
+ reflectx.RegisterFunc(reflect.TypeOf((*func(float32,float32) (float32))(nil)).Elem(), funcMakerFloat32Float32ГFloat32)
+ reflectx.RegisterFunc(reflect.TypeOf((*func(float64,float64) (float64))(nil)).Elem(), funcMakerFloat64Float64ГFloat64)
+ reflectx.RegisterFunc(reflect.TypeOf((*func(int16,int16) (int16))(nil)).Elem(), funcMakerInt16Int16ГInt16)
+ reflectx.RegisterFunc(reflect.TypeOf((*func(int32,int32) (int32))(nil)).Elem(), funcMakerInt32Int32ГInt32)
+ reflectx.RegisterFunc(reflect.TypeOf((*func(int64,int64) (int64))(nil)).Elem(), funcMakerInt64Int64ГInt64)
+ reflectx.RegisterFunc(reflect.TypeOf((*func(int8,int8) (int8))(nil)).Elem(), funcMakerInt8Int8ГInt8)
+ reflectx.RegisterFunc(reflect.TypeOf((*func(int,int) (int))(nil)).Elem(), funcMakerIntIntГInt)
+ reflectx.RegisterFunc(reflect.TypeOf((*func(uint16,uint16) (uint16))(nil)).Elem(), funcMakerUint16Uint16ГUint16)
+ reflectx.RegisterFunc(reflect.TypeOf((*func(uint32,uint32) (uint32))(nil)).Elem(), funcMakerUint32Uint32ГUint32)
+ reflectx.RegisterFunc(reflect.TypeOf((*func(uint64,uint64) (uint64))(nil)).Elem(), funcMakerUint64Uint64ГUint64)
+ reflectx.RegisterFunc(reflect.TypeOf((*func(uint8,uint8) (uint8))(nil)).Elem(), funcMakerUint8Uint8ГUint8)
+ reflectx.RegisterFunc(reflect.TypeOf((*func(uint,uint) (uint))(nil)).Elem(), funcMakerUintUintГUint)
+}
+
+type callerFloat32Float32ГFloat32 struct {
+ fn func(float32,float32) (float32)
+}
+
+func funcMakerFloat32Float32ГFloat32(fn interface{}) reflectx.Func {
+ f := fn.(func(float32,float32) (float32))
+ return &callerFloat32Float32ГFloat32{fn: f}
+}
+
+func (c *callerFloat32Float32ГFloat32) Name() string {
+ return reflectx.FunctionName(c.fn)
+}
+
+func (c *callerFloat32Float32ГFloat32) Type() reflect.Type {
+ return reflect.TypeOf(c.fn)
+}
+
+func (c *callerFloat32Float32ГFloat32) Call(args []interface{}) []interface{} {
+ out0 := c.fn(args[0].(float32), args[1].(float32))
+ return []interface{}{out0}
+}
+
+func (c *callerFloat32Float32ГFloat32) Call2x1(arg0, arg1 interface{}) (interface{}) {
+ return c.fn(arg0.(float32), arg1.(float32))
+}
+
+type callerFloat64Float64ГFloat64 struct {
+ fn func(float64,float64) (float64)
+}
+
+func funcMakerFloat64Float64ГFloat64(fn interface{}) reflectx.Func {
+ f := fn.(func(float64,float64) (float64))
+ return &callerFloat64Float64ГFloat64{fn: f}
+}
+
+func (c *callerFloat64Float64ГFloat64) Name() string {
+ return reflectx.FunctionName(c.fn)
+}
+
+func (c *callerFloat64Float64ГFloat64) Type() reflect.Type {
+ return reflect.TypeOf(c.fn)
+}
+
+func (c *callerFloat64Float64ГFloat64) Call(args []interface{}) []interface{} {
+ out0 := c.fn(args[0].(float64), args[1].(float64))
+ return []interface{}{out0}
+}
+
+func (c *callerFloat64Float64ГFloat64) Call2x1(arg0, arg1 interface{}) (interface{}) {
+ return c.fn(arg0.(float64), arg1.(float64))
+}
+
+type callerInt16Int16ГInt16 struct {
+ fn func(int16,int16) (int16)
+}
+
+func funcMakerInt16Int16ГInt16(fn interface{}) reflectx.Func {
+ f := fn.(func(int16,int16) (int16))
+ return &callerInt16Int16ГInt16{fn: f}
+}
+
+func (c *callerInt16Int16ГInt16) Name() string {
+ return reflectx.FunctionName(c.fn)
+}
+
+func (c *callerInt16Int16ГInt16) Type() reflect.Type {
+ return reflect.TypeOf(c.fn)
+}
+
+func (c *callerInt16Int16ГInt16) Call(args []interface{}) []interface{} {
+ out0 := c.fn(args[0].(int16), args[1].(int16))
+ return []interface{}{out0}
+}
+
+func (c *callerInt16Int16ГInt16) Call2x1(arg0, arg1 interface{}) (interface{}) {
+ return c.fn(arg0.(int16), arg1.(int16))
+}
+
+type callerInt32Int32ГInt32 struct {
+ fn func(int32,int32) (int32)
+}
+
+func funcMakerInt32Int32ГInt32(fn interface{}) reflectx.Func {
+ f := fn.(func(int32,int32) (int32))
+ return &callerInt32Int32ГInt32{fn: f}
+}
+
+func (c *callerInt32Int32ГInt32) Name() string {
+ return reflectx.FunctionName(c.fn)
+}
+
+func (c *callerInt32Int32ГInt32) Type() reflect.Type {
+ return reflect.TypeOf(c.fn)
+}
+
+func (c *callerInt32Int32ГInt32) Call(args []interface{}) []interface{} {
+ out0 := c.fn(args[0].(int32), args[1].(int32))
+ return []interface{}{out0}
+}
+
+func (c *callerInt32Int32ГInt32) Call2x1(arg0, arg1 interface{}) (interface{}) {
+ return c.fn(arg0.(int32), arg1.(int32))
+}
+
+type callerInt64Int64ГInt64 struct {
+ fn func(int64,int64) (int64)
+}
+
+func funcMakerInt64Int64ГInt64(fn interface{}) reflectx.Func {
+ f := fn.(func(int64,int64) (int64))
+ return &callerInt64Int64ГInt64{fn: f}
+}
+
+func (c *callerInt64Int64ГInt64) Name() string {
+ return reflectx.FunctionName(c.fn)
+}
+
+func (c *callerInt64Int64ГInt64) Type() reflect.Type {
+ return reflect.TypeOf(c.fn)
+}
+
+func (c *callerInt64Int64ГInt64) Call(args []interface{}) []interface{} {
+ out0 := c.fn(args[0].(int64), args[1].(int64))
+ return []interface{}{out0}
+}
+
+func (c *callerInt64Int64ГInt64) Call2x1(arg0, arg1 interface{}) (interface{}) {
+ return c.fn(arg0.(int64), arg1.(int64))
+}
+
+type callerInt8Int8ГInt8 struct {
+ fn func(int8,int8) (int8)
+}
+
+func funcMakerInt8Int8ГInt8(fn interface{}) reflectx.Func {
+ f := fn.(func(int8,int8) (int8))
+ return &callerInt8Int8ГInt8{fn: f}
+}
+
+func (c *callerInt8Int8ГInt8) Name() string {
+ return reflectx.FunctionName(c.fn)
+}
+
+func (c *callerInt8Int8ГInt8) Type() reflect.Type {
+ return reflect.TypeOf(c.fn)
+}
+
+func (c *callerInt8Int8ГInt8) Call(args []interface{}) []interface{} {
+ out0 := c.fn(args[0].(int8), args[1].(int8))
+ return []interface{}{out0}
+}
+
+func (c *callerInt8Int8ГInt8) Call2x1(arg0, arg1 interface{}) (interface{}) {
+ return c.fn(arg0.(int8), arg1.(int8))
+}
+
+type callerIntIntГInt struct {
+ fn func(int,int) (int)
+}
+
+func funcMakerIntIntГInt(fn interface{}) reflectx.Func {
+ f := fn.(func(int,int) (int))
+ return &callerIntIntГInt{fn: f}
+}
+
+func (c *callerIntIntГInt) Name() string {
+ return reflectx.FunctionName(c.fn)
+}
+
+func (c *callerIntIntГInt) Type() reflect.Type {
+ return reflect.TypeOf(c.fn)
+}
+
+func (c *callerIntIntГInt) Call(args []interface{}) []interface{} {
+ out0 := c.fn(args[0].(int), args[1].(int))
+ return []interface{}{out0}
+}
+
+func (c *callerIntIntГInt) Call2x1(arg0, arg1 interface{}) (interface{}) {
+ return c.fn(arg0.(int), arg1.(int))
+}
+
+type callerUint16Uint16ГUint16 struct {
+ fn func(uint16,uint16) (uint16)
+}
+
+func funcMakerUint16Uint16ГUint16(fn interface{}) reflectx.Func {
+ f := fn.(func(uint16,uint16) (uint16))
+ return &callerUint16Uint16ГUint16{fn: f}
+}
+
+func (c *callerUint16Uint16ГUint16) Name() string {
+ return reflectx.FunctionName(c.fn)
+}
+
+func (c *callerUint16Uint16ГUint16) Type() reflect.Type {
+ return reflect.TypeOf(c.fn)
+}
+
+func (c *callerUint16Uint16ГUint16) Call(args []interface{}) []interface{} {
+ out0 := c.fn(args[0].(uint16), args[1].(uint16))
+ return []interface{}{out0}
+}
+
+func (c *callerUint16Uint16ГUint16) Call2x1(arg0, arg1 interface{}) (interface{}) {
+ return c.fn(arg0.(uint16), arg1.(uint16))
+}
+
+type callerUint32Uint32ГUint32 struct {
+ fn func(uint32,uint32) (uint32)
+}
+
+func funcMakerUint32Uint32ГUint32(fn interface{}) reflectx.Func {
+ f := fn.(func(uint32,uint32) (uint32))
+ return &callerUint32Uint32ГUint32{fn: f}
+}
+
+func (c *callerUint32Uint32ГUint32) Name() string {
+ return reflectx.FunctionName(c.fn)
+}
+
+func (c *callerUint32Uint32ГUint32) Type() reflect.Type {
+ return reflect.TypeOf(c.fn)
+}
+
+func (c *callerUint32Uint32ГUint32) Call(args []interface{}) []interface{} {
+ out0 := c.fn(args[0].(uint32), args[1].(uint32))
+ return []interface{}{out0}
+}
+
+func (c *callerUint32Uint32ГUint32) Call2x1(arg0, arg1 interface{}) (interface{}) {
+ return c.fn(arg0.(uint32), arg1.(uint32))
+}
+
+type callerUint64Uint64ГUint64 struct {
+ fn func(uint64,uint64) (uint64)
+}
+
+func funcMakerUint64Uint64ГUint64(fn interface{}) reflectx.Func {
+ f := fn.(func(uint64,uint64) (uint64))
+ return &callerUint64Uint64ГUint64{fn: f}
+}
+
+func (c *callerUint64Uint64ГUint64) Name() string {
+ return reflectx.FunctionName(c.fn)
+}
+
+func (c *callerUint64Uint64ГUint64) Type() reflect.Type {
+ return reflect.TypeOf(c.fn)
+}
+
+func (c *callerUint64Uint64ГUint64) Call(args []interface{}) []interface{} {
+ out0 := c.fn(args[0].(uint64), args[1].(uint64))
+ return []interface{}{out0}
+}
+
+func (c *callerUint64Uint64ГUint64) Call2x1(arg0, arg1 interface{}) (interface{}) {
+ return c.fn(arg0.(uint64), arg1.(uint64))
+}
+
+type callerUint8Uint8ГUint8 struct {
+ fn func(uint8,uint8) (uint8)
+}
+
+func funcMakerUint8Uint8ГUint8(fn interface{}) reflectx.Func {
+ f := fn.(func(uint8,uint8) (uint8))
+ return &callerUint8Uint8ГUint8{fn: f}
+}
+
+func (c *callerUint8Uint8ГUint8) Name() string {
+ return reflectx.FunctionName(c.fn)
+}
+
+func (c *callerUint8Uint8ГUint8) Type() reflect.Type {
+ return reflect.TypeOf(c.fn)
+}
+
+func (c *callerUint8Uint8ГUint8) Call(args []interface{}) []interface{} {
+ out0 := c.fn(args[0].(uint8), args[1].(uint8))
+ return []interface{}{out0}
+}
+
+func (c *callerUint8Uint8ГUint8) Call2x1(arg0, arg1 interface{}) (interface{}) {
+ return c.fn(arg0.(uint8), arg1.(uint8))
+}
+
+type callerUintUintГUint struct {
+ fn func(uint,uint) (uint)
+}
+
+func funcMakerUintUintГUint(fn interface{}) reflectx.Func {
+ f := fn.(func(uint,uint) (uint))
+ return &callerUintUintГUint{fn: f}
+}
+
+func (c *callerUintUintГUint) Name() string {
+ return reflectx.FunctionName(c.fn)
+}
+
+func (c *callerUintUintГUint) Type() reflect.Type {
+ return reflect.TypeOf(c.fn)
+}
+
+func (c *callerUintUintГUint) Call(args []interface{}) []interface{} {
+ out0 := c.fn(args[0].(uint), args[1].(uint))
+ return []interface{}{out0}
+}
+
+func (c *callerUintUintГUint) Call2x1(arg0, arg1 interface{}) (interface{}) {
+ return c.fn(arg0.(uint), arg1.(uint))
+}
+
+
+
+
+// DO NOT MODIFY: GENERATED CODE
diff --git a/sdks/go/pkg/beam/transforms/stats/sum_switch.tmpl b/sdks/go/pkg/beam/transforms/stats/sum_switch.tmpl
index ddafb95dfb48d..b622e56463c00 100644
--- a/sdks/go/pkg/beam/transforms/stats/sum_switch.tmpl
+++ b/sdks/go/pkg/beam/transforms/stats/sum_switch.tmpl
@@ -18,15 +18,11 @@ package stats
import (
"fmt"
"reflect"
-
- "github.com/apache/beam/sdks/go/pkg/beam"
)
-func init() {
-{{- range .X}}
- beam.RegisterFunction(sum{{.Name}}Fn)
-{{- end}}
-}
+{{with $x := .X }}
+//go:generate starcgen --inputs=sum_switch.go --output=sum_switch.shims.go --identifiers={{- range $i, $t := $x -}}{{if $i}},{{end}}sum{{$t.Name}}Fn{{- end -}}
+{{end}}
func findSumFn(t reflect.Type) interface{} {
switch t.String() {