File: README.md

package info (click to toggle)
golang-github-putdotio-go-putio 0.0~git20190822.19b9c63-3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 180 kB
  • sloc: makefile: 2
file content (43 lines) | stat: -rw-r--r-- 968 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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# putio  [![Build Status](https://travis-ci.org/putdotio/go-putio.svg?branch=master)](https://travis-ci.org/putdotio/go-putio)

putio is a Go client library for accessing the [Put.io API v2](https://api.put.io/v2/docs).

## Documentation

Available on [GoDoc](http://godoc.org/github.com/putdotio/go-putio/putio)

## Install

```sh
go get -u github.com/putdotio/go-putio/putio"
```

## Usage

```go
package main

import (
        "fmt"
        "log"
        "context"

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

func main() {
    oauthToken := "<YOUR-TOKEN-HERE>"
    tokenSource := oauth2.StaticTokenSource(&oauth2.Token{AccessToken: oauthToken})
    oauthClient := oauth2.NewClient(oauth2.NoContext, tokenSource)

    client := putio.NewClient(oauthClient)

    const rootDir = 0
    root, err := client.Files.Get(context.Background(), rootDir)
    if err != nil {
        log.Fatal(err)
    }
    fmt.Println(root.Filename)
}
```