Run go fmt.

This commit is contained in:
Greg 2019-09-06 10:46:23 -04:00
parent e108a9b7a7
commit e40e98aa25
2 changed files with 54 additions and 55 deletions

View File

@ -19,18 +19,18 @@ var (
func setFont() error { func setFont() error {
f, err := os.Open("/System/Library/Fonts/AppleSDGothicNeo.ttc") f, err := os.Open("/System/Library/Fonts/AppleSDGothicNeo.ttc")
if err != nil { if err != nil {
log(Info,"Cannot open system font.") log(Info, "Cannot open system font.")
return err return err
} }
collection, err := sfnt.ParseCollectionReaderAt(f) collection, err := sfnt.ParseCollectionReaderAt(f)
if err != nil { if err != nil {
log(Info,"Cannot parse system font.") log(Info, "Cannot parse system font.")
return err return err
} }
regular, err = collection.Font(0) regular, err = collection.Font(0)
if err != nil { if err != nil {
log(Info,"Cannot access first font in collection.") log(Info, "Cannot access first font in collection.")
return err return err
} }
return nil return nil
@ -41,7 +41,7 @@ func init() {
if err != nil { if err != nil {
regular, err = sfnt.Parse(goregular.TTF) regular, err = sfnt.Parse(goregular.TTF)
if err != nil { if err != nil {
log(Fatal,"Cannot parse default font: ", err) log(Fatal, "Cannot parse default font: ", err)
} }
} }
usr, err := user.Current() usr, err := user.Current()
@ -52,7 +52,7 @@ func init() {
if _, err := os.Stat(confDir); os.IsNotExist(err) { if _, err := os.Stat(confDir); os.IsNotExist(err) {
err = os.MkdirAll(confDir, 0700) err = os.MkdirAll(confDir, 0700)
if err != nil { if err != nil {
log(Info, "Cannot create configuration directory ",confDir) log(Info, "Cannot create configuration directory ", confDir)
log(Fatal, err) log(Fatal, err)
} else { } else {
log(Info, "Configuration directory created") log(Info, "Configuration directory created")

View File

@ -39,7 +39,7 @@ func main() {
confFile := path.Join(confDir, "config.yml") confFile := path.Join(confDir, "config.yml")
if _, err := os.Stat(confFile); os.IsNotExist(err) { if _, err := os.Stat(confFile); os.IsNotExist(err) {
fd, err = os.Create(confFile) fd, err = os.Create(confFile)
if err != nil { if err != nil {
log(Fatal, "Cannot create configuration file: ", err) log(Fatal, "Cannot create configuration file: ", err)
} }
} }
@ -52,7 +52,7 @@ func main() {
log(Fatal, "Cannot parse configuration file: ", err) log(Fatal, "Cannot parse configuration file: ", err)
} }
store.Dir = Config.StoreDir store.Dir = Config.StoreDir
log(Info," StoreDir = ", store.Dir) log(Info, " StoreDir = ", store.Dir)
err = passgo.GetStore(&store) err = passgo.GetStore(&store)
if err != nil { if err != nil {
log(Fatal, err) log(Fatal, err)
@ -74,16 +74,16 @@ func main() {
} }
var ( var (
Config conf Config conf
l []passgo.Pass l []passgo.Pass
mux sync.Mutex mux sync.Mutex
store passgo.Store store passgo.Store
reload chan struct{} reload chan struct{}
updated chan struct{} updated chan struct{}
black = color.RGBA{A: 0xff, R:0, G:0, B:0} black = color.RGBA{A: 0xff, R: 0, G: 0, B: 0}
white = color.RGBA{A: 0xff, R:0xff, G:0xff, B:0xff} white = color.RGBA{A: 0xff, R: 0xff, G: 0xff, B: 0xff}
gray = color.RGBA{A: 0xff, R:0xf0, G:0xf0, B:0xf0} gray = color.RGBA{A: 0xff, R: 0xf0, G: 0xf0, B: 0xf0}
darkgray = color.RGBA{A: 0xff, R:0xa0, G:0xa0, B:0xa0} darkgray = color.RGBA{A: 0xff, R: 0xa0, G: 0xa0, B: 0xa0}
) )
func Updater() { func Updater() {
@ -139,12 +139,12 @@ func saveConf(fds ...*os.File) {
} }
type Overlay struct { type Overlay struct {
Face text.Face Face text.Face
Text string Text string
Click gesture.Click Click gesture.Click
Color color.RGBA Color color.RGBA
Background color.RGBA Background color.RGBA
Alignment text.Alignment Alignment text.Alignment
} }
func (b *Overlay) Layout(c ui.Config, ops *ui.Ops, cs layout.Constraints) layout.Dimensions { func (b *Overlay) Layout(c ui.Config, ops *ui.Ops, cs layout.Constraints) layout.Dimensions {
@ -156,8 +156,8 @@ func (b *Overlay) Layout(c ui.Config, ops *ui.Ops, cs layout.Constraints) layout
{ {
cs = st.Rigid() cs = st.Rigid()
l := text.Label{ l := text.Label{
Face: b.Face, Face: b.Face,
Text: b.Text, Text: b.Text,
Alignment: b.Alignment, Alignment: b.Alignment,
} }
ins := layout.UniformInset(ui.Dp(4)) ins := layout.UniformInset(ui.Dp(4))
@ -174,13 +174,13 @@ func (b *Overlay) Layout(c ui.Config, ops *ui.Ops, cs layout.Constraints) layout
} }
type Button struct { type Button struct {
Face text.Face Face text.Face
Label string Label string
Click gesture.Click Click gesture.Click
Color color.RGBA Color color.RGBA
Background color.RGBA Background color.RGBA
Alignment text.Alignment Alignment text.Alignment
clicked bool clicked bool
} }
func layoutRRect(col color.RGBA, c ui.Config, ops *ui.Ops, cs layout.Constraints) layout.Dimensions { func layoutRRect(col color.RGBA, c ui.Config, ops *ui.Ops, cs layout.Constraints) layout.Dimensions {
@ -225,8 +225,8 @@ func (b *Button) Layout(c ui.Config, q input.Queue, ops *ui.Ops, cs layout.Const
{ {
cs = st.Rigid() cs = st.Rigid()
l := text.Label{ l := text.Label{
Face: b.Face, Face: b.Face,
Text: b.Label, Text: b.Label,
Alignment: b.Alignment, Alignment: b.Alignment,
} }
ins := layout.UniformInset(ui.Dp(4)) ins := layout.UniformInset(ui.Dp(4))
@ -257,15 +257,14 @@ func eventLoop() {
var c1 layout.FlexChild // flex child for title bar var c1 layout.FlexChild // flex child for title bar
face := faces.For(regular, ui.Sp(16)) face := faces.For(regular, ui.Sp(16))
margin := layout.UniformInset(ui.Dp(10)) margin := layout.UniformInset(ui.Dp(10))
title := &text.Label{Face: face, Text:"passgo"} title := &text.Label{Face: face, Text: "passgo"}
dotsbtn := &Button{ dotsbtn := &Button{
Face: face, Face: face,
Label: "\xe2\x8b\xae", Label: "\xe2\x8b\xae",
Alignment: text.End, Alignment: text.End,
Color: black, Color: black,
Background: gray, Background: gray,
} }
@ -281,9 +280,9 @@ func eventLoop() {
_ = passSubmit _ = passSubmit
pathnames := make([]string, 0) pathnames := make([]string, 0)
copied := &Overlay{Face: face, Text: "copied to clipboard", copied := &Overlay{Face: face, Text: "copied to clipboard",
Color: black, Color: black,
Background: darkgray, Background: darkgray,
Alignment: text.Middle, Alignment: text.Middle,
} }
var copiedWhen time.Time var copiedWhen time.Time
@ -299,8 +298,8 @@ func eventLoop() {
z = "/" z = "/"
} }
passBtns = append(passBtns, &Button{ passBtns = append(passBtns, &Button{
Face: face, Face: face,
Label: strings.Join([]string{s, n, z}, ""), Label: strings.Join([]string{s, n, z}, ""),
Background: gray, Background: gray,
}) })
pathnames = append(pathnames, x.Pathname) pathnames = append(pathnames, x.Pathname)
@ -310,10 +309,10 @@ func eventLoop() {
updateBtns() updateBtns()
confBtn := &Button{ confBtn := &Button{
Face: face, Face: face,
Label: "configure", Label: "configure",
Alignment: text.Middle, Alignment: text.Middle,
Color: black, Color: black,
Background: gray, Background: gray,
} }
@ -321,10 +320,10 @@ func eventLoop() {
storeDirEd := &text.Editor{Face: face, SingleLine: true} storeDirEd := &text.Editor{Face: face, SingleLine: true}
storeDirEd.SetText(store.Dir) storeDirEd.SetText(store.Dir)
saveBtn := &Button{ saveBtn := &Button{
Face: face, Face: face,
Label: "save", Label: "save",
Alignment: text.End, Alignment: text.End,
Color: black, Color: black,
Background: gray, Background: gray,
} }
@ -353,7 +352,7 @@ func eventLoop() {
if len(passBtns) == 0 { if len(passBtns) == 0 {
c2 = flex.End(confBtn.Layout(c, q, ops, cs)) c2 = flex.End(confBtn.Layout(c, q, ops, cs))
if confBtn.Clicked() { if confBtn.Clicked() {
log(Info,"Configure") log(Info, "Configure")
w.Invalidate() w.Invalidate()
page = confPage page = confPage
} }
@ -433,7 +432,7 @@ func eventLoop() {
passgo.GetStore(&store) passgo.GetStore(&store)
Config.StoreDir = store.Dir Config.StoreDir = store.Dir
saveConf() saveConf()
reload <-struct{}{} reload <- struct{}{}
}() }()
page = listPage page = listPage
} }