Search code examples
crystal-lang

How to access module version in Crystal Lang?


I see that a frequent convention is to add a file often named version.cr or named after the module it is attached to. Inside of that file, there is a definition of the module with VERSION = "[semver]". How can I access that version?


Solution

  • Using the namespace operator ::, this can be achieved with Module::VERSION where Module is the name of the module you're trying to access it from.