nix-amer/internal/ser/loader.go

29 lines
540 B
Go
Raw Normal View History

package ser
import (
"errors"
)
var ErrUnknownManager = errors.New("unknown service manager")
var ErrNotInstalled = errors.New("not candidate installed")
func Load(_manager string) (ServiceManager, error) {
// 1. create manager (fail if unknown)
var manager ServiceManager
switch _manager {
case "systemd":
manager = new(Systemd)
default:
return nil, ErrUnknownManager
}
// 2. fail if not installed
// if exec.Command("which", manager.Name()).Run() != nil {
// return nil, ErrNotInstalled
// }
return manager, nil
}