MCPcopy
hub / github.com/google/go-jsonnet / Importer

Interface Importer

imports.go:31–58  ·  view source on GitHub ↗

An Importer imports data from a path. TODO(sbarzowski) caching of errors (may require breaking changes)

Source from the content-addressed store, hash-verified

29// An Importer imports data from a path.
30// TODO(sbarzowski) caching of errors (may require breaking changes)
31type Importer interface {
32 // Import fetches data from a given path. It may be relative
33 // to the file where we do the import. What "relative path"
34 // means depends on the importer.
35 //
36 // It is required that:
37 // a) for given (importedFrom, importedPath) the same
38 // (contents, foundAt) are returned on subsequent calls.
39 // b) for given foundAt, the contents are always the same
40 //
41 // It is recommended that if there are multiple locations that
42 // need to be probed (e.g. relative + multiple library paths)
43 // then all results of all attempts will be cached separately,
44 // both nonexistence and contents of existing ones.
45 // FileImporter may serve as an example.
46 //
47 // IMPORTANT: The passed importedFrom might be "" (an empty string).
48 // It means that the import is coming from an ad-hoc snippet, e.g.
49 // code passed on the command line, read from stdin or passed as
50 // a snippet to execute. Importer may have a "default" path to use
51 // in such case or it may only allow absolute imports from such
52 // "anonymous locations".
53 //
54 // Importing the same file multiple times must be a cheap operation
55 // and shouldn't involve copying the whole file - the same buffer
56 // should be returned.
57 Import(importedFrom, importedPath string) (contents Contents, foundAt string, err error)
58}
59
60// Contents is a representation of imported data. It is a simple
61// byte wrapper, which makes it easier to enforce the caching policy.

Callers 2

ImportMethod · 0.65
importDataMethod · 0.65

Implementers 6

importerWithHistoryjsonnet_test.go
FileImporterimports.go
MemoryImporterimports.go
Baseinternal/pass/pass.go
JavascriptImportercmd/wasm/main.go
importerc-bindings/c-bindings.go

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…