mirror of
https://github.com/wailsapp/wails.git
synced 2025-05-07 20:39:16 +08:00
28 lines
536 B
Go
28 lines
536 B
Go
package application
|
|
|
|
import (
|
|
"context"
|
|
"reflect"
|
|
)
|
|
|
|
type ServiceName interface {
|
|
ServiceName() string
|
|
}
|
|
|
|
type ServiceStartup interface {
|
|
ServiceStartup(ctx context.Context, options ServiceOptions) error
|
|
}
|
|
|
|
type ServiceShutdown interface {
|
|
ServiceShutdown() error
|
|
}
|
|
|
|
func getServiceName(service any) string {
|
|
// First check it conforms to ServiceName interface
|
|
if serviceName, ok := service.(ServiceName); ok {
|
|
return serviceName.ServiceName()
|
|
}
|
|
// Next, get the name from the type
|
|
return reflect.TypeOf(service).String()
|
|
}
|