Moved file.
[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         "git.curoverse.com/arvados.git/sdk/go/keepclient"
18         "git.curoverse.com/arvados.git/sdk/go/arvadosclient"
19 )
20 </code></pre>
21 </notextile>
22
23 If you need pre-release client code, you can use the latest version from the repo by following "these instructions.":https://arvados.org/projects/arvados/wiki/Go#Using-Go-with-Arvados
24
25 h3. Examples
26
27 Import the module. (We import the log module here too, so we can use it in the subsequent examples.)
28
29 <notextile>
30 <pre><code class="userinput">import (
31         "git.curoverse.com/arvados.git/sdk/go/keepclient"
32         "git.curoverse.com/arvados.git/sdk/go/arvadosclient"
33         "log"
34 )
35 </code></pre>
36 </notextile>
37
38 Set up an API client user agent:
39
40 <notextile>
41 <pre><code class="userinput">   arv, err := arvadosclient.MakeArvadosClient()
42         if err != nil {
43                 log.Fatalf("Error setting up arvados client %s", err.Error())
44         }
45 </code></pre>
46 </notextile>
47
48 Get the User object for the current user:
49
50 <notextile>
51 <pre><code class="userinput">   type user struct {
52                 Uuid       string   `json:"uuid"`
53                 FullName   string   `json:"full_name"`
54         }
55
56         var u user
57         err := arv.Call("GET", "users", "", "current", nil, &u)
58
59         if err != nil {
60                 return err
61         }
62
63         log.Printf("Logged in as %s (uuid %s)", user.Uuid, user.FullName)
64 </code></pre>
65 </notextile>
66
67 Print all returned fields for collections:
68
69 <notextile>{% code 'example_sdk_go' as go %}</notextile>
70
71 A few more usage examples can be found in the "services/keepproxy":https://arvados.org/projects/arvados/repository/revisions/master/show/services/keepproxy and "sdk/go/keepclient":https://arvados.org/projects/arvados/repository/revisions/master/show/sdk/go/keepclient directories in the arvados source tree.