From d7c3be82673f869fed4ea77a0c5e3f13bd65ba89 Mon Sep 17 00:00:00 2001 From: Agis Anastasopoulos <827224+agis@users.noreply.github.com> Date: Tue, 21 Aug 2018 11:19:37 +0300 Subject: [PATCH 1/2] Fix README typo --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index f2baef4..6eb2996 100644 --- a/README.md +++ b/README.md @@ -670,7 +670,7 @@ func main() { ``` Note that default values set from file (e.g. `FilePath`) take precedence over -default values set from the enviornment (e.g. `EnvVar`). +default values set from the environment (e.g. `EnvVar`). #### Values from alternate input sources (YAML, TOML, and others) From 5b83c895a70b7714548f0aa4f43deb3fa5fc1601 Mon Sep 17 00:00:00 2001 From: "Iskander (Alex) Sharipov" Date: Tue, 29 Jan 2019 22:51:02 +0300 Subject: [PATCH 2/2] use type switch instead of if/else This reduces the syntax noise of the code by removing excessive type assertions. Signed-off-by: Iskander Sharipov --- app.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/app.go b/app.go index 9add067..b54e1ab 100644 --- a/app.go +++ b/app.go @@ -495,11 +495,12 @@ func (a Author) String() string { // it's an ActionFunc or a func with the legacy signature for Action, the func // is run! func HandleAction(action interface{}, context *Context) (err error) { - if a, ok := action.(ActionFunc); ok { + switch a := action.(type) { + case ActionFunc: return a(context) - } else if a, ok := action.(func(*Context) error); ok { + case func(*Context) error: return a(context) - } else if a, ok := action.(func(*Context)); ok { // deprecated function signature + case func(*Context): // deprecated function signature a(context) return nil }