Skip to content

Commit

Permalink
Fix context.Get panic issue (#7)
Browse files Browse the repository at this point in the history
- Added a new treatment to correctly handle and return the default zero values when the desired key values are not found.
  • Loading branch information
JhonatanRSantos committed Sep 1, 2023
1 parent 1bc5fe3 commit bc70960
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion pkg/gocontext/gocontext.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ func Get[T constraints.Integer | constraints.Float | ~string | ~bool](ctx contex
return any(ctxValue).(T), true
}
}
return any("").(T), false
var result T
return result, false
}

// GetKeys Get all context keys
Expand Down

0 comments on commit bc70960

Please sign in to comment.