Integrating External Programs with Our Code
We’ve been through the steps needed to publish your work on
GitHub. Now we’ll look at how to include other people’s work in
our projects. As an example, we’ll integrate the code from bitcask
into our bertie project.
We’ll change bertie so that when it starts, it prints the number of times it has been started. So, for example, when it starts the tenth time, bertie will announce the following:
| | Bertie has been run 10 times |
To achieve this, we’ll store the number of times bertie has been run in a
bitcask database. In bitcask, keys and values must be
binaries. We’ll choose the key to be the binary
<<"n">> and the value to be
term_to_binary(N), where N is the number of
times bertie has been run. bertie.erl ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access