Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Format code example in README #510

Merged
merged 1 commit into from
Jun 1, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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