Hey,
I have this working C code, giving me a recursive hash for some specific directory
#include "store-api.hh"
#include "legacy.hh"
#include "posix-source-accessor.hh"
using namespace nix;
static int main_nix_prefetch_url(int argc, char * * argv)
{
{
auto store = openStore();
auto ingestionMethod = FileIngestionMethod::Recursive;
HashAlgorithm hashAlgo = HashAlgorithm::SHA256;
std::optional<std::string> name = "bookmarks";
std::optional<Hash> hash;
Path unpacked = (Path) "/home/onny/projects/nix/bookmarks";
PosixSourceAccessor accessor;
auto info = store->addToStoreSlow(
*name,
accessor, CanonPath::fromCwd(unpacked),
ingestionMethod, hashAlgo, {});
assert(info.ca);
hash = info.ca->hash;
logger->cout(printHash16or32(hash.value()));
return 0;
}
}
static RegisterLegacyCommand r_nix_prefetch_url("nix-prefetch-url", main_nix_prefetch_url);
Returns
06pprhlaaqdha2nmfdcf76mhh48hdr5jlv88snxji8lpflv50wr5
Is there some equivalent I could use in Go?
Best regards
Jonas