I don’t seem to understand how the -on_load directive works. In the module I wrote, I have a function to initialize the ets table and populate it with some data. This function works correctly when you call it explicitly. However: I thought it would be nice if the ets table was populated “automatically” when the module was loaded. But this does not work, because ets:info(filesig) tells me "undefined" after loading the module. The corresponding code looks something like this:
... -on_load(init/0), init() -> % load filesig database into ETS {_, Signatures} = file:consult("path to a file"), ets:new(filesig, [set, protected, named_table]), ets:insert(filesig, Signatures), ok. ...
I tested it from erlang shell. Any hints on me, what am I doing wrong?
source share