Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

package name conflict #99

Open
AndrewWPhillips opened this issue Feb 16, 2017 · 0 comments
Open

package name conflict #99

AndrewWPhillips opened this issue Feb 16, 2017 · 0 comments

Comments

@AndrewWPhillips
Copy link

AndrewWPhillips commented Feb 16, 2017

Go packages can't be nested but you can nest namespaces in Thrift. If you have two Thrift files with the same "leaf" namespace name then when both namespaces are used together the generated Go code won't compile. The error is redeclared as imported package name ...

Eg for this thrift:

  include "Person.Address.thrift"
  include "Computer.Address.thrift"

  struct Details
  {
	1 : optional Person.Address.Primary addr,
	2 : optional Computer.Address.Primary ip,
  }

the Go code looks something like this:

  import (
	"Person/Address"
	"Computer/Address"     // Address redeclared as imported package name
	"git.apache.org/thrift.git/lib/go/thrift"
  )
  .....
  type Details struct {
	Addr             *Address.Primary
	Ip               *Address.Primary
  }

This is not a big problem but could be avoided by importing the package under a non-conflicting name like this:

  import (
	PersonAddress   "Person/Address"
	ComputerAddress "Computer/Address"
	"git.apache.org/thrift.git/lib/go/thrift"
  )
  .....
  type Details struct {
	Addr             *PersonAddress.Primary
	Ip               *ComputerAddress.Primary
  }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant