typora-installer/common/reactive_os.go

20 lines
379 B
Go
Raw Permalink Normal View History

2021-12-07 02:35:05 +00:00
package common
import (
"context"
"errors"
"runtime"
)
type ReactiveHandlerOnOS struct {
HandleFunc map[string]func(ctx context.Context) (context.Context, error)
}
func (h *ReactiveHandlerOnOS) Handle(ctx context.Context) (context.Context, error) {
handle, ok := h.HandleFunc[runtime.GOOS]
if !ok {
return nil, errors.New("unsupported error")
}
return handle(ctx)
}