Make sample code self-contained & fix errors inside (#7)
- 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
diff --git a/README.md b/README.md
index c89d776..4f61c2b 100644
--- a/README.md
+++ b/README.md
@@ -27,14 +27,18 @@
-----
```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 @@
}
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)
}
}
```