typora-installer/common/reactive_os.go

20 lines
379 B
Go

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)
}