This is an automated email from the ASF dual-hosted git repository.

xddeng pushed a commit to branch fix-sample-usage-code-in-readme
in repository https://gitbox.apache.org/repos/asf/airflow-client-go.git

commit 9f167d34950a03ed2b49717b23bbcc413ecfd725
Author: Xiaodong DENG <[email protected]>
AuthorDate: Wed Mar 24 09:41:48 2021 +0100

    Make sample code self-contained & fix errors inside
    
    - make the sample usage code self-contained
    - fix a few errors inside: 1. wrong variable name ("cli"); 2. if-else block 
handling err was wrong
---
 README.md | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/README.md b/README.md
index c89d776..4f61c2b 100644
--- a/README.md
+++ b/README.md
@@ -27,14 +27,18 @@ Usage
 -----
 
 ```go
+package main
+
 import (
+       "context"
+       "fmt"
        "github.com/apache/airflow-client-go/airflow"
 )
 
 func main() {
        cli := airflow.NewAPIClient(&airflow.Configuration{
                Scheme:   "http",
-               Host:     "localhost:28080",
+               Host:     "localhost:8080",
                BasePath: "/api/v1",
        })
 
@@ -44,11 +48,11 @@ func main() {
        }
        ctx := context.WithValue(context.Background(), 
airflow.ContextBasicAuth, cred)
 
-       variable, _, err := client.VariableApi.GetVariable(ctx, "foo")
+       variable, _, err := cli.VariableApi.GetVariable(ctx, "foo")
        if err != nil {
-               fmt.Println(variable)
-       } else {
                fmt.Println(err)
+       } else {
+               fmt.Println(variable)
        }
 }
 ```

Reply via email to