commit 96899077ba06fbc4788e2fc4a7ffad74d5e15d8a
parent 46222434bbc0da2ee7f95b4b3a0ef8203deb9053
Author: Jack Mordaunt <jackmordaunt@gmail.com>
Date: Sat, 27 Feb 2021 22:58:46 +0800
ref: reduce noise with helper
Diffstat:
1 file changed, 13 insertions(+), 22 deletions(-)
diff --git a/icons/icons.go b/icons/icons.go
@@ -5,27 +5,18 @@ import (
"golang.org/x/exp/shiny/materialdesign/icons"
)
-var BackIcon *widget.Icon = func() *widget.Icon {
- icon, _ := widget.NewIcon(icons.NavigationArrowBack)
- return icon
-}()
-
-var ForwardIcon *widget.Icon = func() *widget.Icon {
- icon, _ := widget.NewIcon(icons.NavigationArrowForward)
- return icon
-}()
-
-var ContentEdit *widget.Icon = func() *widget.Icon {
- icon, _ := widget.NewIcon(icons.ContentCreate)
- return icon
-}()
-
-var ContentDelete *widget.Icon = func() *widget.Icon {
- icon, _ := widget.NewIcon(icons.ContentDeleteSweep)
- return icon
-}()
+var (
+ BackIcon *widget.Icon = must(widget.NewIcon(icons.NavigationArrowBack))
+ ForwardIcon *widget.Icon = must(widget.NewIcon(icons.NavigationArrowForward))
+ ContentEdit *widget.Icon = must(widget.NewIcon(icons.ContentCreate))
+ ContentDelete *widget.Icon = must(widget.NewIcon(icons.ContentDeleteSweep))
+ ContentAdd *widget.Icon = must(widget.NewIcon(icons.ContentAdd))
+ Configuration *widget.Icon = must(widget.NewIcon(icons.ActionSettings))
+)
-var ContentAdd *widget.Icon = func() *widget.Icon {
- icon, _ := widget.NewIcon(icons.ContentAdd)
+func must(icon *widget.Icon, err error) *widget.Icon {
+ if err != nil {
+ panic(err)
+ }
return icon
-}()
+}