-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
assert: guard CanConvert call in backward compatible wrapper
- Loading branch information
1 parent
c038d8c
commit 54276bb
Showing
3 changed files
with
23 additions
and
1 deletion.
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,11 @@ | ||
// +build go1.17 | ||
|
||
package assert | ||
|
||
import "reflect" | ||
|
||
// Wrapper around reflect.Value.CanConvert, for compatability | ||
// reasons. | ||
func canConvert(value reflect.Value, to reflect.Type) bool { | ||
return value.CanConvert(to) | ||
} |
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,11 @@ | ||
// +build !go1.17 | ||
|
||
package assert | ||
|
||
import "reflect" | ||
|
||
// Older versions of Go does not have the reflect.Value.CanConvert | ||
// method. | ||
func canConvert(value reflect.Value, to reflect.Type) bool { | ||
return false | ||
} |