You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by xd...@apache.org on 2021/03/24 08:42:15 UTC

[airflow-client-go] branch fix-sample-usage-code-in-readme created (now 9f167d3)

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

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


      at 9f167d3  Make sample code self-contained & fix errors inside

This branch includes the following new commits:

     new 9f167d3  Make sample code self-contained & fix errors inside

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


[airflow-client-go] 01/01: Make sample code self-contained & fix errors inside

Posted by xd...@apache.org.
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 <xd...@apache.org>
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)
 	}
 }
 ```