Uploaded image for project: 'Thrift'
  1. Thrift
  2. THRIFT-3128

Go generated code produces name collisions between services

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 0.9.2
    • Fix Version/s: 0.9.3
    • Component/s: Go - Compiler
    • Labels:
      None
    • Environment:

      Built from git, confirmed missing prefixes in t_go_generator.cc

      Description

      =====
      Thrift file to produce problem:
      =====

      namespace go BreakGo

      service S1 {
      i32 Ping(1:i32 i)
      }

      service S2 {
      i32 Ping(1:i32 i)
      }

      =====
      Errors:
      =====

      ../BreakGo/s2.go:222: PingArgs redeclared in this block
      previous declaration at ../BreakGo/s1.go:222
      ../BreakGo/s2.go:226: NewPingArgs redeclared in this block
      previous declaration at ../BreakGo/s1.go:226
      ../BreakGo/s2.go:230: (*PingArgs).GetI redeclared in this block
      previous declaration at ../BreakGo/s1.go:230
      ../BreakGo/s2.go:233: (*PingArgs).Read redeclared in this block
      previous declaration at ../BreakGo/s1.go:233
      ../BreakGo/s2.go:266: (*PingArgs).ReadField1 redeclared in this block
      previous declaration at ../BreakGo/s1.go:266
      ../BreakGo/s2.go:275: (*PingArgs).Write redeclared in this block
      previous declaration at ../BreakGo/s1.go:275
      ../BreakGo/s2.go:291: (*PingArgs).writeField1 redeclared in this block
      previous declaration at ../BreakGo/s1.go:291
      ../BreakGo/s2.go:304: (*PingArgs).String redeclared in this block
      previous declaration at ../BreakGo/s1.go:304
      ../BreakGo/s2.go:313: PingResult redeclared in this block
      previous declaration at ../BreakGo/s1.go:313
      ../BreakGo/s2.go:317: NewPingResult redeclared in this block
      previous declaration at ../BreakGo/s1.go:317
      ../BreakGo/s2.go:317: too many errors

      =====

      Solution: Use the service name as a prefix for the *Args and *Result helper structs, to generate S1PingArgs, S2PingArgs, S1PingResult, etc.

        Attachments

          Activity

            People

            • Assignee:
              beberg Adam Beberg
              Reporter:
              beberg Adam Beberg
            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: