MCPcopy Create free account
hub / github.com/goadesign/goa / dslFuncLocation

Function dslFuncLocation

eval/error.go:150–161  ·  view source on GitHub ↗

dslFuncLocation returns the file and line where the given DSL function is declared. The returned file is relative to the current working directory when possible.

(fn func())

Source from the content-addressed store, hash-verified

148//
149// The returned file is relative to the current working directory when possible.
150func dslFuncLocation(fn func()) (file string, line int, ok bool) {
151 pc := reflect.ValueOf(fn).Pointer()
152 f := runtime.FuncForPC(pc)
153 if f == nil {
154 return "", 0, false
155 }
156 file, line = f.FileLine(pc)
157 if file == "" || line == 0 {
158 return "", 0, false
159 }
160 return relativeToWorkdir(file), line, true
161}
162
163// relativeToWorkdir returns file relative to the current working directory when
164// possible, otherwise it returns file unchanged.

Callers 1

validationErrorLocationFunction · 0.85

Calls 1

relativeToWorkdirFunction · 0.70

Tested by

no test coverage detected