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

Go generated code produces name collisions between services

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 0.9.2
    • 0.9.3
    • Go - Compiler
    • None
    • 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

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

            Dates

              Created:
              Updated:
              Resolved: