MCPcopy Create free account
hub / github.com/bracesdev/errtrace / toolExecRewrite

Method toolExecRewrite

cmd/errtrace/toolexec.go:142–160  ·  view source on GitHub ↗
(pkg string, p toolExecParams)

Source from the content-addressed store, hash-verified

140}
141
142func (cmd *mainCmd) toolExecRewrite(pkg string, p toolExecParams) (exitCode int) {
143 // We only need to modify the arguments for "compile" calls which work with .go files.
144 if !isCompile(p.Tool) {
145 return cmd.runOriginal(p)
146 }
147
148 // We only modify files that import errtrace, so stdlib is never eliglble.
149 if isStdLib(p.ToolArgs) {
150 return cmd.runOriginal(p)
151 }
152
153 exitCode, err := cmd.rewriteCompile(pkg, p)
154 if err != nil {
155 cmd.log.Print(err)
156 return 1
157 }
158
159 return exitCode
160}
161
162func (cmd *mainCmd) rewriteCompile(pkg string, p toolExecParams) (exitCode int, _ error) {
163 var canRewrite, needRewrite bool

Callers 1

handleToolExecMethod · 0.95

Calls 4

runOriginalMethod · 0.95
rewriteCompileMethod · 0.95
isCompileFunction · 0.85
isStdLibFunction · 0.85

Tested by

no test coverage detected