Skip to content

Commit 0c4f236

Browse files
committed
refact(string): rewritten hack prioritized logical expressions with clearer sequence
Signed-off-by: Frederic BIDON <fredbi@yahoo.com>
1 parent bb6b75b commit 0c4f236

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

‎internal/assertions/string.go‎

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -223,8 +223,14 @@ func asString(v any) (string, bool) {
223223

224224
// weird reflection: numbers CanConvert but their string rep is wrong. Need to check further.
225225
typ := val.Type()
226-
if kind != reflect.String && !(kind == reflect.Slice && typ.Elem().Kind() == reflect.Uint8) { //nolint:staticcheck // we want type.Elem() to be called only when kind is a slice
227-
return "", false
226+
if kind != reflect.String {
227+
if kind != reflect.Slice {
228+
return "", false
229+
}
230+
231+
if typ.Elem().Kind() != reflect.Uint8 {
232+
return "", false
233+
}
228234
}
229235

230236
// handle ~string, ~[]byte

0 commit comments

Comments
 (0)
⌂ 换网址