Debian Codegraph @

example_test.go

raw symbols ◀ ▶ SCIP
1 Debian patch touch this file
1 package sourcemap_test
2
3 import (
4 "fmt"
5 "io/ioutil"
6 "net/http"
7
8 "gopkg.in/sourcemap.v1"
9 )
10
11 func ExampleParse() {
•12 mapURL := "file:///usr/share/javascript/jquery/jquery.min.map"
13
14 trans := &http.Transport{}
15 trans.RegisterProtocol("file", http.NewFileTransport(http.Dir("/")))
16
17 cli := &http.Client{Transport: trans}
18 resp, err := cli.Get(mapURL)
19 if err != nil {
20 panic(err)
21 }
22 defer resp.Body.Close()
23
24 b, err := ioutil.ReadAll(resp.Body)
25 if err != nil {
26 panic(err)
27 }
28
29 smap, err := sourcemap.Parse(mapURL, b)
30 if err != nil {
31 panic(err)
32 }
33
34 line, column := 5, 6789
35 file, fn, line, col, ok := smap.Source(line, column)
36 fmt.Println(file, fn, line, col, ok)
37 }