Help us shape the future of Go! Take the 2026 Go Developer Survey

sourcemap

package
v0.1.69 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 1, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package sourcemap reads version 3 source maps, as bundlers write them beside a script, to find where a place in the bundle came from.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Map

type Map struct {
	// contains filtered or unexported fields
}

Map is a decoded source map.

func Parse

func Parse(data []byte) (*Map, error)

Parse decodes a source map. It skips a segment that names no source, and rejects a map whose mappings are not well formed.

func (*Map) Locate

func (m *Map) Locate(line, column int) (Position, bool)

Locate returns where the generated line and column, from 1, came from: the last segment at or before the column. A column of 0 takes the line's first segment. It returns false for a line with no segment there.

type Position

type Position struct {
	// Source is the file as the map names it, relative to the map's
	// directory unless the map named it absolute.
	Source       string
	Line, Column int
}

Position is a place in a source file, line and column from 1.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL