| 1 | # Source Maps consumer for Golang [](https://travis-ci.org/go-sourcemap/sourcemap) |
| 2 | |
| 3 | ## Installation |
| 4 | |
| 5 | Install: |
| 6 | |
| 7 | go get gopkg.in/sourcemap.v1 |
| 8 | |
| 9 | ## Quickstart |
| 10 | |
| 11 | ```go |
| 12 | func ExampleParse() { |
| 13 | mapURL := "http://code.jquery.com/jquery-2.0.3.min.map" |
| 14 | resp, err := http.Get(mapURL) |
| 15 | if err != nil { |
| 16 | panic(err) |
| 17 | } |
| 18 | defer resp.Body.Close() |
| 19 | |
| 20 | b, err := ioutil.ReadAll(resp.Body) |
| 21 | if err != nil { |
| 22 | panic(err) |
| 23 | } |
| 24 | |
| 25 | smap, err := sourcemap.Parse(mapURL, b) |
| 26 | if err != nil { |
| 27 | panic(err) |
| 28 | } |
| 29 | |
| 30 | line, column := 5, 6789 |
| 31 | file, fn, line, col, ok := smap.Source(line, column) |
| 32 | fmt.Println(file, fn, line, col, ok) |
| 33 | // Output: http://code.jquery.com/jquery-2.0.3.js apply 4360 27 true |
| 34 | } |
| 35 | ``` |