type FooServiceProcessor struct { handler FooService } func (p *FooServiceProcessor) runProcessorFunction(key string, seqId int32, iprot, oprot thrift.TProtocol) (found, ok bool, err thrift.TException) { switch key { case "add1": ok, err = p.Process_Add1(seqId, iprot, oprot) return true, ok, err default: return false, false, nil } } func NewFooServiceProcessor(handler FooService) *FooServiceProcessor { return &FooServiceProcessor{handler: handler} } func (p *FooServiceProcessor) Process(iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { name, _, seqId, err := iprot.ReadMessageBegin() if err != nil { return false, err } if found, ok, err := p.runProcessorFunction(name, seqId, iprot, oprot); found { return ok, err } //same not found stuff } func (p *FooServiceProcessor) Process_Add1(seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { //same body... }