-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #25 from Antonboom/fix-no-spec-for-type
Go 1.21 & Support `ast.IndexListExpr` receiver
- Loading branch information
Showing
10 changed files
with
89 additions
and
22 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,4 +4,4 @@ updates: | |
- package-ecosystem: gomod | ||
directory: "/" | ||
schedule: | ||
interval: "daily" | ||
interval: "monthly" |
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
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
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 |
---|---|---|
@@ -1,6 +1,6 @@ | ||
module github.com/Antonboom/errname | ||
|
||
go 1.20 | ||
go 1.21 | ||
|
||
require ( | ||
golang.org/x/sys v0.11.0 // indirect | ||
|
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
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,46 @@ | ||
package generics | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
"net/http" | ||
"reflect" | ||
) | ||
|
||
type ( | ||
Req any | ||
Resp any | ||
) | ||
|
||
type timeoutErr[REQ Req, RESP Resp] struct { // want "the type name `timeoutErr` should conform to the `xxxError` format" | ||
err error | ||
sending bool | ||
} | ||
|
||
func (e *timeoutErr[REQ, RESP]) Error() string { | ||
var req REQ | ||
var resp RESP | ||
|
||
direction := "sending" | ||
if !e.sending { | ||
direction = "receiving" | ||
} | ||
|
||
return fmt.Sprintf("deferred call %T->%T timeout %s: %s", | ||
reflect.TypeOf(req), reflect.TypeOf(resp), direction, e.err.Error()) | ||
} | ||
|
||
func (e *timeoutErr[REQ, RESP]) Unwrap() error { | ||
return e.err | ||
} | ||
|
||
type TimeoutError[REQ Req, RESP Resp] struct{} // | ||
func (TimeoutError[REQ, RESP]) Error() string { return "timeouted" } | ||
|
||
type ValErr[A, B, C, D, E, F any] struct{} // want "the type name `ValErr` should conform to the `XxxError` format" | ||
func (ValErr[A, B, C, D, E, F]) Error() string { return "boom!" } | ||
|
||
var ( | ||
ErrTimeout error = &timeoutErr[*http.Request, *http.Response]{err: context.DeadlineExceeded, sending: false} | ||
tErr error = &timeoutErr[string, string]{err: context.DeadlineExceeded, sending: true} // want "the variable name `tErr` should conform to the `errXxx` format" | ||
) |