diff options
| author | Shulhan <ms@kilabit.info> | 2021-03-07 00:30:32 +0700 |
|---|---|---|
| committer | Shulhan <ms@kilabit.info> | 2021-03-07 00:30:32 +0700 |
| commit | de6fcb8484980a9f119ebfdb79f90b9c5a713718 (patch) | |
| tree | 238930c1f5daec6d3324f135d692002291b8c278 /script_example_test.go | |
| parent | b8f671f5744b18bc1beabd78d12fa840aabb28b9 (diff) | |
| download | awwan-de6fcb8484980a9f119ebfdb79f90b9c5a713718.tar.xz | |
all: never, ever use log.Fatal on library
A good library is the one that return an error when something happened,
not immediately stop the program.
I made a mistake and I learn from it.
Diffstat (limited to 'script_example_test.go')
| -rw-r--r-- | script_example_test.go | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/script_example_test.go b/script_example_test.go index 6f89a51..01b9c1a 100644 --- a/script_example_test.go +++ b/script_example_test.go @@ -6,6 +6,7 @@ package awwan import ( "fmt" + "log" ) func Examplescript_join() { @@ -20,9 +21,15 @@ command {{.Val "section::key"}};\ end; ` env := &Environment{} - env.parse([]byte(envContent)) + err := env.parse([]byte(envContent)) + if err != nil { + log.Fatal(err) + } - s := parseScript(env, []byte(scriptContent)) + s, err := parseScript(env, []byte(scriptContent)) + if err != nil { + log.Fatal(err) + } for _, stmt := range s.Statements { fmt.Printf("%s\n", stmt) |
