Skip to content

Commit 0da4c3a

Browse files
authored
Merge pull request #695 from cben/api-client-examples-shadowing
api client examples: avoid shadowing package with variable
2 parents 9097a2c + 38c6752 commit 0da4c3a

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

api/prometheus/v1/example_test.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,10 @@ func ExampleAPI_query() {
3434
os.Exit(1)
3535
}
3636

37-
api := v1.NewAPI(client)
37+
v1api := v1.NewAPI(client)
3838
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
3939
defer cancel()
40-
result, warnings, err := api.Query(ctx, "up", time.Now())
40+
result, warnings, err := v1api.Query(ctx, "up", time.Now())
4141
if err != nil {
4242
fmt.Printf("Error querying Prometheus: %v\n", err)
4343
os.Exit(1)
@@ -57,15 +57,15 @@ func ExampleAPI_queryRange() {
5757
os.Exit(1)
5858
}
5959

60-
api := v1.NewAPI(client)
60+
v1api := v1.NewAPI(client)
6161
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
6262
defer cancel()
6363
r := v1.Range{
6464
Start: time.Now().Add(-time.Hour),
6565
End: time.Now(),
6666
Step: time.Minute,
6767
}
68-
result, warnings, err := api.QueryRange(ctx, "rate(prometheus_tsdb_head_samples_appended_total[5m])", r)
68+
result, warnings, err := v1api.QueryRange(ctx, "rate(prometheus_tsdb_head_samples_appended_total[5m])", r)
6969
if err != nil {
7070
fmt.Printf("Error querying Prometheus: %v\n", err)
7171
os.Exit(1)
@@ -85,10 +85,10 @@ func ExampleAPI_series() {
8585
os.Exit(1)
8686
}
8787

88-
api := v1.NewAPI(client)
88+
v1api := v1.NewAPI(client)
8989
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
9090
defer cancel()
91-
lbls, warnings, err := api.Series(ctx, []string{
91+
lbls, warnings, err := v1api.Series(ctx, []string{
9292
"{__name__=~\"scrape_.+\",job=\"node\"}",
9393
"{__name__=~\"scrape_.+\",job=\"prometheus\"}",
9494
}, time.Now().Add(-time.Hour), time.Now())

0 commit comments

Comments
 (0)