File: example_test.go

package info (click to toggle)
golang-github-putdotio-go-putio 0.0~git20190822.19b9c63-2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 168 kB
  • sloc: makefile: 2
file content (28 lines) | stat: -rw-r--r-- 524 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
package putio_test

import (
	"context"
	"fmt"
	"log"

	"github.com/putdotio/go-putio/putio"
	"golang.org/x/oauth2"
)

const token = "<YOUR-TOKEN-HERE>"

func Example() {
	tokenSource := oauth2.StaticTokenSource(
		&oauth2.Token{AccessToken: token},
	)
	oauthClient := oauth2.NewClient(context.TODO(), tokenSource)
	client := putio.NewClient(oauthClient)

	// get root directory
	root, err := client.Files.Get(context.TODO(), 0)
	if err != nil {
		log.Fatal(err)
	}

	fmt.Printf("Name of root folder is: %s\n", root.Name)
}