Skip to content

Commit

Permalink
Format code example in README (#510)
Browse files Browse the repository at this point in the history
  • Loading branch information
zliang-akamai committed Jun 1, 2024
1 parent 3bcb4a6 commit e7939e8
Showing 1 changed file with 23 additions and 24 deletions.
47 changes: 23 additions & 24 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,36 +33,35 @@ package main
import (
"context"
"fmt"

"github.com/linode/linodego"
"golang.org/x/oauth2"

"log"
"net/http"
"os"

"github.com/linode/linodego"
"golang.org/x/oauth2"
)

func main() {
apiKey, ok := os.LookupEnv("LINODE_TOKEN")
if !ok {
log.Fatal("Could not find LINODE_TOKEN, please assert it is set.")
}
tokenSource := oauth2.StaticTokenSource(&oauth2.Token{AccessToken: apiKey})

oauth2Client := &http.Client{
Transport: &oauth2.Transport{
Source: tokenSource,
},
}

linodeClient := linodego.NewClient(oauth2Client)
linodeClient.SetDebug(true)
res, err := linodeClient.GetInstance(context.Background(), 4090913)
if err != nil {
log.Fatal(err)
}
fmt.Printf("%v", res)
apiKey, ok := os.LookupEnv("LINODE_TOKEN")
if !ok {
log.Fatal("Could not find LINODE_TOKEN, please assert it is set.")
}
tokenSource := oauth2.StaticTokenSource(&oauth2.Token{AccessToken: apiKey})

oauth2Client := &http.Client{
Transport: &oauth2.Transport{
Source: tokenSource,
},
}

linodeClient := linodego.NewClient(oauth2Client)
linodeClient.SetDebug(true)

res, err := linodeClient.GetInstance(context.Background(), 4090913)
if err != nil {
log.Fatal(err)
}
fmt.Printf("%v", res)
}
```

Expand Down

0 comments on commit e7939e8

Please sign in to comment.