200sc / bebop

bebop wire format in Go
Apache License 2.0
71 stars 5 forks source link

Add Import Support #13

Closed 200sc closed 3 years ago

200sc commented 3 years ago

This adds import support in two operating modes-

  1. By default, generate each .bop file to a single .go file, with a const go_package hint for where those files should be found
  2. Optionally, instead generate a single file containing all definitions in the entire import tree. This is what https://github.com/RainwayApp/bebop does, and may be necessary if working with a file you can't change to add a package hint.

We offer (1) instead because (2) is infeasible for a complex system. If you had a large app built on bebop structures you would either need a single place that stored every definition used in the app, which would eventually fail as file sizes increased and would have a bad developer experience, or you'd need to have partial definitions throughout the codebase, which would get confusing and an additional import added somewhere could cause a cascading file size bloat.

In addition,

I'm not 100% confident this implementation works in all cases as is, but have decided to push it forward and resolve bugs as they arise instead of attempting to generate further test cases right now.