I was working on a tool that needed to know the file system paths and
version information of some of its dependencies from go.mod for code
generation. I couldn't find any official way of obtaining these
(debug/gosym was close, but didn't work for the current binary on any
OS), so I wrote this package:

https://github.com/mxk/go-gomod

It's basically a hack that looks through all file name strings used
for stack traces in the current binary, identifies those containing
"@v", and extracts root directory and version information from there.

This got me thinking whether there should be a more general (and
unsafe-free) way of obtaining module information at run time. 'go
list' command defines a Module struct containing pretty much all
information one might want. Would it make sense to compile this
metadata into the binary (if not already done) and expose it via the
runtime package?

-Max

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to