github
109 of 214 new or added lines in 9 files covered. (50.93%)
109 of 268 relevant lines covered (40.67%)
3.16 hits per line
1 |
package internal
|
|
2 |
|
|
3 |
import (
|
|
4 |
"fmt"
|
|
5 |
) |
|
6 |
|
|
7 |
// Cast casts a value into another type.
|
|
NEW
|
func Cast[T any](from any) (T, error) { |
× |
NEW
|
into, ok := (from).(T) |
× |
NEW
|
|
× |
NEW
|
if !ok {
|
× |
NEW
|
return *new(T), fmt.Errorf("unable to cast %s into %T ", from, *new(T)) |
× |
NEW
|
} |
× |
14 |
|
|
NEW
|
return into, nil |
× |
16 |
} |