I haven't tried it yet but I was planning on using this library to do most of the heavy lifting:
https://pypi.org/project/treeshake/
It looks like it's calling C code via Cython so if it works, you could probably use the same underlying C code via CGo for your project.