init project
This commit is contained in:
commit
d63cc8d9f5
33 files changed
+1529
No files matched your search
@@ -0,0 +1,36 @@
|
||||
package runtime
|
||||
|
||||
import (
|
||||
"context"
|
||||
)
|
||||
|
||||
type Option func(o *Options)
|
||||
|
||||
type Options struct {
|
||||
ID string
|
||||
Type string
|
||||
|
||||
// 自定义参数
|
||||
Context context.Context
|
||||
}
|
||||
|
||||
func WithID(id string) Option {
|
||||
return func(o *Options) {
|
||||
o.ID = id
|
||||
}
|
||||
}
|
||||
|
||||
func WithType(t string) Option {
|
||||
return func(o *Options) {
|
||||
o.Type = t
|
||||
}
|
||||
}
|
||||
|
||||
func SetRuntimeOption(k, v interface{}) Option {
|
||||
return func(o *Options) {
|
||||
if o.Context == nil {
|
||||
o.Context = context.Background()
|
||||
}
|
||||
o.Context = context.WithValue(o.Context, k, v)
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user