Browse Source

优化ioswitch

gitlink
Sydonian 1 year ago
parent
commit
21d826edf9
1 changed files with 5 additions and 1 deletions
  1. +5
    -1
      pkgs/ioswitch/exec/context.go

+ 5
- 1
pkgs/ioswitch/exec/context.go View File

@@ -35,7 +35,7 @@ func (c *ExecContext) SetValue(key any, value any) {
c.Values[key] = value
}

func ValueByType[T any](ctx *ExecContext) (T, error) {
func GetValueByType[T any](ctx *ExecContext) (T, error) {
var ret T

value, err := ctx.Value(reflect2.TypeOf[T]())
@@ -50,3 +50,7 @@ func ValueByType[T any](ctx *ExecContext) (T, error) {

return ret, nil
}

func SetValueByType[T any](ctx *ExecContext, value T) {
ctx.SetValue(reflect2.TypeOf[T](), value)
}

Loading…
Cancel
Save