3551: Fix source tree layout.
[arvados.git] / doc / sdk / go / index.html.textile.liquid
1 ---
2 layout: default
3 navsection: sdk
4 navmenu: Go
5 title: "Go SDK"
6
7 ...
8
9 The Go ("Golang":http://golang.org) SDK provides a generic set of wrappers so you can make API calls easily.
10
11 h3. Installation
12
13 You don't need to install anything. Just import the client like this. The go tools will fetch the relevant code and dependencies for you.
14
15 <notextile>
16 <pre><code class="userinput">import (
17         keepclient    "git.curoverse.com/arvados.git/sdk/go/keepclient"
18         arvadosclient "git.curoverse.com/arvados.git/sdk/go/arvadosclient"
19 )
20 </code></pre>
21 </notextile>
22
23 h3. Examples
24
25 Import the module. (We import the log module here too, so we can use it in the subsequent examples.)
26
27 <notextile>
28 <pre><code class="userinput">import (
29         keepclient    "git.curoverse.com/arvados.git/sdk/go/keepclient"
30         arvadosclient "git.curoverse.com/arvados.git/sdk/go/arvadosclient"
31         "log"
32 )
33 </code></pre>
34 </notextile>
35
36 Set up an API client user agent:
37
38 <notextile>
39 <pre><code class="userinput">   arv, err := arvadosclient.MakeArvadosClient()
40         if err != nil {
41                 log.Fatalf("Error setting up arvados client %s", err.Error())
42         }
43 </code></pre>
44 </notextile>
45
46 Get the User object for the current user:
47
48 <notextile>
49 <pre><code class="userinput">   type user struct {
50                 Uuid         string `json:"uuid"`
51                 FullName     int    `json:"full_name"`
52         }
53
54         var u user
55         err := arv.Call("GET", "users", "", "current", nil, &u)
56
57         if err != nil {
58                 return err
59         }
60
61         log.Printf("Logged in as %s (uuid %s)", user.Uuid, user.FullName)
62 </code></pre>
63 </notextile>
64
65 A few more usage examples can be found in the services/keepproxy and sdk/go/keepclient directories in the arvados source tree.