• Home
  • History
  • Annotate
Name Date Size #Lines LOC

..03-May-2022-

git-hooks/H23-Jul-2021-

mockns1/H23-Jul-2021-

rest/H23-Jul-2021-

script/H23-Jul-2021-

.gitignoreH A D23-Jul-202110

.travis.ymlH A D23-Jul-2021295

CHANGELOG.mdH A D23-Jul-20211.3 KiB

MakefileH A D23-Jul-2021111

README.mdH A D23-Jul-20211.5 KiB

doc.goH A D23-Jul-2021168

go.modH A D23-Jul-202183

go.sumH A D23-Jul-20211 KiB

README.md

1[![Build Status](https://travis-ci.org/ns1/ns1-go.svg?branch=v2)](https://travis-ci.org/ns1/ns1-go) [![GoDoc](https://godoc.org/gopkg.in/ns1/ns1-go.v2?status.svg)](https://godoc.org/gopkg.in/ns1/ns1-go.v2)
2
3# NS1 Golang SDK
4
5> This project is in [active development](https://github.com/ns1/community/blob/master/project_status/ACTIVE_DEVELOPMENT.md).
6
7The golang client for the NS1 API: https://ns1.com/api/
8
9# Installing
10
11```
12$ go get gopkg.in/ns1/ns1-go.v2
13```
14
15Examples
16========
17
18[See more](https://github.com/ns1/ns1-go/tree/v2/rest/_examples)
19
20
21```go
22package main
23
24import (
25	"fmt"
26	"log"
27	"net/http"
28	"os"
29	"time"
30
31	api "gopkg.in/ns1/ns1-go.v2/rest"
32)
33
34func main() {
35	k := os.Getenv("NS1_APIKEY")
36	if k == "" {
37		fmt.Println("NS1_APIKEY environment variable is not set, giving up")
38		os.Exit(1)
39	}
40
41	httpClient := &http.Client{Timeout: time.Second * 10}
42	client := api.NewClient(httpClient, api.SetAPIKey(k))
43
44	zones, _, err := client.Zones.List()
45	if err != nil {
46		log.Fatal(err)
47	}
48
49	for _, z := range zones {
50		fmt.Println(z.Zone)
51	}
52
53}
54```
55
56Contributing
57============
58Pull Requests and issues are welcome. See the [NS1 Contribution Guidelines](https://github.com/ns1/community) for more information.
59
60Run tests:
61
62```
63make test
64```
65
66Local dev: use `go mod replace` in client code to point to local checkout of
67this repository.
68
69Consider running `./script/install-git-hooks` to install local git hooks for this
70project.
71
72# LICENSE
73
74Apache2 - see the included LICENSE file for more information
75