From 00d684343a33a6c76e851546e9405e680ae0b89e Mon Sep 17 00:00:00 2001 From: Caleb Bassi Date: Thu, 6 Sep 2018 18:22:04 -0700 Subject: [PATCH] Readd explicit error handling to examples --- _examples/barchart.go | 5 ++++- _examples/dashboard.go | 5 ++++- _examples/gauge.go | 5 ++++- _examples/grid.go | 5 ++++- _examples/linechart.go | 5 ++++- _examples/list.go | 5 ++++- _examples/mbarchart.go | 5 ++++- _examples/par.go | 5 ++++- _examples/piechart.go | 5 ++++- _examples/sparklines.go | 5 ++++- _examples/table.go | 5 ++++- _examples/tabs.go | 5 ++++- _examples/theme.go | 5 ++++- _examples/ttop.go | 5 ++++- _examples/wrapper.go | 5 ++++- 15 files changed, 60 insertions(+), 15 deletions(-) diff --git a/_examples/barchart.go b/_examples/barchart.go index d84af8f..7b1f900 100644 --- a/_examples/barchart.go +++ b/_examples/barchart.go @@ -9,7 +9,10 @@ package main import ui "github.com/gizak/termui" func main() { - ui.Init() + err := ui.Init() + if err != nil { + panic(err) + } defer ui.Close() bc := ui.NewBarChart() diff --git a/_examples/dashboard.go b/_examples/dashboard.go index aba764e..8a2aac3 100644 --- a/_examples/dashboard.go +++ b/_examples/dashboard.go @@ -14,7 +14,10 @@ import ( ) func main() { - ui.Init() + err := ui.Init() + if err != nil { + panic(err) + } defer ui.Close() p := ui.NewPar(":PRESS q TO QUIT DEMO") diff --git a/_examples/gauge.go b/_examples/gauge.go index f0835ca..64bb5ea 100644 --- a/_examples/gauge.go +++ b/_examples/gauge.go @@ -9,7 +9,10 @@ package main import ui "github.com/gizak/termui" func main() { - ui.Init() + err := ui.Init() + if err != nil { + panic(err) + } defer ui.Close() g0 := ui.NewGauge() diff --git a/_examples/grid.go b/_examples/grid.go index 1cca0c1..ab1fa1e 100644 --- a/_examples/grid.go +++ b/_examples/grid.go @@ -14,7 +14,10 @@ import ( ) func main() { - ui.Init() + err := ui.Init() + if err != nil { + panic(err) + } defer ui.Close() sinps := (func() []float64 { diff --git a/_examples/linechart.go b/_examples/linechart.go index 641fb62..806c42d 100644 --- a/_examples/linechart.go +++ b/_examples/linechart.go @@ -13,7 +13,10 @@ import ( ) func main() { - ui.Init() + err := ui.Init() + if err != nil { + panic(err) + } defer ui.Close() sinps := (func() map[string][]float64 { diff --git a/_examples/list.go b/_examples/list.go index cf68714..808d290 100644 --- a/_examples/list.go +++ b/_examples/list.go @@ -9,7 +9,10 @@ package main import ui "github.com/gizak/termui" func main() { - ui.Init() + err := ui.Init() + if err != nil { + panic(err) + } defer ui.Close() strs := []string{ diff --git a/_examples/mbarchart.go b/_examples/mbarchart.go index 75e9392..8388099 100644 --- a/_examples/mbarchart.go +++ b/_examples/mbarchart.go @@ -9,7 +9,10 @@ package main import ui "github.com/gizak/termui" func main() { - ui.Init() + err := ui.Init() + if err != nil { + panic(err) + } defer ui.Close() bc := ui.NewMBarChart() diff --git a/_examples/par.go b/_examples/par.go index 4944a80..c68196b 100644 --- a/_examples/par.go +++ b/_examples/par.go @@ -9,7 +9,10 @@ package main import ui "github.com/gizak/termui" func main() { - ui.Init() + err := ui.Init() + if err != nil { + panic(err) + } defer ui.Close() par0 := ui.NewPar("Borderless Text") diff --git a/_examples/piechart.go b/_examples/piechart.go index 53322a1..ae870f4 100644 --- a/_examples/piechart.go +++ b/_examples/piechart.go @@ -12,7 +12,10 @@ import ( ) func main() { - ui.Init() + err := ui.Init() + if err != nil { + panic(err) + } defer ui.Close() rand.Seed(time.Now().UTC().UnixNano()) diff --git a/_examples/sparklines.go b/_examples/sparklines.go index 7d94358..0c0c578 100644 --- a/_examples/sparklines.go +++ b/_examples/sparklines.go @@ -9,7 +9,10 @@ package main import ui "github.com/gizak/termui" func main() { - ui.Init() + err := ui.Init() + if err != nil { + panic(err) + } defer ui.Close() data := []int{4, 2, 1, 6, 3, 9, 1, 4, 2, 15, 14, 9, 8, 6, 10, 13, 15, 12, 10, 5, 3, 6, 1, 7, 10, 10, 14, 13, 6} diff --git a/_examples/table.go b/_examples/table.go index 3b6396d..59679df 100644 --- a/_examples/table.go +++ b/_examples/table.go @@ -9,7 +9,10 @@ package main import ui "github.com/gizak/termui" func main() { - ui.Init() + err := ui.Init() + if err != nil { + panic(err) + } defer ui.Close() rows1 := [][]string{ diff --git a/_examples/tabs.go b/_examples/tabs.go index 8915a12..3e68e22 100644 --- a/_examples/tabs.go +++ b/_examples/tabs.go @@ -12,7 +12,10 @@ import ( ) func main() { - ui.Init() + err := ui.Init() + if err != nil { + panic(err) + } defer ui.Close() header := ui.NewPar("Press q to quit, Press j or k to switch tabs") diff --git a/_examples/theme.go b/_examples/theme.go index 0f45947..8c02edb 100644 --- a/_examples/theme.go +++ b/_examples/theme.go @@ -14,7 +14,10 @@ import ( ) func main() { - ui.Init() + err := ui.Init() + if err != nil { + panic(err) + } defer ui.Close() // Deprecated diff --git a/_examples/ttop.go b/_examples/ttop.go index 68308ec..3440651 100644 --- a/_examples/ttop.go +++ b/_examples/ttop.go @@ -276,7 +276,10 @@ func main() { if runtime.GOOS != "linux" { panic("Currently works only on Linux") } - ui.Init() + err := ui.Init() + if err != nil { + panic(err) + } defer ui.Close() termWidth := 70 diff --git a/_examples/wrapper.go b/_examples/wrapper.go index 734ab9a..40158cb 100644 --- a/_examples/wrapper.go +++ b/_examples/wrapper.go @@ -9,7 +9,10 @@ package main import ui "github.com/gizak/termui" func main() { - ui.Init() + err := ui.Init() + if err != nil { + panic(err) + } defer ui.Close() p := ui.NewPar("Press q to QUIT THE DEMO. [There](fg-blue) are other things [that](fg-red) are going to fit in here I think. What do you think? Now is the time for all good [men to](bg-blue) come to the aid of their country. [This is going to be one really really really long line](fg-green) that is going to go together and stuffs and things. Let's see how this thing renders out.\n Here is a new paragraph and stuffs and things. There should be a tab indent at the beginning of the paragraph. Let's see if that worked as well.")