I was browsing github looking for odin libraries and I noticed a lot of them had a pkg.mod file.
Where? I have never seen this before and I created Odin
To be clear, I dont mean official libraries. Heres one GitHub - Up05/toml_parser: TOML Parser for odin-lang. I also wrote the file name from memory when making the topic, its actually mod.pkg.
This is literally the first time I’ve seen someone do this, and I still do not know what it is used by anything. I think someone is just using it as a form of metadata storing for a possible “package manager” in the future, but it’s not really doing anything.
This has nothing to do with the language itself, and if I was designing such a thing, it wouldn’t be JSON either.
The weird part is that im seeing it in way more repos than I would expect if it does literally nothing.
Reddit user LaytanL has the answer. Its used to store metadata so third party libraries can be listed on https://pkg-odin.org
I noticed too in some repos, but I didn’t found much information about it.
I personally used a file called project.ini
which is a lot simpler (just an Ini file) and contains common configuration for the project, normally a name and a version number to be integrated by a CI pipeline for releases (although it can have many more info if you need).
Example
Thats the way I like to structure projects so I can just use this in my project.odin
main file.
read_project_settings :: proc() -> ini.Map {
// Setup project.ini for entire project
config_file_path := filepath.clean("project.ini")
values, err, ok := ini.load_map_from_path(config_file_path, context.allocator)
if !ok {
fmt.panicf("Error opening project config file (%s): %s", config_file_path, err)
}
return values
}