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

Using filenames containing chars not valid within identifiers will create uncompileable code

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Minor
    • Resolution: Information Provided
    • 0.9.2
    • None
    • Go - Compiler
    • None
    • Mac OS X 10.10.5

    Description

      If the name of your Thrift package has a hyphen in it, invalid Go source code will be generated. Following the instructions here:

      If you rename the tutorial file to tutorial-test.thrift, the following error happens when you run thrift -r --gen go tutorial-test.thrift:

      ./gen-go//tutorial-stuff/calculator.go:4:17: expected ';', found '-'
      WARNING - Running 'gofmt -w ./gen-go//tutorial-stuff/calculator.go' failed.
      ./gen-go//tutorial-stuff/ttypes.go:4:17: expected ';', found '-'
      WARNING - Running 'gofmt -w ./gen-go//tutorial-stuff/ttypes.go' failed.
      ./gen-go//tutorial-stuff/constants.go:4:17: expected ';', found '-'
      WARNING - Running 'gofmt -w ./gen-go//tutorial-stuff/constants.go' failed.
      

      Looking at the source code, the issue looks to be because the package name has a hyphen in it:

      calculator.go
      // Autogenerated by Thrift Compiler (1.0.0-dev)
      // DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
      
      package tutorial-stuff
      
      import (
      	"bytes"
      	"fmt"
      	"git.apache.org/thrift.git/lib/go/thrift"
      	"shared"
      
      )
      

      This has been tested on Mac OS X 10.10.5 by installing v0.9.2 as well as v1.0.0-dev (HEAD) using homebrew. Both result in the same failure.

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              tim.heckman Tim Heckman
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: