be able to reconstruct the original file from sourcemap. something like the following:
smap, err := sourcemap.Parse(mapURL, b)
if err != nil {
panic(err)
}
originalFile, err := smap.Reconstruct()
or, for the purpose of not loading a whole un-minified file into memory, we can pass in an int denoting number of lines you want reconstructed when you call Source(). Then, return a slice containing n strings which each represent a like. maybe something like this:
smap, err := sourcemap.Parse(mapURL, b)
if err != nil {
panic(err)
}
line, column, peekCount := 5, 6789, 10
var originalLines []string
file, fn, line, col, originalLines, ok := smap.Source(line, column, peekCount)
originalLines would then have 5 lines above the mapped line, the mapped line, and 4 lines below, like so:
{
"package main",
"",
"import \"fmt\"",
"",
"func main() {",
"\tfor i := 0; i < 5; i++ {", // Mapped line
"\t\tfmt.Println(\"howdy\")",
"\t}",
"}",
"",
}
be able to reconstruct the original file from sourcemap. something like the following:
or, for the purpose of not loading a whole un-minified file into memory, we can pass in an int denoting number of lines you want reconstructed when you call
Source()
. Then, return a slice containing n strings which each represent a like. maybe something like this:originalLines would then have 5 lines above the mapped line, the mapped line, and 4 lines below, like so: