gofmt autofix paths

Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
Jeff Carr 2024-01-18 00:57:43 -06:00
parent 47a665be8b
commit ff3a51f354
9 changed files with 121 additions and 101 deletions

View File

@ -8,7 +8,9 @@ import (
// reports externally if something has changed // reports externally if something has changed
// since the last time it was asked about it // since the last time it was asked about it
func (rs *RepoStatus) Changed() bool { func (rs *RepoStatus) Changed() bool {
if ! rs.Ready() {return false} if !rs.Ready() {
return false
}
if rs.changed { if rs.changed {
rs.changed = false rs.changed = false
return true return true
@ -17,7 +19,9 @@ func (rs *RepoStatus) Changed() bool {
} }
func (rs *RepoStatus) Draw() { func (rs *RepoStatus) Draw() {
if ! rs.Ready() {return} if !rs.Ready() {
return
}
log.Log(CHANGE, "Draw() window ready =", rs.ready) log.Log(CHANGE, "Draw() window ready =", rs.ready)
rs.window.TestDraw() rs.window.TestDraw()
// rs.window.Draw() // rs.window.Draw()
@ -25,21 +29,27 @@ func (rs *RepoStatus) Draw() {
} }
func (rs *RepoStatus) Show() { func (rs *RepoStatus) Show() {
if ! rs.Ready() {return} if !rs.Ready() {
return
}
log.Log(CHANGE, "Show() window ready =", rs.ready) log.Log(CHANGE, "Show() window ready =", rs.ready)
rs.window.Show() rs.window.Show()
rs.hidden = false rs.hidden = false
} }
func (rs *RepoStatus) Hide() { func (rs *RepoStatus) Hide() {
if ! rs.Ready() {return} if !rs.Ready() {
return
}
log.Log(CHANGE, "Hide() window ready =", rs.ready) log.Log(CHANGE, "Hide() window ready =", rs.ready)
rs.window.Hide() rs.window.Hide()
rs.hidden = true rs.hidden = true
} }
func (rs *RepoStatus) Toggle() { func (rs *RepoStatus) Toggle() {
if ! rs.Ready() {return} if !rs.Ready() {
return
}
log.Log(CHANGE, "Toggle() window ready =", rs.ready) log.Log(CHANGE, "Toggle() window ready =", rs.ready)
if rs.hidden { if rs.hidden {
rs.Show() rs.Show()
@ -50,8 +60,12 @@ func (rs *RepoStatus) Toggle() {
func (rs *RepoStatus) Ready() bool { func (rs *RepoStatus) Ready() bool {
log.Log(SPEW, "Ready() maybe not ready? rs =", rs) log.Log(SPEW, "Ready() maybe not ready? rs =", rs)
if rs == nil {return false} if rs == nil {
if rs.window == nil {return false} return false
}
if rs.window == nil {
return false
}
return rs.ready return rs.ready
} }

10
draw.go
View File

@ -4,16 +4,18 @@ import (
"strconv" "strconv"
"strings" "strings"
"go.wit.com/log"
"go.wit.com/gui/gui" "go.wit.com/gui/gui"
"go.wit.com/gui/widget" "go.wit.com/lib/gadgets"
"go.wit.com/gui/gadgets" "go.wit.com/lib/widget"
"go.wit.com/log"
) )
// creates the actual widgets. // creates the actual widgets.
// it's assumed you are always passing in a box // it's assumed you are always passing in a box
func (rs *RepoStatus) draw() { func (rs *RepoStatus) draw() {
if ! rs.Ready() {return} if !rs.Ready() {
return
}
// display the status of the git repository // display the status of the git repository
rs.drawGitStatus() rs.drawGitStatus()

2
git.go
View File

@ -4,8 +4,8 @@ import (
"strings" "strings"
"unicode/utf8" "unicode/utf8"
"io/ioutil"
"go.wit.com/log" "go.wit.com/log"
"io/ioutil"
) )
func (rs *RepoStatus) GetPath() string { func (rs *RepoStatus) GetPath() string {

4
new.go
View File

@ -1,9 +1,9 @@
package repostatus package repostatus
import ( import (
"go.wit.com/log"
"go.wit.com/gui/gui" "go.wit.com/gui/gui"
"go.wit.com/gui/gadgets" "go.wit.com/lib/gadgets"
"go.wit.com/log"
) )
func New(p *gui.Node, path string) *RepoStatus { func New(p *gui.Node, path string) *RepoStatus {

View File

@ -2,7 +2,7 @@ package repostatus
import ( import (
"go.wit.com/gui/gui" "go.wit.com/gui/gui"
"go.wit.com/gui/gadgets" "go.wit.com/lib/gadgets"
) )
type RepoStatus struct { type RepoStatus struct {

View File

@ -12,6 +12,8 @@ func timeFunction(f func()) time.Duration {
} }
func (ls *RepoStatus) SetSpeedActual(s string) { func (ls *RepoStatus) SetSpeedActual(s string) {
if ! ls.Ready() {return} if !ls.Ready() {
return
}
ls.speedActual.SetText(s) ls.speedActual.SetText(s)
} }

10
unix.go
View File

@ -2,13 +2,13 @@
package repostatus package repostatus
import ( import (
"errors"
"os" "os"
"os/exec" "os/exec"
"os/user" "os/user"
"strings"
"regexp"
"errors"
"path/filepath" "path/filepath"
"regexp"
"strings"
"go.wit.com/log" "go.wit.com/log"
) )
@ -91,7 +91,9 @@ func alphaOnly(s string) bool {
func normalizeVersion(s string) string { func normalizeVersion(s string) string {
// reg, err := regexp.Compile("[^a-zA-Z0-9]+") // reg, err := regexp.Compile("[^a-zA-Z0-9]+")
parts := strings.Split(s, "-") parts := strings.Split(s, "-")
if len(parts) == 0 { return "" } if len(parts) == 0 {
return ""
}
reg, err := regexp.Compile("[^0-9.]+") reg, err := regexp.Compile("[^0-9.]+")
if err != nil { if err != nil {
log.Log(WARN, "normalizeVersion() regexp.Compile() ERROR =", err) log.Log(WARN, "normalizeVersion() regexp.Compile() ERROR =", err)

View File

@ -1,9 +1,9 @@
package repostatus package repostatus
import ( import (
"errors"
"fmt" "fmt"
"time" "time"
"errors"
"go.wit.com/log" "go.wit.com/log"
) )
@ -67,9 +67,9 @@ func (rs *RepoStatus) setSpeed(duration time.Duration) {
} }
rs.speedActual.SetText(s) rs.speedActual.SetText(s)
if (duration > 500 * time.Millisecond ) { if duration > 500*time.Millisecond {
rs.speed.SetText("SLOW") rs.speed.SetText("SLOW")
} else if (duration > 100 * time.Millisecond ) { } else if duration > 100*time.Millisecond {
rs.speed.SetText("OK") rs.speed.SetText("OK")
} else { } else {
rs.speed.SetText("FAST") rs.speed.SetText("FAST")