schema/gen/go: cache genned code in os.TempDir
This means we no longer clutter the repository with lots of files, even if they are git-ignored. It's always a bit of a red flag when you run "go test ./..." and the result is a bunch of leftover files. We still want to keep the files around, for the sake of Go's build cache. And we still want their paths to be static between "go test" runs. So put them in a static dir under os.TempDir. This does mean that concurrent runs of these tests will likely not work well. I don't imagine that's going to be a problem anytime soon, though. If it really becomes a problem in the future, we could figure something out like grabbing a file lock for the directory. The idea behind using os.TempDir is that it will likely remain in place between a number of "go test" runs within a hacking session, but it will be eventually cleaned up by the system, such as when rebooting. Note that we need to use globbing since one can't build "proper packages" located outside a module. The only exception is building an ad-hoc set of explicit Go files. While at it, use filepath.Join, to be nice.
Showing
Please register or sign in to comment