Closed shuheiktgw closed 9 months ago
You should regenerate test files. I think there will be the unexpected differences. (I'm not sure why CI didn't warn it)
@kazegusuri I've updated the PR to import packages on demand, which means packages are imported if they are actually used in the file. I'll leave some follow-up comments below. Would you review the PR again? 🙏
I'm closing this issue for now since we must reconsider the interface.
Currently, golang.org/x/tools/imports manages to import proper go packages in generated files, and it works in most cases. However, it has certain limitations. For example, if users specify
civil.Date
golang.org/x/tools/imports cannot tell if they try to usecloud.google.com/go/civil
orgithub.com/golang-sql/civil
for sure.Instead of leaving it to golang.org/x/tools/imports, this PR implements a package registry that imports an appropriate package based on fields of Spanner tables. I'll implement the following features once this PR gets merged.