Init() is a better function name here

This commit is contained in:
Jeff Carr 2024-02-25 18:39:27 -06:00
parent 4641eceda8
commit 40e811b3b3
2 changed files with 5 additions and 5 deletions

6
new.go
View File

@ -2,13 +2,12 @@
package linuxstatus package linuxstatus
import ( import (
"go.wit.com/gui"
"go.wit.com/log" "go.wit.com/log"
"go.wit.com/lib/gadgets" "go.wit.com/lib/gadgets"
) )
func NewLinuxStatus(parent *gui.Node) *LinuxStatus { func InitLinuxStatus() *LinuxStatus {
if me != nil { if me != nil {
log.Log(WARN, "You have done New() twice. You can only do this once") log.Log(WARN, "You have done New() twice. You can only do this once")
return me return me
@ -21,10 +20,9 @@ func NewLinuxStatus(parent *gui.Node) *LinuxStatus {
me.ipmap = make(map[string]*IPtype) me.ipmap = make(map[string]*IPtype)
log.Log(WARN, "Creating the Window") log.Log(WARN, "Creating the Window")
me.window = gadgets.NewBasicWindow(parent, "OS Hostname Details") me.window = gadgets.RawBasicWindow("OS Hostname Details")
me.window.Make() me.window.Make()
draw(me) draw(me)
me.window.Draw()
me.ready = true me.ready = true
return me return me

View File

@ -9,7 +9,9 @@ import (
) )
func (ls *LinuxStatus) Update() { func (ls *LinuxStatus) Update() {
if ls == nil { return } if ls == nil {
return
}
if !ls.Ready() { if !ls.Ready() {
log.Log(WARN, "can't update yet. ready is false") log.Log(WARN, "can't update yet. ready is false")
log.Error(errors.New("Update() is not ready yet")) log.Error(errors.New("Update() is not ready yet"))