package ui import ( "fmt" "os" ) type Options struct { Name string Version string OnClose func() } type GUIApp interface { Run(exitCh chan os.Signal) int Close() } func (o *Options) Validate() error { if len(o.Version) == 0 { return fmt.Errorf("version is required") } if o.OnClose == nil { return fmt.Errorf("missing onClose function") } return nil } type Option func(*Options) func Version(v string) Option { return func(o *Options) { o.Version = v } } func Name(n string) Option { return func(o *Options) { o.Name = n } } // OnClose 关闭窗口事件 func OnClose(f func()) Option { return func(o *Options) { o.OnClose = f } }