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

internal/filetypes: avoid using CUE at runtime #3280

Open
rogpeppe opened this issue Jul 12, 2024 · 0 comments
Open

internal/filetypes: avoid using CUE at runtime #3280

rogpeppe opened this issue Jul 12, 2024 · 0 comments

Comments

@rogpeppe
Copy link
Member

The internal/filetypes package currently uses CUE itself to decide what attributes should apply
for any given file extension and user-supplied filetype hints. This is a lovely and expressive
way of implementing the logic, but comes with certain down sides:

  1. it's somewhat slow: the generality of CUE means that the logic is never going to be as fast as hard-coded rules
  2. it can easily lead to cyclic import dependencies. It means that some parts of the internals of CUE cannot depend on internal/filetypes because that in turn depends on the entire CUE standard library which has many dependencies. This should really be a low-dependency leaf package.

Point 1 might be addressable with performance improvements, but point 2 is a significant wart.

There are at least two possible ways to work around this:

  • rewrite the logic in Go
  • use a preprocessor to evaluate the CUE and generate Go code or data structures that encapsulate the logic
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant