-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
cmd/errtrace: Fix blank import handling (#92)
With toolexec mode, a blank import of errtrace is more likely to opt-in to rewriting. However, this blank import can't be used to call errtrace functions, so we need to track both: * Whether errtrace is imported (used to opt-in toolexec rewriting) * Whether errtrace needs to be imported for any Wrap calls. Since this change modifies the rewriting logic, we bump the errtrace toolexec version manually.
- Loading branch information
Showing
6 changed files
with
47 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
//go:build ignore | ||
|
||
package foo | ||
|
||
import ( | ||
"strconv" | ||
|
||
_ "braces.dev/errtrace" | ||
) | ||
|
||
func Unwrapped(s string) (int, error) { | ||
i, err := strconv.Atoi(s) | ||
if err != nil { | ||
return 0, err | ||
} | ||
return i + 42, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
//go:build ignore | ||
|
||
package foo | ||
|
||
import ( | ||
"strconv" | ||
|
||
_ "braces.dev/errtrace"; "braces.dev/errtrace" | ||
) | ||
|
||
func Unwrapped(s string) (int, error) { | ||
i, err := strconv.Atoi(s) | ||
if err != nil { | ||
return 0, errtrace.Wrap(err) | ||
} | ||
return i + 42, nil | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters