Readd explicit error handling to examples

This commit is contained in:
Caleb Bassi 2018-09-06 18:22:04 -07:00
parent f4dc75130f
commit 00d684343a
15 changed files with 60 additions and 15 deletions

View File

@ -9,7 +9,10 @@ package main
import ui "github.com/gizak/termui" import ui "github.com/gizak/termui"
func main() { func main() {
ui.Init() err := ui.Init()
if err != nil {
panic(err)
}
defer ui.Close() defer ui.Close()
bc := ui.NewBarChart() bc := ui.NewBarChart()

View File

@ -14,7 +14,10 @@ import (
) )
func main() { func main() {
ui.Init() err := ui.Init()
if err != nil {
panic(err)
}
defer ui.Close() defer ui.Close()
p := ui.NewPar(":PRESS q TO QUIT DEMO") p := ui.NewPar(":PRESS q TO QUIT DEMO")

View File

@ -9,7 +9,10 @@ package main
import ui "github.com/gizak/termui" import ui "github.com/gizak/termui"
func main() { func main() {
ui.Init() err := ui.Init()
if err != nil {
panic(err)
}
defer ui.Close() defer ui.Close()
g0 := ui.NewGauge() g0 := ui.NewGauge()

View File

@ -14,7 +14,10 @@ import (
) )
func main() { func main() {
ui.Init() err := ui.Init()
if err != nil {
panic(err)
}
defer ui.Close() defer ui.Close()
sinps := (func() []float64 { sinps := (func() []float64 {

View File

@ -13,7 +13,10 @@ import (
) )
func main() { func main() {
ui.Init() err := ui.Init()
if err != nil {
panic(err)
}
defer ui.Close() defer ui.Close()
sinps := (func() map[string][]float64 { sinps := (func() map[string][]float64 {

View File

@ -9,7 +9,10 @@ package main
import ui "github.com/gizak/termui" import ui "github.com/gizak/termui"
func main() { func main() {
ui.Init() err := ui.Init()
if err != nil {
panic(err)
}
defer ui.Close() defer ui.Close()
strs := []string{ strs := []string{

View File

@ -9,7 +9,10 @@ package main
import ui "github.com/gizak/termui" import ui "github.com/gizak/termui"
func main() { func main() {
ui.Init() err := ui.Init()
if err != nil {
panic(err)
}
defer ui.Close() defer ui.Close()
bc := ui.NewMBarChart() bc := ui.NewMBarChart()

View File

@ -9,7 +9,10 @@ package main
import ui "github.com/gizak/termui" import ui "github.com/gizak/termui"
func main() { func main() {
ui.Init() err := ui.Init()
if err != nil {
panic(err)
}
defer ui.Close() defer ui.Close()
par0 := ui.NewPar("Borderless Text") par0 := ui.NewPar("Borderless Text")

View File

@ -12,7 +12,10 @@ import (
) )
func main() { func main() {
ui.Init() err := ui.Init()
if err != nil {
panic(err)
}
defer ui.Close() defer ui.Close()
rand.Seed(time.Now().UTC().UnixNano()) rand.Seed(time.Now().UTC().UnixNano())

View File

@ -9,7 +9,10 @@ package main
import ui "github.com/gizak/termui" import ui "github.com/gizak/termui"
func main() { func main() {
ui.Init() err := ui.Init()
if err != nil {
panic(err)
}
defer ui.Close() 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} 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}

View File

@ -9,7 +9,10 @@ package main
import ui "github.com/gizak/termui" import ui "github.com/gizak/termui"
func main() { func main() {
ui.Init() err := ui.Init()
if err != nil {
panic(err)
}
defer ui.Close() defer ui.Close()
rows1 := [][]string{ rows1 := [][]string{

View File

@ -12,7 +12,10 @@ import (
) )
func main() { func main() {
ui.Init() err := ui.Init()
if err != nil {
panic(err)
}
defer ui.Close() defer ui.Close()
header := ui.NewPar("Press q to quit, Press j or k to switch tabs") header := ui.NewPar("Press q to quit, Press j or k to switch tabs")

View File

@ -14,7 +14,10 @@ import (
) )
func main() { func main() {
ui.Init() err := ui.Init()
if err != nil {
panic(err)
}
defer ui.Close() defer ui.Close()
// Deprecated // Deprecated

View File

@ -276,7 +276,10 @@ func main() {
if runtime.GOOS != "linux" { if runtime.GOOS != "linux" {
panic("Currently works only on Linux") panic("Currently works only on Linux")
} }
ui.Init() err := ui.Init()
if err != nil {
panic(err)
}
defer ui.Close() defer ui.Close()
termWidth := 70 termWidth := 70

View File

@ -9,7 +9,10 @@ package main
import ui "github.com/gizak/termui" import ui "github.com/gizak/termui"
func main() { func main() {
ui.Init() err := ui.Init()
if err != nil {
panic(err)
}
defer ui.Close() 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.") 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.")