Brendan Abolivier 6 år sedan
förälder
incheckning
8d175bf33b
Signed by: Brendan Abolivier <contact@brendanabolivier.com> GPG key ID: 8EF1500759F70623
100 ändrade filer med 7443 tillägg och 6 borttagningar
  1. 6
    0
      src/config/config.go
  2. 34
    0
      src/git/git.go
  3. 16
    1
      src/grafana/client.go
  4. 30
    0
      src/logger/logger.go
  5. 3
    0
      src/puller/main.go
  6. 22
    0
      src/puller/puller.go
  7. 3
    0
      src/pusher/main.go
  8. 45
    5
      src/pusher/webhook.go
  9. 13
    0
      vendor/manifest
  10. 118
    0
      vendor/src/github.com/sirupsen/logrus/CHANGELOG.md
  11. 21
    0
      vendor/src/github.com/sirupsen/logrus/LICENSE
  12. 509
    0
      vendor/src/github.com/sirupsen/logrus/README.md
  13. 64
    0
      vendor/src/github.com/sirupsen/logrus/alt_exit.go
  14. 83
    0
      vendor/src/github.com/sirupsen/logrus/alt_exit_test.go
  15. 14
    0
      vendor/src/github.com/sirupsen/logrus/appveyor.yml
  16. 26
    0
      vendor/src/github.com/sirupsen/logrus/doc.go
  17. 279
    0
      vendor/src/github.com/sirupsen/logrus/entry.go
  18. 77
    0
      vendor/src/github.com/sirupsen/logrus/entry_test.go
  19. 69
    0
      vendor/src/github.com/sirupsen/logrus/example_basic_test.go
  20. 35
    0
      vendor/src/github.com/sirupsen/logrus/example_hook_test.go
  21. 193
    0
      vendor/src/github.com/sirupsen/logrus/exported.go
  22. 45
    0
      vendor/src/github.com/sirupsen/logrus/formatter.go
  23. 101
    0
      vendor/src/github.com/sirupsen/logrus/formatter_bench_test.go
  24. 144
    0
      vendor/src/github.com/sirupsen/logrus/hook_test.go
  25. 34
    0
      vendor/src/github.com/sirupsen/logrus/hooks.go
  26. 39
    0
      vendor/src/github.com/sirupsen/logrus/hooks/syslog/README.md
  27. 55
    0
      vendor/src/github.com/sirupsen/logrus/hooks/syslog/syslog.go
  28. 27
    0
      vendor/src/github.com/sirupsen/logrus/hooks/syslog/syslog_test.go
  29. 95
    0
      vendor/src/github.com/sirupsen/logrus/hooks/test/test.go
  30. 39
    0
      vendor/src/github.com/sirupsen/logrus/hooks/test/test_test.go
  31. 79
    0
      vendor/src/github.com/sirupsen/logrus/json_formatter.go
  32. 199
    0
      vendor/src/github.com/sirupsen/logrus/json_formatter_test.go
  33. 323
    0
      vendor/src/github.com/sirupsen/logrus/logger.go
  34. 61
    0
      vendor/src/github.com/sirupsen/logrus/logger_bench_test.go
  35. 143
    0
      vendor/src/github.com/sirupsen/logrus/logrus.go
  36. 386
    0
      vendor/src/github.com/sirupsen/logrus/logrus_test.go
  37. 10
    0
      vendor/src/github.com/sirupsen/logrus/terminal_bsd.go
  38. 11
    0
      vendor/src/github.com/sirupsen/logrus/terminal_check_appengine.go
  39. 19
    0
      vendor/src/github.com/sirupsen/logrus/terminal_check_notappengine.go
  40. 14
    0
      vendor/src/github.com/sirupsen/logrus/terminal_linux.go
  41. 178
    0
      vendor/src/github.com/sirupsen/logrus/text_formatter.go
  42. 141
    0
      vendor/src/github.com/sirupsen/logrus/text_formatter_test.go
  43. 62
    0
      vendor/src/github.com/sirupsen/logrus/writer.go
  44. 173
    0
      vendor/src/golang.org/x/sys/unix/README.md
  45. 124
    0
      vendor/src/golang.org/x/sys/unix/affinity_linux.go
  46. 29
    0
      vendor/src/golang.org/x/sys/unix/asm_darwin_386.s
  47. 29
    0
      vendor/src/golang.org/x/sys/unix/asm_darwin_amd64.s
  48. 30
    0
      vendor/src/golang.org/x/sys/unix/asm_darwin_arm.s
  49. 30
    0
      vendor/src/golang.org/x/sys/unix/asm_darwin_arm64.s
  50. 29
    0
      vendor/src/golang.org/x/sys/unix/asm_dragonfly_amd64.s
  51. 29
    0
      vendor/src/golang.org/x/sys/unix/asm_freebsd_386.s
  52. 29
    0
      vendor/src/golang.org/x/sys/unix/asm_freebsd_amd64.s
  53. 29
    0
      vendor/src/golang.org/x/sys/unix/asm_freebsd_arm.s
  54. 65
    0
      vendor/src/golang.org/x/sys/unix/asm_linux_386.s
  55. 57
    0
      vendor/src/golang.org/x/sys/unix/asm_linux_amd64.s
  56. 57
    0
      vendor/src/golang.org/x/sys/unix/asm_linux_arm.s
  57. 52
    0
      vendor/src/golang.org/x/sys/unix/asm_linux_arm64.s
  58. 56
    0
      vendor/src/golang.org/x/sys/unix/asm_linux_mips64x.s
  59. 54
    0
      vendor/src/golang.org/x/sys/unix/asm_linux_mipsx.s
  60. 56
    0
      vendor/src/golang.org/x/sys/unix/asm_linux_ppc64x.s
  61. 56
    0
      vendor/src/golang.org/x/sys/unix/asm_linux_s390x.s
  62. 29
    0
      vendor/src/golang.org/x/sys/unix/asm_netbsd_386.s
  63. 29
    0
      vendor/src/golang.org/x/sys/unix/asm_netbsd_amd64.s
  64. 29
    0
      vendor/src/golang.org/x/sys/unix/asm_netbsd_arm.s
  65. 29
    0
      vendor/src/golang.org/x/sys/unix/asm_openbsd_386.s
  66. 29
    0
      vendor/src/golang.org/x/sys/unix/asm_openbsd_amd64.s
  67. 29
    0
      vendor/src/golang.org/x/sys/unix/asm_openbsd_arm.s
  68. 17
    0
      vendor/src/golang.org/x/sys/unix/asm_solaris_amd64.s
  69. 35
    0
      vendor/src/golang.org/x/sys/unix/bluetooth_linux.go
  70. 195
    0
      vendor/src/golang.org/x/sys/unix/cap_freebsd.go
  71. 13
    0
      vendor/src/golang.org/x/sys/unix/constants.go
  72. 152
    0
      vendor/src/golang.org/x/sys/unix/creds_test.go
  73. 24
    0
      vendor/src/golang.org/x/sys/unix/dev_darwin.go
  74. 51
    0
      vendor/src/golang.org/x/sys/unix/dev_darwin_test.go
  75. 30
    0
      vendor/src/golang.org/x/sys/unix/dev_dragonfly.go
  76. 50
    0
      vendor/src/golang.org/x/sys/unix/dev_dragonfly_test.go
  77. 30
    0
      vendor/src/golang.org/x/sys/unix/dev_freebsd.go
  78. 42
    0
      vendor/src/golang.org/x/sys/unix/dev_linux.go
  79. 53
    0
      vendor/src/golang.org/x/sys/unix/dev_linux_test.go
  80. 29
    0
      vendor/src/golang.org/x/sys/unix/dev_netbsd.go
  81. 50
    0
      vendor/src/golang.org/x/sys/unix/dev_netbsd_test.go
  82. 29
    0
      vendor/src/golang.org/x/sys/unix/dev_openbsd.go
  83. 54
    0
      vendor/src/golang.org/x/sys/unix/dev_openbsd_test.go
  84. 51
    0
      vendor/src/golang.org/x/sys/unix/dev_solaris_test.go
  85. 102
    0
      vendor/src/golang.org/x/sys/unix/dirent.go
  86. 9
    0
      vendor/src/golang.org/x/sys/unix/endian_big.go
  87. 9
    0
      vendor/src/golang.org/x/sys/unix/endian_little.go
  88. 31
    0
      vendor/src/golang.org/x/sys/unix/env_unix.go
  89. 227
    0
      vendor/src/golang.org/x/sys/unix/errors_freebsd_386.go
  90. 227
    0
      vendor/src/golang.org/x/sys/unix/errors_freebsd_amd64.go
  91. 226
    0
      vendor/src/golang.org/x/sys/unix/errors_freebsd_arm.go
  92. 9
    0
      vendor/src/golang.org/x/sys/unix/export_test.go
  93. 22
    0
      vendor/src/golang.org/x/sys/unix/flock.go
  94. 13
    0
      vendor/src/golang.org/x/sys/unix/flock_linux_32bit.go
  95. 46
    0
      vendor/src/golang.org/x/sys/unix/gccgo.go
  96. 41
    0
      vendor/src/golang.org/x/sys/unix/gccgo_c.c
  97. 20
    0
      vendor/src/golang.org/x/sys/unix/gccgo_linux_amd64.go
  98. 51
    0
      vendor/src/golang.org/x/sys/unix/linux/Dockerfile
  99. 482
    0
      vendor/src/golang.org/x/sys/unix/linux/mkall.go
  100. 0
    0
      vendor/src/golang.org/x/sys/unix/linux/mksysnum.pl

+ 6
- 0
src/config/config.go Visa fil

@@ -5,6 +5,8 @@ import (
5 5
 	"strings"
6 6
 
7 7
 	"gopkg.in/yaml.v2"
8
+
9
+	"github.com/sirupsen/logrus"
8 10
 )
9 11
 
10 12
 // Config is the Go representation of the configuration file. It is filled when
@@ -57,6 +59,10 @@ func Load(filename string) (cfg *Config, err error) {
57 59
 		return
58 60
 	}
59 61
 
62
+	logrus.WithFields(logrus.Fields{
63
+		"config_file": filename,
64
+	}).Info("Loading configuration")
65
+
60 66
 	cfg = new(Config)
61 67
 	err = yaml.Unmarshal(rawCfg, cfg)
62 68
 	cfg.Grafana.IgnorePrefix = strings.ToLower(cfg.Grafana.IgnorePrefix)

+ 34
- 0
src/git/git.go Visa fil

@@ -7,6 +7,7 @@ import (
7 7
 
8 8
 	"config"
9 9
 
10
+	"github.com/sirupsen/logrus"
10 11
 	"golang.org/x/crypto/ssh"
11 12
 	gogit "gopkg.in/src-d/go-git.v4"
12 13
 	gitssh "gopkg.in/src-d/go-git.v4/plumbing/transport/ssh"
@@ -34,6 +35,12 @@ func Sync(cfg config.GitSettings) (r *gogit.Repository, err error) {
34 35
 		return
35 36
 	}
36 37
 
38
+	logrus.WithFields(logrus.Fields{
39
+		"repo":       cfg.User + "@" + cfg.URL,
40
+		"clone_path": cfg.ClonePath,
41
+		"pull":       exists,
42
+	}).Info("Synchronising the Git repository with the remote")
43
+
37 44
 	// If the clone path already exists, pull from the remote, else clone it.
38 45
 	if exists {
39 46
 		r, err = pull(cfg.ClonePath, auth)
@@ -101,12 +108,22 @@ func pull(clonePath string, auth *gitssh.PublicKeys) (*gogit.Repository, error)
101 108
 	// update"
102 109
 	if err != nil {
103 110
 		if err == gogit.NoErrAlreadyUpToDate {
111
+			logrus.WithFields(logrus.Fields{
112
+				"clone_path": clonePath,
113
+				"error":      err,
114
+			}).Info("Caught specific non-error")
115
+
104 116
 			return r, nil
105 117
 		}
106 118
 
107 119
 		// go-git doesn't have an error variable for "non-fast-forward update",
108 120
 		// so this is the only way to detect it
109 121
 		if strings.HasPrefix(err.Error(), "non-fast-forward update") {
122
+			logrus.WithFields(logrus.Fields{
123
+				"clone_path": clonePath,
124
+				"error":      err,
125
+			}).Info("Caught specific non-error")
126
+
110 127
 			return r, nil
111 128
 		}
112 129
 	}
@@ -141,6 +158,11 @@ func Push(r *gogit.Repository, cfg config.GitSettings) error {
141 158
 		return err
142 159
 	}
143 160
 
161
+	logrus.WithFields(logrus.Fields{
162
+		"repo":       cfg.User + "@" + cfg.URL,
163
+		"clone_path": cfg.ClonePath,
164
+	}).Info("Pushing to the remote")
165
+
144 166
 	// Push to remote
145 167
 	err = r.Push(&gogit.PushOptions{
146 168
 		Auth: auth,
@@ -150,12 +172,24 @@ func Push(r *gogit.Repository, cfg config.GitSettings) error {
150 172
 	// update"
151 173
 	if err != nil {
152 174
 		if err == gogit.NoErrAlreadyUpToDate {
175
+			logrus.WithFields(logrus.Fields{
176
+				"repo":       cfg.User + "@" + cfg.URL,
177
+				"clone_path": cfg.ClonePath,
178
+				"error":      err,
179
+			}).Info("Caught specific non-error")
180
+
153 181
 			return nil
154 182
 		}
155 183
 
156 184
 		// go-git doesn't have an error variable for "non-fast-forward update", so
157 185
 		// this is the only way to detect it
158 186
 		if strings.HasPrefix(err.Error(), "non-fast-forward update") {
187
+			logrus.WithFields(logrus.Fields{
188
+				"repo":       cfg.User + "@" + cfg.URL,
189
+				"clone_path": cfg.ClonePath,
190
+				"error":      err,
191
+			}).Info("Caught specific non-error")
192
+
159 193
 			return nil
160 194
 		}
161 195
 	}

+ 16
- 1
src/grafana/client.go Visa fil

@@ -6,6 +6,8 @@ import (
6 6
 	"io/ioutil"
7 7
 	"net/http"
8 8
 	"strings"
9
+
10
+	"github.com/sirupsen/logrus"
9 11
 )
10 12
 
11 13
 // Client implements a Grafana API client, and contains the instance's base URL
@@ -42,7 +44,14 @@ func NewClient(baseURL string, apiKey string) (c *Client) {
42 44
 // status code is neither 200 nor 404 an error of type httpUnkownError is
43 45
 // returned.
44 46
 func (c *Client) request(method string, endpoint string, body []byte) ([]byte, error) {
45
-	url := c.BaseURL + "/api/" + endpoint
47
+	route := "/api/" + endpoint
48
+
49
+	logrus.WithFields(logrus.Fields{
50
+		"route":  route,
51
+		"method": method,
52
+	}).Info("Querying the Grafana HTTP API")
53
+
54
+	url := c.BaseURL + route
46 55
 
47 56
 	// Create the request
48 57
 	req, err := http.NewRequest(method, url, bytes.NewBuffer(body))
@@ -66,6 +75,12 @@ func (c *Client) request(method string, endpoint string, body []byte) ([]byte, e
66 75
 		return nil, err
67 76
 	}
68 77
 
78
+	logrus.WithFields(logrus.Fields{
79
+		"route":  route,
80
+		"method": method,
81
+		"code":   resp.StatusCode,
82
+	}).Info("The Grafana HTTP API responded")
83
+
69 84
 	// Read the response body
70 85
 	respBody, err := ioutil.ReadAll(resp.Body)
71 86
 	if err != nil {

+ 30
- 0
src/logger/logger.go Visa fil

@@ -0,0 +1,30 @@
1
+package logger
2
+
3
+import (
4
+	"github.com/sirupsen/logrus"
5
+)
6
+
7
+// utcFormatter is a custom logrus formatter that converts the time for all
8
+// entries to UTC.
9
+type utcFormatter struct {
10
+	logrus.Formatter
11
+}
12
+
13
+// Format implements logrus.Formatter.Format().
14
+func (f utcFormatter) Format(entry *logrus.Entry) ([]byte, error) {
15
+	entry.Time = entry.Time.UTC()
16
+	return f.Formatter.Format(entry)
17
+}
18
+
19
+// LogConfig sets the format of the default logger.
20
+func LogConfig() {
21
+	logrus.SetFormatter(&utcFormatter{
22
+		&logrus.TextFormatter{
23
+			TimestampFormat:  "2006-01-02T15:04:05.000000000Z07:00",
24
+			FullTimestamp:    true,
25
+			DisableColors:    false,
26
+			DisableTimestamp: false,
27
+			DisableSorting:   false,
28
+		},
29
+	})
30
+}

+ 3
- 0
src/puller/main.go Visa fil

@@ -5,12 +5,15 @@ import (
5 5
 
6 6
 	"config"
7 7
 	"grafana"
8
+	"logger"
8 9
 )
9 10
 
10 11
 func main() {
11 12
 	configFile := flag.String("config", "config.yaml", "Path to the configuration file")
12 13
 	flag.Parse()
13 14
 
15
+	logger.LogConfig()
16
+
14 17
 	cfg, err := config.Load(*configFile)
15 18
 	if err != nil {
16 19
 		panic(err)

+ 22
- 0
src/puller/puller.go Visa fil

@@ -11,6 +11,7 @@ import (
11 11
 	"git"
12 12
 	"grafana"
13 13
 
14
+	"github.com/sirupsen/logrus"
14 15
 	gogit "gopkg.in/src-d/go-git.v4"
15 16
 )
16 17
 
@@ -37,6 +38,7 @@ func PullGrafanaAndCommit(client *grafana.Client, cfg *config.Config) error {
37 38
 	}
38 39
 
39 40
 	// Get URIs for all known dashboards
41
+	logrus.Info("Getting dashboard URIs")
40 42
 	uris, err := client.GetDashboardsURIs()
41 43
 	if err != nil {
42 44
 		return err
@@ -45,6 +47,7 @@ func PullGrafanaAndCommit(client *grafana.Client, cfg *config.Config) error {
45 47
 	dv := make(map[string]diffVersion)
46 48
 
47 49
 	// Load versions
50
+	logrus.Info("Getting local dashboard versions")
48 51
 	dbVersions, err := getDashboardsVersions(cfg.Git.ClonePath)
49 52
 	if err != nil {
50 53
 		return err
@@ -52,6 +55,10 @@ func PullGrafanaAndCommit(client *grafana.Client, cfg *config.Config) error {
52 55
 
53 56
 	// Iterate over the dashboards URIs
54 57
 	for _, uri := range uris {
58
+		logrus.WithFields(logrus.Fields{
59
+			"uri": uri,
60
+		}).Info("Retrieving dashboard")
61
+
55 62
 		// Retrieve the dashboard JSON
56 63
 		dashboard, err := client.GetDashboard(uri)
57 64
 		if err != nil {
@@ -61,6 +68,12 @@ func PullGrafanaAndCommit(client *grafana.Client, cfg *config.Config) error {
61 68
 		if len(cfg.Grafana.IgnorePrefix) > 0 {
62 69
 			lowerCasedName := strings.ToLower(dashboard.Name)
63 70
 			if strings.HasPrefix(lowerCasedName, cfg.Grafana.IgnorePrefix) {
71
+				logrus.WithFields(logrus.Fields{
72
+					"uri":    uri,
73
+					"name":   dashboard.Name,
74
+					"prefix": cfg.Grafana.IgnorePrefix,
75
+				}).Info("Dashboard name starts with specified prefix, skipping")
76
+
64 77
 				continue
65 78
 			}
66 79
 		}
@@ -72,6 +85,13 @@ func PullGrafanaAndCommit(client *grafana.Client, cfg *config.Config) error {
72 85
 		// changes in the repo and add the modified file to the git index.
73 86
 		version, ok := dbVersions[dashboard.Slug]
74 87
 		if !ok || dashboard.Version > version {
88
+			logrus.WithFields(logrus.Fields{
89
+				"uri":           uri,
90
+				"name":          dashboard.Name,
91
+				"local_version": version,
92
+				"new_version":   dashboard.Version,
93
+			}).Info("Grafana has a newer version, updating")
94
+
75 95
 			if err = addDashboardChangesToRepo(
76 96
 				dashboard, cfg.Git.ClonePath, w,
77 97
 			); err != nil {
@@ -96,6 +116,8 @@ func PullGrafanaAndCommit(client *grafana.Client, cfg *config.Config) error {
96 116
 
97 117
 	// Check if there's uncommited changes, and if that's the case, commit them.
98 118
 	if !status.IsClean() {
119
+		logrus.Info("Comitting changes")
120
+
99 121
 		if err = commitNewVersions(dbVersions, dv, w, cfg); err != nil {
100 122
 			return err
101 123
 		}

+ 3
- 0
src/pusher/main.go Visa fil

@@ -5,6 +5,7 @@ import (
5 5
 
6 6
 	"config"
7 7
 	"grafana"
8
+	"logger"
8 9
 )
9 10
 
10 11
 // The Grafana API client and the config need to be global to the package since
@@ -21,6 +22,8 @@ func main() {
21 22
 	configFile := flag.String("config", "config.yaml", "Path to the configuration file")
22 23
 	flag.Parse()
23 24
 
25
+	logger.LogConfig()
26
+
24 27
 	cfg, err = config.Load(*configFile)
25 28
 	if err != nil {
26 29
 		panic(err)

+ 45
- 5
src/pusher/webhook.go Visa fil

@@ -9,6 +9,7 @@ import (
9 9
 	"git"
10 10
 	puller "puller"
11 11
 
12
+	"github.com/sirupsen/logrus"
12 13
 	"gopkg.in/go-playground/webhooks.v3"
13 14
 	"gopkg.in/go-playground/webhooks.v3/gitlab"
14 15
 )
@@ -42,7 +43,13 @@ func HandlePush(payload interface{}, header webhooks.Header) {
42 43
 
43 44
 	// Clone or pull the repository
44 45
 	if _, err = git.Sync(cfg.Git); err != nil {
45
-		panic(err)
46
+		logrus.WithFields(logrus.Fields{
47
+			"error":      err,
48
+			"repo":       cfg.Git.User + "@" + cfg.Git.URL,
49
+			"clone_path": cfg.Git.ClonePath,
50
+		}).Error("Failed to synchronise the Git repository with the remote")
51
+
52
+		return
46 53
 	}
47 54
 
48 55
 	// Files to push are stored in a map before being pushed to the Grafana API.
@@ -56,6 +63,12 @@ func HandlePush(payload interface{}, header webhooks.Header) {
56 63
 	for _, commit := range pl.Commits {
57 64
 		// We don't want to process commits made by the puller
58 65
 		if commit.Author.Email == cfg.Git.CommitsAuthor.Email {
66
+			logrus.WithFields(logrus.Fields{
67
+				"hash":          commit.ID,
68
+				"author_email":  commit.Author.Email,
69
+				"manager_email": cfg.Git.CommitsAuthor.Email,
70
+			}).Info("Commit was made by the manager, skipping")
71
+
59 72
 			continue
60 73
 		}
61 74
 
@@ -64,10 +77,19 @@ func HandlePush(payload interface{}, header webhooks.Header) {
64 77
 		for _, addedFile := range commit.Added {
65 78
 			ignored, err := isIgnored(addedFile)
66 79
 			if err != nil {
67
-				panic(err)
80
+				logrus.WithFields(logrus.Fields{
81
+					"error":    err,
82
+					"filename": addedFile,
83
+				}).Error("Failed to check if file is to be ignored")
84
+
85
+				continue
68 86
 			}
69 87
 
70 88
 			if !ignored {
89
+				logrus.WithFields(logrus.Fields{
90
+					"filename": addedFile,
91
+				}).Info("Setting file as file to push to Grafana")
92
+
71 93
 				filesToPush[addedFile] = true
72 94
 			}
73 95
 		}
@@ -77,10 +99,19 @@ func HandlePush(payload interface{}, header webhooks.Header) {
77 99
 		for _, modifiedFile := range commit.Modified {
78 100
 			ignored, err := isIgnored(modifiedFile)
79 101
 			if err != nil {
80
-				panic(err)
102
+				logrus.WithFields(logrus.Fields{
103
+					"error":    err,
104
+					"filename": modifiedFile,
105
+				}).Error("Failed to check if file is to be ignored")
106
+
107
+				continue
81 108
 			}
82 109
 
83 110
 			if !ignored {
111
+				logrus.WithFields(logrus.Fields{
112
+					"filename": modifiedFile,
113
+				}).Info("Setting file as file to push to Grafana")
114
+
84 115
 				filesToPush[modifiedFile] = true
85 116
 			}
86 117
 		}
@@ -91,7 +122,12 @@ func HandlePush(payload interface{}, header webhooks.Header) {
91 122
 	// Push all files to the Grafana API
92 123
 	for fileToPush := range filesToPush {
93 124
 		if err = pushFile(fileToPush); err != nil {
94
-			panic(err)
125
+			logrus.WithFields(logrus.Fields{
126
+				"error":    err,
127
+				"filename": fileToPush,
128
+			}).Error("Failed push the file to Grafana")
129
+
130
+			continue
95 131
 		}
96 132
 	}
97 133
 
@@ -99,7 +135,11 @@ func HandlePush(payload interface{}, header webhooks.Header) {
99 135
 	// dashboards, so we use the puller mechanic to pull the updated numbers and
100 136
 	// commit them in the git repo.
101 137
 	if err = puller.PullGrafanaAndCommit(grafanaClient, cfg); err != nil {
102
-		panic(err)
138
+		logrus.WithFields(logrus.Fields{
139
+			"error":      err,
140
+			"repo":       cfg.Git.User + "@" + cfg.Git.URL,
141
+			"clone_path": cfg.Git.ClonePath,
142
+		}).Error("Call to puller returned an error")
103 143
 	}
104 144
 }
105 145
 

+ 13
- 0
vendor/manifest Visa fil

@@ -34,6 +34,12 @@
34 34
 			"path": "/diffmatchpatch"
35 35
 		},
36 36
 		{
37
+			"importpath": "github.com/sirupsen/logrus",
38
+			"repository": "https://github.com/sirupsen/logrus",
39
+			"revision": "d682213848ed68c0a260ca37d6dd5ace8423f5ba",
40
+			"branch": "master"
41
+		},
42
+		{
37 43
 			"importpath": "github.com/src-d/gcfg",
38 44
 			"repository": "https://github.com/src-d/gcfg",
39 45
 			"revision": "f187355171c936ac84a82793659ebb4936bc1c23",
@@ -80,6 +86,13 @@
80 86
 			"path": "/context"
81 87
 		},
82 88
 		{
89
+			"importpath": "golang.org/x/sys/unix",
90
+			"repository": "https://go.googlesource.com/sys",
91
+			"revision": "1792d66dc88e503d3cb2400578221cdf1f7fe26f",
92
+			"branch": "master",
93
+			"path": "/unix"
94
+		},
95
+		{
83 96
 			"importpath": "golang.org/x/text/transform",
84 97
 			"repository": "https://go.googlesource.com/text",
85 98
 			"revision": "e19ae1496984b1c655b8044a65c0300a3c878dd3",

+ 118
- 0
vendor/src/github.com/sirupsen/logrus/CHANGELOG.md Visa fil

@@ -0,0 +1,118 @@
1
+# 1.0.4
2
+
3
+* Fix race when adding hooks (#612)
4
+* Fix terminal check in AppEngine (#635)
5
+
6
+# 1.0.3
7
+
8
+* Replace example files with testable examples
9
+
10
+# 1.0.2
11
+
12
+* bug: quote non-string values in text formatter (#583)
13
+* Make (*Logger) SetLevel a public method
14
+
15
+# 1.0.1
16
+
17
+* bug: fix escaping in text formatter (#575)
18
+
19
+# 1.0.0
20
+
21
+* Officially changed name to lower-case
22
+* bug: colors on Windows 10 (#541)
23
+* bug: fix race in accessing level (#512)
24
+
25
+# 0.11.5
26
+
27
+* feature: add writer and writerlevel to entry (#372)
28
+
29
+# 0.11.4
30
+
31
+* bug: fix undefined variable on solaris (#493)
32
+
33
+# 0.11.3
34
+
35
+* formatter: configure quoting of empty values (#484)
36
+* formatter: configure quoting character (default is `"`) (#484)
37
+* bug: fix not importing io correctly in non-linux environments (#481)
38
+
39
+# 0.11.2
40
+
41
+* bug: fix windows terminal detection (#476)
42
+
43
+# 0.11.1
44
+
45
+* bug: fix tty detection with custom out (#471)
46
+
47
+# 0.11.0
48
+
49
+* performance: Use bufferpool to allocate (#370)
50
+* terminal: terminal detection for app-engine (#343)
51
+* feature: exit handler (#375)
52
+
53
+# 0.10.0
54
+
55
+* feature: Add a test hook (#180)
56
+* feature: `ParseLevel` is now case-insensitive (#326)
57
+* feature: `FieldLogger` interface that generalizes `Logger` and `Entry` (#308)
58
+* performance: avoid re-allocations on `WithFields` (#335)
59
+
60
+# 0.9.0
61
+
62
+* logrus/text_formatter: don't emit empty msg
63
+* logrus/hooks/airbrake: move out of main repository
64
+* logrus/hooks/sentry: move out of main repository
65
+* logrus/hooks/papertrail: move out of main repository
66
+* logrus/hooks/bugsnag: move out of main repository
67
+* logrus/core: run tests with `-race`
68
+* logrus/core: detect TTY based on `stderr`
69
+* logrus/core: support `WithError` on logger
70
+* logrus/core: Solaris support
71
+
72
+# 0.8.7
73
+
74
+* logrus/core: fix possible race (#216)
75
+* logrus/doc: small typo fixes and doc improvements
76
+
77
+
78
+# 0.8.6
79
+
80
+* hooks/raven: allow passing an initialized client
81
+
82
+# 0.8.5
83
+
84
+* logrus/core: revert #208
85
+
86
+# 0.8.4
87
+
88
+* formatter/text: fix data race (#218)
89
+
90
+# 0.8.3
91
+
92
+* logrus/core: fix entry log level (#208)
93
+* logrus/core: improve performance of text formatter by 40%
94
+* logrus/core: expose `LevelHooks` type
95
+* logrus/core: add support for DragonflyBSD and NetBSD
96
+* formatter/text: print structs more verbosely
97
+
98
+# 0.8.2
99
+
100
+* logrus: fix more Fatal family functions
101
+
102
+# 0.8.1
103
+
104
+* logrus: fix not exiting on `Fatalf` and `Fatalln`
105
+
106
+# 0.8.0
107
+
108
+* logrus: defaults to stderr instead of stdout
109
+* hooks/sentry: add special field for `*http.Request`
110
+* formatter/text: ignore Windows for colors
111
+
112
+# 0.7.3
113
+
114
+* formatter/\*: allow configuration of timestamp layout
115
+
116
+# 0.7.2
117
+
118
+* formatter/text: Add configuration option for time format (#158)

+ 21
- 0
vendor/src/github.com/sirupsen/logrus/LICENSE Visa fil

@@ -0,0 +1,21 @@
1
+The MIT License (MIT)
2
+
3
+Copyright (c) 2014 Simon Eskildsen
4
+
5
+Permission is hereby granted, free of charge, to any person obtaining a copy
6
+of this software and associated documentation files (the "Software"), to deal
7
+in the Software without restriction, including without limitation the rights
8
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+copies of the Software, and to permit persons to whom the Software is
10
+furnished to do so, subject to the following conditions:
11
+
12
+The above copyright notice and this permission notice shall be included in
13
+all copies or substantial portions of the Software.
14
+
15
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+THE SOFTWARE.

+ 509
- 0
vendor/src/github.com/sirupsen/logrus/README.md Visa fil

@@ -0,0 +1,509 @@
1
+# Logrus <img src="http://i.imgur.com/hTeVwmJ.png" width="40" height="40" alt=":walrus:" class="emoji" title=":walrus:"/>&nbsp;[![Build Status](https://travis-ci.org/sirupsen/logrus.svg?branch=master)](https://travis-ci.org/sirupsen/logrus)&nbsp;[![GoDoc](https://godoc.org/github.com/sirupsen/logrus?status.svg)](https://godoc.org/github.com/sirupsen/logrus)
2
+
3
+Logrus is a structured logger for Go (golang), completely API compatible with
4
+the standard library logger.
5
+
6
+**Seeing weird case-sensitive problems?** It's in the past been possible to
7
+import Logrus as both upper- and lower-case. Due to the Go package environment,
8
+this caused issues in the community and we needed a standard. Some environments
9
+experienced problems with the upper-case variant, so the lower-case was decided.
10
+Everything using `logrus` will need to use the lower-case:
11
+`github.com/sirupsen/logrus`. Any package that isn't, should be changed.
12
+
13
+To fix Glide, see [these
14
+comments](https://github.com/sirupsen/logrus/issues/553#issuecomment-306591437).
15
+For an in-depth explanation of the casing issue, see [this
16
+comment](https://github.com/sirupsen/logrus/issues/570#issuecomment-313933276).
17
+
18
+**Are you interested in assisting in maintaining Logrus?** Currently I have a
19
+lot of obligations, and I am unable to provide Logrus with the maintainership it
20
+needs. If you'd like to help, please reach out to me at `simon at author's
21
+username dot com`.
22
+
23
+Nicely color-coded in development (when a TTY is attached, otherwise just
24
+plain text):
25
+
26
+![Colored](http://i.imgur.com/PY7qMwd.png)
27
+
28
+With `log.SetFormatter(&log.JSONFormatter{})`, for easy parsing by logstash
29
+or Splunk:
30
+
31
+```json
32
+{"animal":"walrus","level":"info","msg":"A group of walrus emerges from the
33
+ocean","size":10,"time":"2014-03-10 19:57:38.562264131 -0400 EDT"}
34
+
35
+{"level":"warning","msg":"The group's number increased tremendously!",
36
+"number":122,"omg":true,"time":"2014-03-10 19:57:38.562471297 -0400 EDT"}
37
+
38
+{"animal":"walrus","level":"info","msg":"A giant walrus appears!",
39
+"size":10,"time":"2014-03-10 19:57:38.562500591 -0400 EDT"}
40
+
41
+{"animal":"walrus","level":"info","msg":"Tremendously sized cow enters the ocean.",
42
+"size":9,"time":"2014-03-10 19:57:38.562527896 -0400 EDT"}
43
+
44
+{"level":"fatal","msg":"The ice breaks!","number":100,"omg":true,
45
+"time":"2014-03-10 19:57:38.562543128 -0400 EDT"}
46
+```
47
+
48
+With the default `log.SetFormatter(&log.TextFormatter{})` when a TTY is not
49
+attached, the output is compatible with the
50
+[logfmt](http://godoc.org/github.com/kr/logfmt) format:
51
+
52
+```text
53
+time="2015-03-26T01:27:38-04:00" level=debug msg="Started observing beach" animal=walrus number=8
54
+time="2015-03-26T01:27:38-04:00" level=info msg="A group of walrus emerges from the ocean" animal=walrus size=10
55
+time="2015-03-26T01:27:38-04:00" level=warning msg="The group's number increased tremendously!" number=122 omg=true
56
+time="2015-03-26T01:27:38-04:00" level=debug msg="Temperature changes" temperature=-4
57
+time="2015-03-26T01:27:38-04:00" level=panic msg="It's over 9000!" animal=orca size=9009
58
+time="2015-03-26T01:27:38-04:00" level=fatal msg="The ice breaks!" err=&{0x2082280c0 map[animal:orca size:9009] 2015-03-26 01:27:38.441574009 -0400 EDT panic It's over 9000!} number=100 omg=true
59
+exit status 1
60
+```
61
+
62
+#### Case-sensitivity
63
+
64
+The organization's name was changed to lower-case--and this will not be changed
65
+back. If you are getting import conflicts due to case sensitivity, please use
66
+the lower-case import: `github.com/sirupsen/logrus`.
67
+
68
+#### Example
69
+
70
+The simplest way to use Logrus is simply the package-level exported logger:
71
+
72
+```go
73
+package main
74
+
75
+import (
76
+  log "github.com/sirupsen/logrus"
77
+)
78
+
79
+func main() {
80
+  log.WithFields(log.Fields{
81
+    "animal": "walrus",
82
+  }).Info("A walrus appears")
83
+}
84
+```
85
+
86
+Note that it's completely api-compatible with the stdlib logger, so you can
87
+replace your `log` imports everywhere with `log "github.com/sirupsen/logrus"`
88
+and you'll now have the flexibility of Logrus. You can customize it all you
89
+want:
90
+
91
+```go
92
+package main
93
+
94
+import (
95
+  "os"
96
+  log "github.com/sirupsen/logrus"
97
+)
98
+
99
+func init() {
100
+  // Log as JSON instead of the default ASCII formatter.
101
+  log.SetFormatter(&log.JSONFormatter{})
102
+
103
+  // Output to stdout instead of the default stderr
104
+  // Can be any io.Writer, see below for File example
105
+  log.SetOutput(os.Stdout)
106
+
107
+  // Only log the warning severity or above.
108
+  log.SetLevel(log.WarnLevel)
109
+}
110
+
111
+func main() {
112
+  log.WithFields(log.Fields{
113
+    "animal": "walrus",
114
+    "size":   10,
115
+  }).Info("A group of walrus emerges from the ocean")
116
+
117
+  log.WithFields(log.Fields{
118
+    "omg":    true,
119
+    "number": 122,
120
+  }).Warn("The group's number increased tremendously!")
121
+
122
+  log.WithFields(log.Fields{
123
+    "omg":    true,
124
+    "number": 100,
125
+  }).Fatal("The ice breaks!")
126
+
127
+  // A common pattern is to re-use fields between logging statements by re-using
128
+  // the logrus.Entry returned from WithFields()
129
+  contextLogger := log.WithFields(log.Fields{
130
+    "common": "this is a common field",
131
+    "other": "I also should be logged always",
132
+  })
133
+
134
+  contextLogger.Info("I'll be logged with common and other field")
135
+  contextLogger.Info("Me too")
136
+}
137
+```
138
+
139
+For more advanced usage such as logging to multiple locations from the same
140
+application, you can also create an instance of the `logrus` Logger:
141
+
142
+```go
143
+package main
144
+
145
+import (
146
+  "os"
147
+  "github.com/sirupsen/logrus"
148
+)
149
+
150
+// Create a new instance of the logger. You can have any number of instances.
151
+var log = logrus.New()
152
+
153
+func main() {
154
+  // The API for setting attributes is a little different than the package level
155
+  // exported logger. See Godoc.
156
+  log.Out = os.Stdout
157
+
158
+  // You could set this to any `io.Writer` such as a file
159
+  // file, err := os.OpenFile("logrus.log", os.O_CREATE|os.O_WRONLY, 0666)
160
+  // if err == nil {
161
+  //  log.Out = file
162
+  // } else {
163
+  //  log.Info("Failed to log to file, using default stderr")
164
+  // }
165
+
166
+  log.WithFields(logrus.Fields{
167
+    "animal": "walrus",
168
+    "size":   10,
169
+  }).Info("A group of walrus emerges from the ocean")
170
+}
171
+```
172
+
173
+#### Fields
174
+
175
+Logrus encourages careful, structured logging through logging fields instead of
176
+long, unparseable error messages. For example, instead of: `log.Fatalf("Failed
177
+to send event %s to topic %s with key %d")`, you should log the much more
178
+discoverable:
179
+
180
+```go
181
+log.WithFields(log.Fields{
182
+  "event": event,
183
+  "topic": topic,
184
+  "key": key,
185
+}).Fatal("Failed to send event")
186
+```
187
+
188
+We've found this API forces you to think about logging in a way that produces
189
+much more useful logging messages. We've been in countless situations where just
190
+a single added field to a log statement that was already there would've saved us
191
+hours. The `WithFields` call is optional.
192
+
193
+In general, with Logrus using any of the `printf`-family functions should be
194
+seen as a hint you should add a field, however, you can still use the
195
+`printf`-family functions with Logrus.
196
+
197
+#### Default Fields
198
+
199
+Often it's helpful to have fields _always_ attached to log statements in an
200
+application or parts of one. For example, you may want to always log the
201
+`request_id` and `user_ip` in the context of a request. Instead of writing
202
+`log.WithFields(log.Fields{"request_id": request_id, "user_ip": user_ip})` on
203
+every line, you can create a `logrus.Entry` to pass around instead:
204
+
205
+```go
206
+requestLogger := log.WithFields(log.Fields{"request_id": request_id, "user_ip": user_ip})
207
+requestLogger.Info("something happened on that request") # will log request_id and user_ip
208
+requestLogger.Warn("something not great happened")
209
+```
210
+
211
+#### Hooks
212
+
213
+You can add hooks for logging levels. For example to send errors to an exception
214
+tracking service on `Error`, `Fatal` and `Panic`, info to StatsD or log to
215
+multiple places simultaneously, e.g. syslog.
216
+
217
+Logrus comes with [built-in hooks](hooks/). Add those, or your custom hook, in
218
+`init`:
219
+
220
+```go
221
+import (
222
+  log "github.com/sirupsen/logrus"
223
+  "gopkg.in/gemnasium/logrus-airbrake-hook.v2" // the package is named "aibrake"
224
+  logrus_syslog "github.com/sirupsen/logrus/hooks/syslog"
225
+  "log/syslog"
226
+)
227
+
228
+func init() {
229
+
230
+  // Use the Airbrake hook to report errors that have Error severity or above to
231
+  // an exception tracker. You can create custom hooks, see the Hooks section.
232
+  log.AddHook(airbrake.NewHook(123, "xyz", "production"))
233
+
234
+  hook, err := logrus_syslog.NewSyslogHook("udp", "localhost:514", syslog.LOG_INFO, "")
235
+  if err != nil {
236
+    log.Error("Unable to connect to local syslog daemon")
237
+  } else {
238
+    log.AddHook(hook)
239
+  }
240
+}
241
+```
242
+Note: Syslog hook also support connecting to local syslog (Ex. "/dev/log" or "/var/run/syslog" or "/var/run/log"). For the detail, please check the [syslog hook README](hooks/syslog/README.md).
243
+
244
+| Hook  | Description |
245
+| ----- | ----------- |
246
+| [Airbrake "legacy"](https://github.com/gemnasium/logrus-airbrake-legacy-hook) | Send errors to an exception tracking service compatible with the Airbrake API V2. Uses [`airbrake-go`](https://github.com/tobi/airbrake-go) behind the scenes. |
247
+| [Airbrake](https://github.com/gemnasium/logrus-airbrake-hook) | Send errors to the Airbrake API V3. Uses the official [`gobrake`](https://github.com/airbrake/gobrake) behind the scenes. |
248
+| [Amazon Kinesis](https://github.com/evalphobia/logrus_kinesis) | Hook for logging to [Amazon Kinesis](https://aws.amazon.com/kinesis/) |
249
+| [Amqp-Hook](https://github.com/vladoatanasov/logrus_amqp) | Hook for logging to Amqp broker (Like RabbitMQ) |
250
+| [AzureTableHook](https://github.com/kpfaulkner/azuretablehook/) | Hook for logging to Azure Table Storage|
251
+| [Bugsnag](https://github.com/Shopify/logrus-bugsnag/blob/master/bugsnag.go) | Send errors to the Bugsnag exception tracking service. |
252
+| [DeferPanic](https://github.com/deferpanic/dp-logrus) | Hook for logging to DeferPanic |
253
+| [Discordrus](https://github.com/kz/discordrus) | Hook for logging to [Discord](https://discordapp.com/) |
254
+| [ElasticSearch](https://github.com/sohlich/elogrus) | Hook for logging to ElasticSearch|
255
+| [Firehose](https://github.com/beaubrewer/logrus_firehose) | Hook for logging to [Amazon Firehose](https://aws.amazon.com/kinesis/firehose/)
256
+| [Fluentd](https://github.com/evalphobia/logrus_fluent) | Hook for logging to fluentd |
257
+| [Go-Slack](https://github.com/multiplay/go-slack) | Hook for logging to [Slack](https://slack.com) |
258
+| [Graylog](https://github.com/gemnasium/logrus-graylog-hook) | Hook for logging to [Graylog](http://graylog2.org/) |
259
+| [Hiprus](https://github.com/nubo/hiprus) | Send errors to a channel in hipchat. |
260
+| [Honeybadger](https://github.com/agonzalezro/logrus_honeybadger) | Hook for sending exceptions to Honeybadger |
261
+| [InfluxDB](https://github.com/Abramovic/logrus_influxdb) | Hook for logging to influxdb |
262
+| [Influxus](http://github.com/vlad-doru/influxus) | Hook for concurrently logging to [InfluxDB](http://influxdata.com/) |
263
+| [Journalhook](https://github.com/wercker/journalhook) | Hook for logging to `systemd-journald` |
264
+| [KafkaLogrus](https://github.com/tracer0tong/kafkalogrus) | Hook for logging to Kafka |
265
+| [LFShook](https://github.com/rifflock/lfshook) | Hook for logging to the local filesystem |
266
+| [Logbeat](https://github.com/macandmia/logbeat) | Hook for logging to [Opbeat](https://opbeat.com/) |
267
+| [Logentries](https://github.com/jcftang/logentriesrus) | Hook for logging to [Logentries](https://logentries.com/) |
268
+| [Logentrus](https://github.com/puddingfactory/logentrus) | Hook for logging to [Logentries](https://logentries.com/) |
269
+| [Logmatic.io](https://github.com/logmatic/logmatic-go) | Hook for logging to [Logmatic.io](http://logmatic.io/) |
270
+| [Logrusly](https://github.com/sebest/logrusly) | Send logs to [Loggly](https://www.loggly.com/) |
271
+| [Logstash](https://github.com/bshuster-repo/logrus-logstash-hook) | Hook for logging to [Logstash](https://www.elastic.co/products/logstash) |
272
+| [Mail](https://github.com/zbindenren/logrus_mail) | Hook for sending exceptions via mail |
273
+| [Mattermost](https://github.com/shuLhan/mattermost-integration/tree/master/hooks/logrus) | Hook for logging to [Mattermost](https://mattermost.com/) |
274
+| [Mongodb](https://github.com/weekface/mgorus) | Hook for logging to mongodb |
275
+| [NATS-Hook](https://github.com/rybit/nats_logrus_hook) | Hook for logging to [NATS](https://nats.io) |
276
+| [Octokit](https://github.com/dorajistyle/logrus-octokit-hook) | Hook for logging to github via octokit |
277
+| [Papertrail](https://github.com/polds/logrus-papertrail-hook) | Send errors to the [Papertrail](https://papertrailapp.com) hosted logging service via UDP. |
278
+| [PostgreSQL](https://github.com/gemnasium/logrus-postgresql-hook) | Send logs to [PostgreSQL](http://postgresql.org) |
279
+| [Promrus](https://github.com/weaveworks/promrus) | Expose number of log messages as [Prometheus](https://prometheus.io/) metrics |
280
+| [Pushover](https://github.com/toorop/logrus_pushover) | Send error via [Pushover](https://pushover.net) |
281
+| [Raygun](https://github.com/squirkle/logrus-raygun-hook) | Hook for logging to [Raygun.io](http://raygun.io/) |
282
+| [Redis-Hook](https://github.com/rogierlommers/logrus-redis-hook) | Hook for logging to a ELK stack (through Redis) |
283
+| [Rollrus](https://github.com/heroku/rollrus) | Hook for sending errors to rollbar |
284
+| [Scribe](https://github.com/sagar8192/logrus-scribe-hook) | Hook for logging to [Scribe](https://github.com/facebookarchive/scribe)|
285
+| [Sentry](https://github.com/evalphobia/logrus_sentry) | Send errors to the Sentry error logging and aggregation service. |
286
+| [Slackrus](https://github.com/johntdyer/slackrus) | Hook for Slack chat. |
287
+| [Stackdriver](https://github.com/knq/sdhook) | Hook for logging to [Google Stackdriver](https://cloud.google.com/logging/) |
288
+| [Sumorus](https://github.com/doublefree/sumorus) | Hook for logging to [SumoLogic](https://www.sumologic.com/)|
289
+| [Syslog](https://github.com/sirupsen/logrus/blob/master/hooks/syslog/syslog.go) | Send errors to remote syslog server. Uses standard library `log/syslog` behind the scenes. |
290
+| [Syslog TLS](https://github.com/shinji62/logrus-syslog-ng) | Send errors to remote syslog server with TLS support. |
291
+| [Telegram](https://github.com/rossmcdonald/telegram_hook) | Hook for logging errors to [Telegram](https://telegram.org/) |
292
+| [TraceView](https://github.com/evalphobia/logrus_appneta) | Hook for logging to [AppNeta TraceView](https://www.appneta.com/products/traceview/) |
293
+| [Typetalk](https://github.com/dragon3/logrus-typetalk-hook) | Hook for logging to [Typetalk](https://www.typetalk.in/) |
294
+| [logz.io](https://github.com/ripcurld00d/logrus-logzio-hook) | Hook for logging to [logz.io](https://logz.io), a Log as a Service using Logstash |
295
+| [SQS-Hook](https://github.com/tsarpaul/logrus_sqs) | Hook for logging to [Amazon Simple Queue Service (SQS)](https://aws.amazon.com/sqs/) |
296
+
297
+#### Level logging
298
+
299
+Logrus has six logging levels: Debug, Info, Warning, Error, Fatal and Panic.
300
+
301
+```go
302
+log.Debug("Useful debugging information.")
303
+log.Info("Something noteworthy happened!")
304
+log.Warn("You should probably take a look at this.")
305
+log.Error("Something failed but I'm not quitting.")
306
+// Calls os.Exit(1) after logging
307
+log.Fatal("Bye.")
308
+// Calls panic() after logging
309
+log.Panic("I'm bailing.")
310
+```
311
+
312
+You can set the logging level on a `Logger`, then it will only log entries with
313
+that severity or anything above it:
314
+
315
+```go
316
+// Will log anything that is info or above (warn, error, fatal, panic). Default.
317
+log.SetLevel(log.InfoLevel)
318
+```
319
+
320
+It may be useful to set `log.Level = logrus.DebugLevel` in a debug or verbose
321
+environment if your application has that.
322
+
323
+#### Entries
324
+
325
+Besides the fields added with `WithField` or `WithFields` some fields are
326
+automatically added to all logging events:
327
+
328
+1. `time`. The timestamp when the entry was created.
329
+2. `msg`. The logging message passed to `{Info,Warn,Error,Fatal,Panic}` after
330
+   the `AddFields` call. E.g. `Failed to send event.`
331
+3. `level`. The logging level. E.g. `info`.
332
+
333
+#### Environments
334
+
335
+Logrus has no notion of environment.
336
+
337
+If you wish for hooks and formatters to only be used in specific environments,
338
+you should handle that yourself. For example, if your application has a global
339
+variable `Environment`, which is a string representation of the environment you
340
+could do:
341
+
342
+```go
343
+import (
344
+  log "github.com/sirupsen/logrus"
345
+)
346
+
347
+init() {
348
+  // do something here to set environment depending on an environment variable
349
+  // or command-line flag
350
+  if Environment == "production" {
351
+    log.SetFormatter(&log.JSONFormatter{})
352
+  } else {
353
+    // The TextFormatter is default, you don't actually have to do this.
354
+    log.SetFormatter(&log.TextFormatter{})
355
+  }
356
+}
357
+```
358
+
359
+This configuration is how `logrus` was intended to be used, but JSON in
360
+production is mostly only useful if you do log aggregation with tools like
361
+Splunk or Logstash.
362
+
363
+#### Formatters
364
+
365
+The built-in logging formatters are:
366
+
367
+* `logrus.TextFormatter`. Logs the event in colors if stdout is a tty, otherwise
368
+  without colors.
369
+  * *Note:* to force colored output when there is no TTY, set the `ForceColors`
370
+    field to `true`.  To force no colored output even if there is a TTY  set the
371
+    `DisableColors` field to `true`. For Windows, see
372
+    [github.com/mattn/go-colorable](https://github.com/mattn/go-colorable).
373
+  * All options are listed in the [generated docs](https://godoc.org/github.com/sirupsen/logrus#TextFormatter).
374
+* `logrus.JSONFormatter`. Logs fields as JSON.
375
+  * All options are listed in the [generated docs](https://godoc.org/github.com/sirupsen/logrus#JSONFormatter).
376
+
377
+Third party logging formatters:
378
+
379
+* [`FluentdFormatter`](https://github.com/joonix/log). Formats entries that can be parsed by Kubernetes and Google Container Engine.
380
+* [`logstash`](https://github.com/bshuster-repo/logrus-logstash-hook). Logs fields as [Logstash](http://logstash.net) Events.
381
+* [`prefixed`](https://github.com/x-cray/logrus-prefixed-formatter). Displays log entry source along with alternative layout.
382
+* [`zalgo`](https://github.com/aybabtme/logzalgo). Invoking the P͉̫o̳̼̊w̖͈̰͎e̬͔̭͂r͚̼̹̲ ̫͓͉̳͈ō̠͕͖̚f̝͍̠ ͕̲̞͖͑Z̖̫̤̫ͪa͉̬͈̗l͖͎g̳̥o̰̥̅!̣͔̲̻͊̄ ̙̘̦̹̦.
383
+
384
+You can define your formatter by implementing the `Formatter` interface,
385
+requiring a `Format` method. `Format` takes an `*Entry`. `entry.Data` is a
386
+`Fields` type (`map[string]interface{}`) with all your fields as well as the
387
+default ones (see Entries section above):
388
+
389
+```go
390
+type MyJSONFormatter struct {
391
+}
392
+
393
+log.SetFormatter(new(MyJSONFormatter))
394
+
395
+func (f *MyJSONFormatter) Format(entry *Entry) ([]byte, error) {
396
+  // Note this doesn't include Time, Level and Message which are available on
397
+  // the Entry. Consult `godoc` on information about those fields or read the
398
+  // source of the official loggers.
399
+  serialized, err := json.Marshal(entry.Data)
400
+    if err != nil {
401
+      return nil, fmt.Errorf("Failed to marshal fields to JSON, %v", err)
402
+    }
403
+  return append(serialized, '\n'), nil
404
+}
405
+```
406
+
407
+#### Logger as an `io.Writer`
408
+
409
+Logrus can be transformed into an `io.Writer`. That writer is the end of an `io.Pipe` and it is your responsibility to close it.
410
+
411
+```go
412
+w := logger.Writer()
413
+defer w.Close()
414
+
415
+srv := http.Server{
416
+    // create a stdlib log.Logger that writes to
417
+    // logrus.Logger.
418
+    ErrorLog: log.New(w, "", 0),
419
+}
420
+```
421
+
422
+Each line written to that writer will be printed the usual way, using formatters
423
+and hooks. The level for those entries is `info`.
424
+
425
+This means that we can override the standard library logger easily:
426
+
427
+```go
428
+logger := logrus.New()
429
+logger.Formatter = &logrus.JSONFormatter{}
430
+
431
+// Use logrus for standard log output
432
+// Note that `log` here references stdlib's log
433
+// Not logrus imported under the name `log`.
434
+log.SetOutput(logger.Writer())
435
+```
436
+
437
+#### Rotation
438
+
439
+Log rotation is not provided with Logrus. Log rotation should be done by an
440
+external program (like `logrotate(8)`) that can compress and delete old log
441
+entries. It should not be a feature of the application-level logger.
442
+
443
+#### Tools
444
+
445
+| Tool | Description |
446
+| ---- | ----------- |
447
+|[Logrus Mate](https://github.com/gogap/logrus_mate)|Logrus mate is a tool for Logrus to manage loggers, you can initial logger's level, hook and formatter by config file, the logger will generated with different config at different environment.|
448
+|[Logrus Viper Helper](https://github.com/heirko/go-contrib/tree/master/logrusHelper)|An Helper around Logrus to wrap with spf13/Viper to load configuration with fangs! And to simplify Logrus configuration use some behavior of [Logrus Mate](https://github.com/gogap/logrus_mate). [sample](https://github.com/heirko/iris-contrib/blob/master/middleware/logrus-logger/example) |
449
+
450
+#### Testing
451
+
452
+Logrus has a built in facility for asserting the presence of log messages. This is implemented through the `test` hook and provides:
453
+
454
+* decorators for existing logger (`test.NewLocal` and `test.NewGlobal`) which basically just add the `test` hook
455
+* a test logger (`test.NewNullLogger`) that just records log messages (and does not output any):
456
+
457
+```go
458
+import(
459
+  "github.com/sirupsen/logrus"
460
+  "github.com/sirupsen/logrus/hooks/test"
461
+  "github.com/stretchr/testify/assert"
462
+  "testing"
463
+)
464
+
465
+func TestSomething(t*testing.T){
466
+  logger, hook := test.NewNullLogger()
467
+  logger.Error("Helloerror")
468
+
469
+  assert.Equal(t, 1, len(hook.Entries))
470
+  assert.Equal(t, logrus.ErrorLevel, hook.LastEntry().Level)
471
+  assert.Equal(t, "Helloerror", hook.LastEntry().Message)
472
+
473
+  hook.Reset()
474
+  assert.Nil(t, hook.LastEntry())
475
+}
476
+```
477
+
478
+#### Fatal handlers
479
+
480
+Logrus can register one or more functions that will be called when any `fatal`
481
+level message is logged. The registered handlers will be executed before
482
+logrus performs a `os.Exit(1)`. This behavior may be helpful if callers need
483
+to gracefully shutdown. Unlike a `panic("Something went wrong...")` call which can be intercepted with a deferred `recover` a call to `os.Exit(1)` can not be intercepted.
484
+
485
+```
486
+...
487
+handler := func() {
488
+  // gracefully shutdown something...
489
+}
490
+logrus.RegisterExitHandler(handler)
491
+...
492
+```
493
+
494
+#### Thread safety
495
+
496
+By default Logger is protected by mutex for concurrent writes, this mutex is invoked when calling hooks and writing logs.
497
+If you are sure such locking is not needed, you can call logger.SetNoLock() to disable the locking.
498
+
499
+Situation when locking is not needed includes:
500
+
501
+* You have no hooks registered, or hooks calling is already thread-safe.
502
+
503
+* Writing to logger.Out is already thread-safe, for example:
504
+
505
+  1) logger.Out is protected by locks.
506
+
507
+  2) logger.Out is a os.File handler opened with `O_APPEND` flag, and every write is smaller than 4k. (This allow multi-thread/multi-process writing)
508
+
509
+     (Refer to http://www.notthewizard.com/2014/06/17/are-files-appends-really-atomic/)

+ 64
- 0
vendor/src/github.com/sirupsen/logrus/alt_exit.go Visa fil

@@ -0,0 +1,64 @@
1
+package logrus
2
+
3
+// The following code was sourced and modified from the
4
+// https://github.com/tebeka/atexit package governed by the following license:
5
+//
6
+// Copyright (c) 2012 Miki Tebeka <miki.tebeka@gmail.com>.
7
+//
8
+// Permission is hereby granted, free of charge, to any person obtaining a copy of
9
+// this software and associated documentation files (the "Software"), to deal in
10
+// the Software without restriction, including without limitation the rights to
11
+// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
12
+// the Software, and to permit persons to whom the Software is furnished to do so,
13
+// subject to the following conditions:
14
+//
15
+// The above copyright notice and this permission notice shall be included in all
16
+// copies or substantial portions of the Software.
17
+//
18
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
20
+// FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
21
+// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
22
+// IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
23
+// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24
+
25
+import (
26
+	"fmt"
27
+	"os"
28
+)
29
+
30
+var handlers = []func(){}
31
+
32
+func runHandler(handler func()) {
33
+	defer func() {
34
+		if err := recover(); err != nil {
35
+			fmt.Fprintln(os.Stderr, "Error: Logrus exit handler error:", err)
36
+		}
37
+	}()
38
+
39
+	handler()
40
+}
41
+
42
+func runHandlers() {
43
+	for _, handler := range handlers {
44
+		runHandler(handler)
45
+	}
46
+}
47
+
48
+// Exit runs all the Logrus atexit handlers and then terminates the program using os.Exit(code)
49
+func Exit(code int) {
50
+	runHandlers()
51
+	os.Exit(code)
52
+}
53
+
54
+// RegisterExitHandler adds a Logrus Exit handler, call logrus.Exit to invoke
55
+// all handlers. The handlers will also be invoked when any Fatal log entry is
56
+// made.
57
+//
58
+// This method is useful when a caller wishes to use logrus to log a fatal
59
+// message but also needs to gracefully shutdown. An example usecase could be
60
+// closing database connections, or sending a alert that the application is
61
+// closing.
62
+func RegisterExitHandler(handler func()) {
63
+	handlers = append(handlers, handler)
64
+}

+ 83
- 0
vendor/src/github.com/sirupsen/logrus/alt_exit_test.go Visa fil

@@ -0,0 +1,83 @@
1
+package logrus
2
+
3
+import (
4
+	"io/ioutil"
5
+	"log"
6
+	"os"
7
+	"os/exec"
8
+	"path/filepath"
9
+	"testing"
10
+	"time"
11
+)
12
+
13
+func TestRegister(t *testing.T) {
14
+	current := len(handlers)
15
+	RegisterExitHandler(func() {})
16
+	if len(handlers) != current+1 {
17
+		t.Fatalf("expected %d handlers, got %d", current+1, len(handlers))
18
+	}
19
+}
20
+
21
+func TestHandler(t *testing.T) {
22
+	tempDir, err := ioutil.TempDir("", "test_handler")
23
+	if err != nil {
24
+		log.Fatalf("can't create temp dir. %q", err)
25
+	}
26
+	defer os.RemoveAll(tempDir)
27
+
28
+	gofile := filepath.Join(tempDir, "gofile.go")
29
+	if err := ioutil.WriteFile(gofile, testprog, 0666); err != nil {
30
+		t.Fatalf("can't create go file. %q", err)
31
+	}
32
+
33
+	outfile := filepath.Join(tempDir, "outfile.out")
34
+	arg := time.Now().UTC().String()
35
+	err = exec.Command("go", "run", gofile, outfile, arg).Run()
36
+	if err == nil {
37
+		t.Fatalf("completed normally, should have failed")
38
+	}
39
+
40
+	data, err := ioutil.ReadFile(outfile)
41
+	if err != nil {
42
+		t.Fatalf("can't read output file %s. %q", outfile, err)
43
+	}
44
+
45
+	if string(data) != arg {
46
+		t.Fatalf("bad data. Expected %q, got %q", data, arg)
47
+	}
48
+}
49
+
50
+var testprog = []byte(`
51
+// Test program for atexit, gets output file and data as arguments and writes
52
+// data to output file in atexit handler.
53
+package main
54
+
55
+import (
56
+	"github.com/sirupsen/logrus"
57
+	"flag"
58
+	"fmt"
59
+	"io/ioutil"
60
+)
61
+
62
+var outfile = ""
63
+var data = ""
64
+
65
+func handler() {
66
+	ioutil.WriteFile(outfile, []byte(data), 0666)
67
+}
68
+
69
+func badHandler() {
70
+	n := 0
71
+	fmt.Println(1/n)
72
+}
73
+
74
+func main() {
75
+	flag.Parse()
76
+	outfile = flag.Arg(0)
77
+	data = flag.Arg(1)
78
+
79
+	logrus.RegisterExitHandler(handler)
80
+	logrus.RegisterExitHandler(badHandler)
81
+	logrus.Fatal("Bye bye")
82
+}
83
+`)

+ 14
- 0
vendor/src/github.com/sirupsen/logrus/appveyor.yml Visa fil

@@ -0,0 +1,14 @@
1
+version: "{build}"
2
+platform: x64
3
+clone_folder: c:\gopath\src\github.com\sirupsen\logrus
4
+environment:  
5
+  GOPATH: c:\gopath
6
+branches:  
7
+  only:
8
+    - master
9
+install:  
10
+  - set PATH=%GOPATH%\bin;c:\go\bin;%PATH%
11
+  - go version
12
+build_script:  
13
+  - go get -t
14
+  - go test

+ 26
- 0
vendor/src/github.com/sirupsen/logrus/doc.go Visa fil

@@ -0,0 +1,26 @@
1
+/*
2
+Package logrus is a structured logger for Go, completely API compatible with the standard library logger.
3
+
4
+
5
+The simplest way to use Logrus is simply the package-level exported logger:
6
+
7
+  package main
8
+
9
+  import (
10
+    log "github.com/sirupsen/logrus"
11
+  )
12
+
13
+  func main() {
14
+    log.WithFields(log.Fields{
15
+      "animal": "walrus",
16
+      "number": 1,
17
+      "size":   10,
18
+    }).Info("A walrus appears")
19
+  }
20
+
21
+Output:
22
+  time="2015-09-07T08:48:33Z" level=info msg="A walrus appears" animal=walrus number=1 size=10
23
+
24
+For a full guide visit https://github.com/sirupsen/logrus
25
+*/
26
+package logrus

+ 279
- 0
vendor/src/github.com/sirupsen/logrus/entry.go Visa fil

@@ -0,0 +1,279 @@
1
+package logrus
2
+
3
+import (
4
+	"bytes"
5
+	"fmt"
6
+	"os"
7
+	"sync"
8
+	"time"
9
+)
10
+
11
+var bufferPool *sync.Pool
12
+
13
+func init() {
14
+	bufferPool = &sync.Pool{
15
+		New: func() interface{} {
16
+			return new(bytes.Buffer)
17
+		},
18
+	}
19
+}
20
+
21
+// Defines the key when adding errors using WithError.
22
+var ErrorKey = "error"
23
+
24
+// An entry is the final or intermediate Logrus logging entry. It contains all
25
+// the fields passed with WithField{,s}. It's finally logged when Debug, Info,
26
+// Warn, Error, Fatal or Panic is called on it. These objects can be reused and
27
+// passed around as much as you wish to avoid field duplication.
28
+type Entry struct {
29
+	Logger *Logger
30
+
31
+	// Contains all the fields set by the user.
32
+	Data Fields
33
+
34
+	// Time at which the log entry was created
35
+	Time time.Time
36
+
37
+	// Level the log entry was logged at: Debug, Info, Warn, Error, Fatal or Panic
38
+	// This field will be set on entry firing and the value will be equal to the one in Logger struct field.
39
+	Level Level
40
+
41
+	// Message passed to Debug, Info, Warn, Error, Fatal or Panic
42
+	Message string
43
+
44
+	// When formatter is called in entry.log(), an Buffer may be set to entry
45
+	Buffer *bytes.Buffer
46
+}
47
+
48
+func NewEntry(logger *Logger) *Entry {
49
+	return &Entry{
50
+		Logger: logger,
51
+		// Default is three fields, give a little extra room
52
+		Data: make(Fields, 5),
53
+	}
54
+}
55
+
56
+// Returns the string representation from the reader and ultimately the
57
+// formatter.
58
+func (entry *Entry) String() (string, error) {
59
+	serialized, err := entry.Logger.Formatter.Format(entry)
60
+	if err != nil {
61
+		return "", err
62
+	}
63
+	str := string(serialized)
64
+	return str, nil
65
+}
66
+
67
+// Add an error as single field (using the key defined in ErrorKey) to the Entry.
68
+func (entry *Entry) WithError(err error) *Entry {
69
+	return entry.WithField(ErrorKey, err)
70
+}
71
+
72
+// Add a single field to the Entry.
73
+func (entry *Entry) WithField(key string, value interface{}) *Entry {
74
+	return entry.WithFields(Fields{key: value})
75
+}
76
+
77
+// Add a map of fields to the Entry.
78
+func (entry *Entry) WithFields(fields Fields) *Entry {
79
+	data := make(Fields, len(entry.Data)+len(fields))
80
+	for k, v := range entry.Data {
81
+		data[k] = v
82
+	}
83
+	for k, v := range fields {
84
+		data[k] = v
85
+	}
86
+	return &Entry{Logger: entry.Logger, Data: data}
87
+}
88
+
89
+// This function is not declared with a pointer value because otherwise
90
+// race conditions will occur when using multiple goroutines
91
+func (entry Entry) log(level Level, msg string) {
92
+	var buffer *bytes.Buffer
93
+	entry.Time = time.Now()
94
+	entry.Level = level
95
+	entry.Message = msg
96
+
97
+	entry.Logger.mu.Lock()
98
+	err := entry.Logger.Hooks.Fire(level, &entry)
99
+	entry.Logger.mu.Unlock()
100
+	if err != nil {
101
+		entry.Logger.mu.Lock()
102
+		fmt.Fprintf(os.Stderr, "Failed to fire hook: %v\n", err)
103
+		entry.Logger.mu.Unlock()
104
+	}
105
+	buffer = bufferPool.Get().(*bytes.Buffer)
106
+	buffer.Reset()
107
+	defer bufferPool.Put(buffer)
108
+	entry.Buffer = buffer
109
+	serialized, err := entry.Logger.Formatter.Format(&entry)
110
+	entry.Buffer = nil
111
+	if err != nil {
112
+		entry.Logger.mu.Lock()
113
+		fmt.Fprintf(os.Stderr, "Failed to obtain reader, %v\n", err)
114
+		entry.Logger.mu.Unlock()
115
+	} else {
116
+		entry.Logger.mu.Lock()
117
+		_, err = entry.Logger.Out.Write(serialized)
118
+		if err != nil {
119
+			fmt.Fprintf(os.Stderr, "Failed to write to log, %v\n", err)
120
+		}
121
+		entry.Logger.mu.Unlock()
122
+	}
123
+
124
+	// To avoid Entry#log() returning a value that only would make sense for
125
+	// panic() to use in Entry#Panic(), we avoid the allocation by checking
126
+	// directly here.
127
+	if level <= PanicLevel {
128
+		panic(&entry)
129
+	}
130
+}
131
+
132
+func (entry *Entry) Debug(args ...interface{}) {
133
+	if entry.Logger.level() >= DebugLevel {
134
+		entry.log(DebugLevel, fmt.Sprint(args...))
135
+	}
136
+}
137
+
138
+func (entry *Entry) Print(args ...interface{}) {
139
+	entry.Info(args...)
140
+}
141
+
142
+func (entry *Entry) Info(args ...interface{}) {
143
+	if entry.Logger.level() >= InfoLevel {
144
+		entry.log(InfoLevel, fmt.Sprint(args...))
145
+	}
146
+}
147
+
148
+func (entry *Entry) Warn(args ...interface{}) {
149
+	if entry.Logger.level() >= WarnLevel {
150
+		entry.log(WarnLevel, fmt.Sprint(args...))
151
+	}
152
+}
153
+
154
+func (entry *Entry) Warning(args ...interface{}) {
155
+	entry.Warn(args...)
156
+}
157
+
158
+func (entry *Entry) Error(args ...interface{}) {
159
+	if entry.Logger.level() >= ErrorLevel {
160
+		entry.log(ErrorLevel, fmt.Sprint(args...))
161
+	}
162
+}
163
+
164
+func (entry *Entry) Fatal(args ...interface{}) {
165
+	if entry.Logger.level() >= FatalLevel {
166
+		entry.log(FatalLevel, fmt.Sprint(args...))
167
+	}
168
+	Exit(1)
169
+}
170
+
171
+func (entry *Entry) Panic(args ...interface{}) {
172
+	if entry.Logger.level() >= PanicLevel {
173
+		entry.log(PanicLevel, fmt.Sprint(args...))
174
+	}
175
+	panic(fmt.Sprint(args...))
176
+}
177
+
178
+// Entry Printf family functions
179
+
180
+func (entry *Entry) Debugf(format string, args ...interface{}) {
181
+	if entry.Logger.level() >= DebugLevel {
182
+		entry.Debug(fmt.Sprintf(format, args...))
183
+	}
184
+}
185
+
186
+func (entry *Entry) Infof(format string, args ...interface{}) {
187
+	if entry.Logger.level() >= InfoLevel {
188
+		entry.Info(fmt.Sprintf(format, args...))
189
+	}
190
+}
191
+
192
+func (entry *Entry) Printf(format string, args ...interface{}) {
193
+	entry.Infof(format, args...)
194
+}
195
+
196
+func (entry *Entry) Warnf(format string, args ...interface{}) {
197
+	if entry.Logger.level() >= WarnLevel {
198
+		entry.Warn(fmt.Sprintf(format, args...))
199
+	}
200
+}
201
+
202
+func (entry *Entry) Warningf(format string, args ...interface{}) {
203
+	entry.Warnf(format, args...)
204
+}
205
+
206
+func (entry *Entry) Errorf(format string, args ...interface{}) {
207
+	if entry.Logger.level() >= ErrorLevel {
208
+		entry.Error(fmt.Sprintf(format, args...))
209
+	}
210
+}
211
+
212
+func (entry *Entry) Fatalf(format string, args ...interface{}) {
213
+	if entry.Logger.level() >= FatalLevel {
214
+		entry.Fatal(fmt.Sprintf(format, args...))
215
+	}
216
+	Exit(1)
217
+}
218
+
219
+func (entry *Entry) Panicf(format string, args ...interface{}) {
220
+	if entry.Logger.level() >= PanicLevel {
221
+		entry.Panic(fmt.Sprintf(format, args...))
222
+	}
223
+}
224
+
225
+// Entry Println family functions
226
+
227
+func (entry *Entry) Debugln(args ...interface{}) {
228
+	if entry.Logger.level() >= DebugLevel {
229
+		entry.Debug(entry.sprintlnn(args...))
230
+	}
231
+}
232
+
233
+func (entry *Entry) Infoln(args ...interface{}) {
234
+	if entry.Logger.level() >= InfoLevel {
235
+		entry.Info(entry.sprintlnn(args...))
236
+	}
237
+}
238
+
239
+func (entry *Entry) Println(args ...interface{}) {
240
+	entry.Infoln(args...)
241
+}
242
+
243
+func (entry *Entry) Warnln(args ...interface{}) {
244
+	if entry.Logger.level() >= WarnLevel {
245
+		entry.Warn(entry.sprintlnn(args...))
246
+	}
247
+}
248
+
249
+func (entry *Entry) Warningln(args ...interface{}) {
250
+	entry.Warnln(args...)
251
+}
252
+
253
+func (entry *Entry) Errorln(args ...interface{}) {
254
+	if entry.Logger.level() >= ErrorLevel {
255
+		entry.Error(entry.sprintlnn(args...))
256
+	}
257
+}
258
+
259
+func (entry *Entry) Fatalln(args ...interface{}) {
260
+	if entry.Logger.level() >= FatalLevel {
261
+		entry.Fatal(entry.sprintlnn(args...))
262
+	}
263
+	Exit(1)
264
+}
265
+
266
+func (entry *Entry) Panicln(args ...interface{}) {
267
+	if entry.Logger.level() >= PanicLevel {
268
+		entry.Panic(entry.sprintlnn(args...))
269
+	}
270
+}
271
+
272
+// Sprintlnn => Sprint no newline. This is to get the behavior of how
273
+// fmt.Sprintln where spaces are always added between operands, regardless of
274
+// their type. Instead of vendoring the Sprintln implementation to spare a
275
+// string allocation, we do the simplest thing.
276
+func (entry *Entry) sprintlnn(args ...interface{}) string {
277
+	msg := fmt.Sprintln(args...)
278
+	return msg[:len(msg)-1]
279
+}

+ 77
- 0
vendor/src/github.com/sirupsen/logrus/entry_test.go Visa fil

@@ -0,0 +1,77 @@
1
+package logrus
2
+
3
+import (
4
+	"bytes"
5
+	"fmt"
6
+	"testing"
7
+
8
+	"github.com/stretchr/testify/assert"
9
+)
10
+
11
+func TestEntryWithError(t *testing.T) {
12
+
13
+	assert := assert.New(t)
14
+
15
+	defer func() {
16
+		ErrorKey = "error"
17
+	}()
18
+
19
+	err := fmt.Errorf("kaboom at layer %d", 4711)
20
+
21
+	assert.Equal(err, WithError(err).Data["error"])
22
+
23
+	logger := New()
24
+	logger.Out = &bytes.Buffer{}
25
+	entry := NewEntry(logger)
26
+
27
+	assert.Equal(err, entry.WithError(err).Data["error"])
28
+
29
+	ErrorKey = "err"
30
+
31
+	assert.Equal(err, entry.WithError(err).Data["err"])
32
+
33
+}
34
+
35
+func TestEntryPanicln(t *testing.T) {
36
+	errBoom := fmt.Errorf("boom time")
37
+
38
+	defer func() {
39
+		p := recover()
40
+		assert.NotNil(t, p)
41
+
42
+		switch pVal := p.(type) {
43
+		case *Entry:
44
+			assert.Equal(t, "kaboom", pVal.Message)
45
+			assert.Equal(t, errBoom, pVal.Data["err"])
46
+		default:
47
+			t.Fatalf("want type *Entry, got %T: %#v", pVal, pVal)
48
+		}
49
+	}()
50
+
51
+	logger := New()
52
+	logger.Out = &bytes.Buffer{}
53
+	entry := NewEntry(logger)
54
+	entry.WithField("err", errBoom).Panicln("kaboom")
55
+}
56
+
57
+func TestEntryPanicf(t *testing.T) {
58
+	errBoom := fmt.Errorf("boom again")
59
+
60
+	defer func() {
61
+		p := recover()
62
+		assert.NotNil(t, p)
63
+
64
+		switch pVal := p.(type) {
65
+		case *Entry:
66
+			assert.Equal(t, "kaboom true", pVal.Message)
67
+			assert.Equal(t, errBoom, pVal.Data["err"])
68
+		default:
69
+			t.Fatalf("want type *Entry, got %T: %#v", pVal, pVal)
70
+		}
71
+	}()
72
+
73
+	logger := New()
74
+	logger.Out = &bytes.Buffer{}
75
+	entry := NewEntry(logger)
76
+	entry.WithField("err", errBoom).Panicf("kaboom %v", true)
77
+}

+ 69
- 0
vendor/src/github.com/sirupsen/logrus/example_basic_test.go Visa fil

@@ -0,0 +1,69 @@
1
+package logrus_test
2
+
3
+import (
4
+	"github.com/sirupsen/logrus"
5
+	"os"
6
+)
7
+
8
+func Example_basic() {
9
+	var log = logrus.New()
10
+	log.Formatter = new(logrus.JSONFormatter)
11
+	log.Formatter = new(logrus.TextFormatter)                     //default
12
+	log.Formatter.(*logrus.TextFormatter).DisableTimestamp = true // remove timestamp from test output
13
+	log.Level = logrus.DebugLevel
14
+	log.Out = os.Stdout
15
+
16
+	// file, err := os.OpenFile("logrus.log", os.O_CREATE|os.O_WRONLY, 0666)
17
+	// if err == nil {
18
+	// 	log.Out = file
19
+	// } else {
20
+	// 	log.Info("Failed to log to file, using default stderr")
21
+	// }
22
+
23
+	defer func() {
24
+		err := recover()
25
+		if err != nil {
26
+			entry := err.(*logrus.Entry)
27
+			log.WithFields(logrus.Fields{
28
+				"omg":         true,
29
+				"err_animal":  entry.Data["animal"],
30
+				"err_size":    entry.Data["size"],
31
+				"err_level":   entry.Level,
32
+				"err_message": entry.Message,
33
+				"number":      100,
34
+			}).Error("The ice breaks!") // or use Fatal() to force the process to exit with a nonzero code
35
+		}
36
+	}()
37
+
38
+	log.WithFields(logrus.Fields{
39
+		"animal": "walrus",
40
+		"number": 8,
41
+	}).Debug("Started observing beach")
42
+
43
+	log.WithFields(logrus.Fields{
44
+		"animal": "walrus",
45
+		"size":   10,
46
+	}).Info("A group of walrus emerges from the ocean")
47
+
48
+	log.WithFields(logrus.Fields{
49
+		"omg":    true,
50
+		"number": 122,
51
+	}).Warn("The group's number increased tremendously!")
52
+
53
+	log.WithFields(logrus.Fields{
54
+		"temperature": -4,
55
+	}).Debug("Temperature changes")
56
+
57
+	log.WithFields(logrus.Fields{
58
+		"animal": "orca",
59
+		"size":   9009,
60
+	}).Panic("It's over 9000!")
61
+
62
+	// Output:
63
+	// level=debug msg="Started observing beach" animal=walrus number=8
64
+	// level=info msg="A group of walrus emerges from the ocean" animal=walrus size=10
65
+	// level=warning msg="The group's number increased tremendously!" number=122 omg=true
66
+	// level=debug msg="Temperature changes" temperature=-4
67
+	// level=panic msg="It's over 9000!" animal=orca size=9009
68
+	// level=error msg="The ice breaks!" err_animal=orca err_level=panic err_message="It's over 9000!" err_size=9009 number=100 omg=true
69
+}

+ 35
- 0
vendor/src/github.com/sirupsen/logrus/example_hook_test.go Visa fil

@@ -0,0 +1,35 @@
1
+package logrus_test
2
+
3
+import (
4
+	"github.com/sirupsen/logrus"
5
+	"gopkg.in/gemnasium/logrus-airbrake-hook.v2"
6
+	"os"
7
+)
8
+
9
+func Example_hook() {
10
+	var log = logrus.New()
11
+	log.Formatter = new(logrus.TextFormatter)                     // default
12
+	log.Formatter.(*logrus.TextFormatter).DisableTimestamp = true // remove timestamp from test output
13
+	log.Hooks.Add(airbrake.NewHook(123, "xyz", "development"))
14
+	log.Out = os.Stdout
15
+
16
+	log.WithFields(logrus.Fields{
17
+		"animal": "walrus",
18
+		"size":   10,
19
+	}).Info("A group of walrus emerges from the ocean")
20
+
21
+	log.WithFields(logrus.Fields{
22
+		"omg":    true,
23
+		"number": 122,
24
+	}).Warn("The group's number increased tremendously!")
25
+
26
+	log.WithFields(logrus.Fields{
27
+		"omg":    true,
28
+		"number": 100,
29
+	}).Error("The ice breaks!")
30
+
31
+	// Output:
32
+	// level=info msg="A group of walrus emerges from the ocean" animal=walrus size=10
33
+	// level=warning msg="The group's number increased tremendously!" number=122 omg=true
34
+	// level=error msg="The ice breaks!" number=100 omg=true
35
+}

+ 193
- 0
vendor/src/github.com/sirupsen/logrus/exported.go Visa fil

@@ -0,0 +1,193 @@
1
+package logrus
2
+
3
+import (
4
+	"io"
5
+)
6
+
7
+var (
8
+	// std is the name of the standard logger in stdlib `log`
9
+	std = New()
10
+)
11
+
12
+func StandardLogger() *Logger {
13
+	return std
14
+}
15
+
16
+// SetOutput sets the standard logger output.
17
+func SetOutput(out io.Writer) {
18
+	std.mu.Lock()
19
+	defer std.mu.Unlock()
20
+	std.Out = out
21
+}
22
+
23
+// SetFormatter sets the standard logger formatter.
24
+func SetFormatter(formatter Formatter) {
25
+	std.mu.Lock()
26
+	defer std.mu.Unlock()
27
+	std.Formatter = formatter
28
+}
29
+
30
+// SetLevel sets the standard logger level.
31
+func SetLevel(level Level) {
32
+	std.mu.Lock()
33
+	defer std.mu.Unlock()
34
+	std.SetLevel(level)
35
+}
36
+
37
+// GetLevel returns the standard logger level.
38
+func GetLevel() Level {
39
+	std.mu.Lock()
40
+	defer std.mu.Unlock()
41
+	return std.level()
42
+}
43
+
44
+// AddHook adds a hook to the standard logger hooks.
45
+func AddHook(hook Hook) {
46
+	std.mu.Lock()
47
+	defer std.mu.Unlock()
48
+	std.Hooks.Add(hook)
49
+}
50
+
51
+// WithError creates an entry from the standard logger and adds an error to it, using the value defined in ErrorKey as key.
52
+func WithError(err error) *Entry {
53
+	return std.WithField(ErrorKey, err)
54
+}
55
+
56
+// WithField creates an entry from the standard logger and adds a field to
57
+// it. If you want multiple fields, use `WithFields`.
58
+//
59
+// Note that it doesn't log until you call Debug, Print, Info, Warn, Fatal
60
+// or Panic on the Entry it returns.
61
+func WithField(key string, value interface{}) *Entry {
62
+	return std.WithField(key, value)
63
+}
64
+
65
+// WithFields creates an entry from the standard logger and adds multiple
66
+// fields to it. This is simply a helper for `WithField`, invoking it
67
+// once for each field.
68
+//
69
+// Note that it doesn't log until you call Debug, Print, Info, Warn, Fatal
70
+// or Panic on the Entry it returns.
71
+func WithFields(fields Fields) *Entry {
72
+	return std.WithFields(fields)
73
+}
74
+
75
+// Debug logs a message at level Debug on the standard logger.
76
+func Debug(args ...interface{}) {
77
+	std.Debug(args...)
78
+}
79
+
80
+// Print logs a message at level Info on the standard logger.
81
+func Print(args ...interface{}) {
82
+	std.Print(args...)
83
+}
84
+
85
+// Info logs a message at level Info on the standard logger.
86
+func Info(args ...interface{}) {
87
+	std.Info(args...)
88
+}
89
+
90
+// Warn logs a message at level Warn on the standard logger.
91
+func Warn(args ...interface{}) {
92
+	std.Warn(args...)
93
+}
94
+
95
+// Warning logs a message at level Warn on the standard logger.
96
+func Warning(args ...interface{}) {
97
+	std.Warning(args...)
98
+}
99
+
100
+// Error logs a message at level Error on the standard logger.
101
+func Error(args ...interface{}) {
102
+	std.Error(args...)
103
+}
104
+
105
+// Panic logs a message at level Panic on the standard logger.
106
+func Panic(args ...interface{}) {
107
+	std.Panic(args...)
108
+}
109
+
110
+// Fatal logs a message at level Fatal on the standard logger.
111
+func Fatal(args ...interface{}) {
112
+	std.Fatal(args...)
113
+}
114
+
115
+// Debugf logs a message at level Debug on the standard logger.
116
+func Debugf(format string, args ...interface{}) {
117
+	std.Debugf(format, args...)
118
+}
119
+
120
+// Printf logs a message at level Info on the standard logger.
121
+func Printf(format string, args ...interface{}) {
122
+	std.Printf(format, args...)
123
+}
124
+
125
+// Infof logs a message at level Info on the standard logger.
126
+func Infof(format string, args ...interface{}) {
127
+	std.Infof(format, args...)
128
+}
129
+
130
+// Warnf logs a message at level Warn on the standard logger.
131
+func Warnf(format string, args ...interface{}) {
132
+	std.Warnf(format, args...)
133
+}
134
+
135
+// Warningf logs a message at level Warn on the standard logger.
136
+func Warningf(format string, args ...interface{}) {
137
+	std.Warningf(format, args...)
138
+}
139
+
140
+// Errorf logs a message at level Error on the standard logger.
141
+func Errorf(format string, args ...interface{}) {
142
+	std.Errorf(format, args...)
143
+}
144
+
145
+// Panicf logs a message at level Panic on the standard logger.
146
+func Panicf(format string, args ...interface{}) {
147
+	std.Panicf(format, args...)
148
+}
149
+
150
+// Fatalf logs a message at level Fatal on the standard logger.
151
+func Fatalf(format string, args ...interface{}) {
152
+	std.Fatalf(format, args...)
153
+}
154
+
155
+// Debugln logs a message at level Debug on the standard logger.
156
+func Debugln(args ...interface{}) {
157
+	std.Debugln(args...)
158
+}
159
+
160
+// Println logs a message at level Info on the standard logger.
161
+func Println(args ...interface{}) {
162
+	std.Println(args...)
163
+}
164
+
165
+// Infoln logs a message at level Info on the standard logger.
166
+func Infoln(args ...interface{}) {
167
+	std.Infoln(args...)
168
+}
169
+
170
+// Warnln logs a message at level Warn on the standard logger.
171
+func Warnln(args ...interface{}) {
172
+	std.Warnln(args...)
173
+}
174
+
175
+// Warningln logs a message at level Warn on the standard logger.
176
+func Warningln(args ...interface{}) {
177
+	std.Warningln(args...)
178
+}
179
+
180
+// Errorln logs a message at level Error on the standard logger.
181
+func Errorln(args ...interface{}) {
182
+	std.Errorln(args...)
183
+}
184
+
185
+// Panicln logs a message at level Panic on the standard logger.
186
+func Panicln(args ...interface{}) {
187
+	std.Panicln(args...)
188
+}
189
+
190
+// Fatalln logs a message at level Fatal on the standard logger.
191
+func Fatalln(args ...interface{}) {
192
+	std.Fatalln(args...)
193
+}

+ 45
- 0
vendor/src/github.com/sirupsen/logrus/formatter.go Visa fil

@@ -0,0 +1,45 @@
1
+package logrus
2
+
3
+import "time"
4
+
5
+const defaultTimestampFormat = time.RFC3339
6
+
7
+// The Formatter interface is used to implement a custom Formatter. It takes an
8
+// `Entry`. It exposes all the fields, including the default ones:
9
+//
10
+// * `entry.Data["msg"]`. The message passed from Info, Warn, Error ..
11
+// * `entry.Data["time"]`. The timestamp.
12
+// * `entry.Data["level"]. The level the entry was logged at.
13
+//
14
+// Any additional fields added with `WithField` or `WithFields` are also in
15
+// `entry.Data`. Format is expected to return an array of bytes which are then
16
+// logged to `logger.Out`.
17
+type Formatter interface {
18
+	Format(*Entry) ([]byte, error)
19
+}
20
+
21
+// This is to not silently overwrite `time`, `msg` and `level` fields when
22
+// dumping it. If this code wasn't there doing:
23
+//
24
+//  logrus.WithField("level", 1).Info("hello")
25
+//
26
+// Would just silently drop the user provided level. Instead with this code
27
+// it'll logged as:
28
+//
29
+//  {"level": "info", "fields.level": 1, "msg": "hello", "time": "..."}
30
+//
31
+// It's not exported because it's still using Data in an opinionated way. It's to
32
+// avoid code duplication between the two default formatters.
33
+func prefixFieldClashes(data Fields) {
34
+	if t, ok := data["time"]; ok {
35
+		data["fields.time"] = t
36
+	}
37
+
38
+	if m, ok := data["msg"]; ok {
39
+		data["fields.msg"] = m
40
+	}
41
+
42
+	if l, ok := data["level"]; ok {
43
+		data["fields.level"] = l
44
+	}
45
+}

+ 101
- 0
vendor/src/github.com/sirupsen/logrus/formatter_bench_test.go Visa fil

@@ -0,0 +1,101 @@
1
+package logrus
2
+
3
+import (
4
+	"fmt"
5
+	"testing"
6
+	"time"
7
+)
8
+
9
+// smallFields is a small size data set for benchmarking
10
+var smallFields = Fields{
11
+	"foo":   "bar",
12
+	"baz":   "qux",
13
+	"one":   "two",
14
+	"three": "four",
15
+}
16
+
17
+// largeFields is a large size data set for benchmarking
18
+var largeFields = Fields{
19
+	"foo":       "bar",
20
+	"baz":       "qux",
21
+	"one":       "two",
22
+	"three":     "four",
23
+	"five":      "six",
24
+	"seven":     "eight",
25
+	"nine":      "ten",
26
+	"eleven":    "twelve",
27
+	"thirteen":  "fourteen",
28
+	"fifteen":   "sixteen",
29
+	"seventeen": "eighteen",
30
+	"nineteen":  "twenty",
31
+	"a":         "b",
32
+	"c":         "d",
33
+	"e":         "f",
34
+	"g":         "h",
35
+	"i":         "j",
36
+	"k":         "l",
37
+	"m":         "n",
38
+	"o":         "p",
39
+	"q":         "r",
40
+	"s":         "t",
41
+	"u":         "v",
42
+	"w":         "x",
43
+	"y":         "z",
44
+	"this":      "will",
45
+	"make":      "thirty",
46
+	"entries":   "yeah",
47
+}
48
+
49
+var errorFields = Fields{
50
+	"foo": fmt.Errorf("bar"),
51
+	"baz": fmt.Errorf("qux"),
52
+}
53
+
54
+func BenchmarkErrorTextFormatter(b *testing.B) {
55
+	doBenchmark(b, &TextFormatter{DisableColors: true}, errorFields)
56
+}
57
+
58
+func BenchmarkSmallTextFormatter(b *testing.B) {
59
+	doBenchmark(b, &TextFormatter{DisableColors: true}, smallFields)
60
+}
61
+
62
+func BenchmarkLargeTextFormatter(b *testing.B) {
63
+	doBenchmark(b, &TextFormatter{DisableColors: true}, largeFields)
64
+}
65
+
66
+func BenchmarkSmallColoredTextFormatter(b *testing.B) {
67
+	doBenchmark(b, &TextFormatter{ForceColors: true}, smallFields)
68
+}
69
+
70
+func BenchmarkLargeColoredTextFormatter(b *testing.B) {
71
+	doBenchmark(b, &TextFormatter{ForceColors: true}, largeFields)
72
+}
73
+
74
+func BenchmarkSmallJSONFormatter(b *testing.B) {
75
+	doBenchmark(b, &JSONFormatter{}, smallFields)
76
+}
77
+
78
+func BenchmarkLargeJSONFormatter(b *testing.B) {
79
+	doBenchmark(b, &JSONFormatter{}, largeFields)
80
+}
81
+
82
+func doBenchmark(b *testing.B, formatter Formatter, fields Fields) {
83
+	logger := New()
84
+
85
+	entry := &Entry{
86
+		Time:    time.Time{},
87
+		Level:   InfoLevel,
88
+		Message: "message",
89
+		Data:    fields,
90
+		Logger:  logger,
91
+	}
92
+	var d []byte
93
+	var err error
94
+	for i := 0; i < b.N; i++ {
95
+		d, err = formatter.Format(entry)
96
+		if err != nil {
97
+			b.Fatal(err)
98
+		}
99
+		b.SetBytes(int64(len(d)))
100
+	}
101
+}

+ 144
- 0
vendor/src/github.com/sirupsen/logrus/hook_test.go Visa fil

@@ -0,0 +1,144 @@
1
+package logrus
2
+
3
+import (
4
+	"sync"
5
+	"testing"
6
+
7
+	"github.com/stretchr/testify/assert"
8
+)
9
+
10
+type TestHook struct {
11
+	Fired bool
12
+}
13
+
14
+func (hook *TestHook) Fire(entry *Entry) error {
15
+	hook.Fired = true
16
+	return nil
17
+}
18
+
19
+func (hook *TestHook) Levels() []Level {
20
+	return []Level{
21
+		DebugLevel,
22
+		InfoLevel,
23
+		WarnLevel,
24
+		ErrorLevel,
25
+		FatalLevel,
26
+		PanicLevel,
27
+	}
28
+}
29
+
30
+func TestHookFires(t *testing.T) {
31
+	hook := new(TestHook)
32
+
33
+	LogAndAssertJSON(t, func(log *Logger) {
34
+		log.Hooks.Add(hook)
35
+		assert.Equal(t, hook.Fired, false)
36
+
37
+		log.Print("test")
38
+	}, func(fields Fields) {
39
+		assert.Equal(t, hook.Fired, true)
40
+	})
41
+}
42
+
43
+type ModifyHook struct {
44
+}
45
+
46
+func (hook *ModifyHook) Fire(entry *Entry) error {
47
+	entry.Data["wow"] = "whale"
48
+	return nil
49
+}
50
+
51
+func (hook *ModifyHook) Levels() []Level {
52
+	return []Level{
53
+		DebugLevel,
54
+		InfoLevel,
55
+		WarnLevel,
56
+		ErrorLevel,
57
+		FatalLevel,
58
+		PanicLevel,
59
+	}
60
+}
61
+
62
+func TestHookCanModifyEntry(t *testing.T) {
63
+	hook := new(ModifyHook)
64
+
65
+	LogAndAssertJSON(t, func(log *Logger) {
66
+		log.Hooks.Add(hook)
67
+		log.WithField("wow", "elephant").Print("test")
68
+	}, func(fields Fields) {
69
+		assert.Equal(t, fields["wow"], "whale")
70
+	})
71
+}
72
+
73
+func TestCanFireMultipleHooks(t *testing.T) {
74
+	hook1 := new(ModifyHook)
75
+	hook2 := new(TestHook)
76
+
77
+	LogAndAssertJSON(t, func(log *Logger) {
78
+		log.Hooks.Add(hook1)
79
+		log.Hooks.Add(hook2)
80
+
81
+		log.WithField("wow", "elephant").Print("test")
82
+	}, func(fields Fields) {
83
+		assert.Equal(t, fields["wow"], "whale")
84
+		assert.Equal(t, hook2.Fired, true)
85
+	})
86
+}
87
+
88
+type ErrorHook struct {
89
+	Fired bool
90
+}
91
+
92
+func (hook *ErrorHook) Fire(entry *Entry) error {
93
+	hook.Fired = true
94
+	return nil
95
+}
96
+
97
+func (hook *ErrorHook) Levels() []Level {
98
+	return []Level{
99
+		ErrorLevel,
100
+	}
101
+}
102
+
103
+func TestErrorHookShouldntFireOnInfo(t *testing.T) {
104
+	hook := new(ErrorHook)
105
+
106
+	LogAndAssertJSON(t, func(log *Logger) {
107
+		log.Hooks.Add(hook)
108
+		log.Info("test")
109
+	}, func(fields Fields) {
110
+		assert.Equal(t, hook.Fired, false)
111
+	})
112
+}
113
+
114
+func TestErrorHookShouldFireOnError(t *testing.T) {
115
+	hook := new(ErrorHook)
116
+
117
+	LogAndAssertJSON(t, func(log *Logger) {
118
+		log.Hooks.Add(hook)
119
+		log.Error("test")
120
+	}, func(fields Fields) {
121
+		assert.Equal(t, hook.Fired, true)
122
+	})
123
+}
124
+
125
+func TestAddHookRace(t *testing.T) {
126
+	var wg sync.WaitGroup
127
+	wg.Add(2)
128
+	hook := new(ErrorHook)
129
+	LogAndAssertJSON(t, func(log *Logger) {
130
+		go func() {
131
+			defer wg.Done()
132
+			log.AddHook(hook)
133
+		}()
134
+		go func() {
135
+			defer wg.Done()
136
+			log.Error("test")
137
+		}()
138
+		wg.Wait()
139
+	}, func(fields Fields) {
140
+		// the line may have been logged
141
+		// before the hook was added, so we can't
142
+		// actually assert on the hook
143
+	})
144
+}

+ 34
- 0
vendor/src/github.com/sirupsen/logrus/hooks.go Visa fil

@@ -0,0 +1,34 @@
1
+package logrus
2
+
3
+// A hook to be fired when logging on the logging levels returned from
4
+// `Levels()` on your implementation of the interface. Note that this is not
5
+// fired in a goroutine or a channel with workers, you should handle such
6
+// functionality yourself if your call is non-blocking and you don't wish for
7
+// the logging calls for levels returned from `Levels()` to block.
8
+type Hook interface {
9
+	Levels() []Level
10
+	Fire(*Entry) error
11
+}
12
+
13
+// Internal type for storing the hooks on a logger instance.
14
+type LevelHooks map[Level][]Hook
15
+
16
+// Add a hook to an instance of logger. This is called with
17
+// `log.Hooks.Add(new(MyHook))` where `MyHook` implements the `Hook` interface.
18
+func (hooks LevelHooks) Add(hook Hook) {
19
+	for _, level := range hook.Levels() {
20
+		hooks[level] = append(hooks[level], hook)
21
+	}
22
+}
23
+
24
+// Fire all the hooks for the passed level. Used by `entry.log` to fire
25
+// appropriate hooks for a log entry.
26
+func (hooks LevelHooks) Fire(level Level, entry *Entry) error {
27
+	for _, hook := range hooks[level] {
28
+		if err := hook.Fire(entry); err != nil {
29
+			return err
30
+		}
31
+	}
32
+
33
+	return nil
34
+}

+ 39
- 0
vendor/src/github.com/sirupsen/logrus/hooks/syslog/README.md Visa fil

@@ -0,0 +1,39 @@
1
+# Syslog Hooks for Logrus <img src="http://i.imgur.com/hTeVwmJ.png" width="40" height="40" alt=":walrus:" class="emoji" title=":walrus:"/>
2
+
3
+## Usage
4
+
5
+```go
6
+import (
7
+  "log/syslog"
8
+  "github.com/sirupsen/logrus"
9
+  lSyslog "github.com/sirupsen/logrus/hooks/syslog"
10
+)
11
+
12
+func main() {
13
+  log       := logrus.New()
14
+  hook, err := lSyslog.NewSyslogHook("udp", "localhost:514", syslog.LOG_INFO, "")
15
+
16
+  if err == nil {
17
+    log.Hooks.Add(hook)
18
+  }
19
+}
20
+```
21
+
22
+If you want to connect to local syslog (Ex. "/dev/log" or "/var/run/syslog" or "/var/run/log"). Just assign empty string to the first two parameters of `NewSyslogHook`. It should look like the following.
23
+
24
+```go
25
+import (
26
+  "log/syslog"
27
+  "github.com/sirupsen/logrus"
28
+  lSyslog "github.com/sirupsen/logrus/hooks/syslog"
29
+)
30
+
31
+func main() {
32
+  log       := logrus.New()
33
+  hook, err := lSyslog.NewSyslogHook("", "", syslog.LOG_INFO, "")
34
+
35
+  if err == nil {
36
+    log.Hooks.Add(hook)
37
+  }
38
+}
39
+```

+ 55
- 0
vendor/src/github.com/sirupsen/logrus/hooks/syslog/syslog.go Visa fil

@@ -0,0 +1,55 @@
1
+// +build !windows,!nacl,!plan9
2
+
3
+package syslog
4
+
5
+import (
6
+	"fmt"
7
+	"log/syslog"
8
+	"os"
9
+
10
+	"github.com/sirupsen/logrus"
11
+)
12
+
13
+// SyslogHook to send logs via syslog.
14
+type SyslogHook struct {
15
+	Writer        *syslog.Writer
16
+	SyslogNetwork string
17
+	SyslogRaddr   string
18
+}
19
+
20
+// Creates a hook to be added to an instance of logger. This is called with
21
+// `hook, err := NewSyslogHook("udp", "localhost:514", syslog.LOG_DEBUG, "")`
22
+// `if err == nil { log.Hooks.Add(hook) }`
23
+func NewSyslogHook(network, raddr string, priority syslog.Priority, tag string) (*SyslogHook, error) {
24
+	w, err := syslog.Dial(network, raddr, priority, tag)
25
+	return &SyslogHook{w, network, raddr}, err
26
+}
27
+
28
+func (hook *SyslogHook) Fire(entry *logrus.Entry) error {
29
+	line, err := entry.String()
30
+	if err != nil {
31
+		fmt.Fprintf(os.Stderr, "Unable to read entry, %v", err)
32
+		return err
33
+	}
34
+
35
+	switch entry.Level {
36
+	case logrus.PanicLevel:
37
+		return hook.Writer.Crit(line)
38
+	case logrus.FatalLevel:
39
+		return hook.Writer.Crit(line)
40
+	case logrus.ErrorLevel:
41
+		return hook.Writer.Err(line)
42
+	case logrus.WarnLevel:
43
+		return hook.Writer.Warning(line)
44
+	case logrus.InfoLevel:
45
+		return hook.Writer.Info(line)
46
+	case logrus.DebugLevel:
47
+		return hook.Writer.Debug(line)
48
+	default:
49
+		return nil
50
+	}
51
+}
52
+
53
+func (hook *SyslogHook) Levels() []logrus.Level {
54
+	return logrus.AllLevels
55
+}

+ 27
- 0
vendor/src/github.com/sirupsen/logrus/hooks/syslog/syslog_test.go Visa fil

@@ -0,0 +1,27 @@
1
+package syslog
2
+
3
+import (
4
+	"log/syslog"
5
+	"testing"
6
+
7
+	"github.com/sirupsen/logrus"
8
+)
9
+
10
+func TestLocalhostAddAndPrint(t *testing.T) {
11
+	log := logrus.New()
12
+	hook, err := NewSyslogHook("udp", "localhost:514", syslog.LOG_INFO, "")
13
+
14
+	if err != nil {
15
+		t.Errorf("Unable to connect to local syslog.")
16
+	}
17
+
18
+	log.Hooks.Add(hook)
19
+
20
+	for _, level := range hook.Levels() {
21
+		if len(log.Hooks[level]) != 1 {
22
+			t.Errorf("SyslogHook was not added. The length of log.Hooks[%v]: %v", level, len(log.Hooks[level]))
23
+		}
24
+	}
25
+
26
+	log.Info("Congratulations!")
27
+}

+ 95
- 0
vendor/src/github.com/sirupsen/logrus/hooks/test/test.go Visa fil

@@ -0,0 +1,95 @@
1
+// The Test package is used for testing logrus. It is here for backwards
2
+// compatibility from when logrus' organization was upper-case. Please use
3
+// lower-case logrus and the `null` package instead of this one.
4
+package test
5
+
6
+import (
7
+	"io/ioutil"
8
+	"sync"
9
+
10
+	"github.com/sirupsen/logrus"
11
+)
12
+
13
+// Hook is a hook designed for dealing with logs in test scenarios.
14
+type Hook struct {
15
+	// Entries is an array of all entries that have been received by this hook.
16
+	// For safe access, use the AllEntries() method, rather than reading this
17
+	// value directly.
18
+	Entries []*logrus.Entry
19
+	mu      sync.RWMutex
20
+}
21
+
22
+// NewGlobal installs a test hook for the global logger.
23
+func NewGlobal() *Hook {
24
+
25
+	hook := new(Hook)
26
+	logrus.AddHook(hook)
27
+
28
+	return hook
29
+
30
+}
31
+
32
+// NewLocal installs a test hook for a given local logger.
33
+func NewLocal(logger *logrus.Logger) *Hook {
34
+
35
+	hook := new(Hook)
36
+	logger.Hooks.Add(hook)
37
+
38
+	return hook
39
+
40
+}
41
+
42
+// NewNullLogger creates a discarding logger and installs the test hook.
43
+func NewNullLogger() (*logrus.Logger, *Hook) {
44
+
45
+	logger := logrus.New()
46
+	logger.Out = ioutil.Discard
47
+
48
+	return logger, NewLocal(logger)
49
+
50
+}
51
+
52
+func (t *Hook) Fire(e *logrus.Entry) error {
53
+	t.mu.Lock()
54
+	defer t.mu.Unlock()
55
+	t.Entries = append(t.Entries, e)
56
+	return nil
57
+}
58
+
59
+func (t *Hook) Levels() []logrus.Level {
60
+	return logrus.AllLevels
61
+}
62
+
63
+// LastEntry returns the last entry that was logged or nil.
64
+func (t *Hook) LastEntry() *logrus.Entry {
65
+	t.mu.RLock()
66
+	defer t.mu.RUnlock()
67
+	i := len(t.Entries) - 1
68
+	if i < 0 {
69
+		return nil
70
+	}
71
+	// Make a copy, for safety
72
+	e := *t.Entries[i]
73
+	return &e
74
+}
75
+
76
+// AllEntries returns all entries that were logged.
77
+func (t *Hook) AllEntries() []*logrus.Entry {
78
+	t.mu.RLock()
79
+	defer t.mu.RUnlock()
80
+	// Make a copy so the returned value won't race with future log requests
81
+	entries := make([]*logrus.Entry, len(t.Entries))
82
+	for i, entry := range t.Entries {
83
+		// Make a copy, for safety
84
+		e := *entry
85
+		entries[i] = &e
86
+	}
87
+	return entries
88
+}
89
+
90
+// Reset removes all Entries from this test hook.
91
+func (t *Hook) Reset() {
92
+	t.mu.Lock()
93
+	defer t.mu.Unlock()
94
+	t.Entries = make([]*logrus.Entry, 0)
95
+}

+ 39
- 0
vendor/src/github.com/sirupsen/logrus/hooks/test/test_test.go Visa fil

@@ -0,0 +1,39 @@
1
+package test
2
+
3
+import (
4
+	"testing"
5
+
6
+	"github.com/sirupsen/logrus"
7
+	"github.com/stretchr/testify/assert"
8
+)
9
+
10
+func TestAllHooks(t *testing.T) {
11
+
12
+	assert := assert.New(t)
13
+
14
+	logger, hook := NewNullLogger()
15
+	assert.Nil(hook.LastEntry())
16
+	assert.Equal(0, len(hook.Entries))
17
+
18
+	logger.Error("Hello error")
19
+	assert.Equal(logrus.ErrorLevel, hook.LastEntry().Level)
20
+	assert.Equal("Hello error", hook.LastEntry().Message)
21
+	assert.Equal(1, len(hook.Entries))
22
+
23
+	logger.Warn("Hello warning")
24
+	assert.Equal(logrus.WarnLevel, hook.LastEntry().Level)
25
+	assert.Equal("Hello warning", hook.LastEntry().Message)
26
+	assert.Equal(2, len(hook.Entries))
27
+
28
+	hook.Reset()
29
+	assert.Nil(hook.LastEntry())
30
+	assert.Equal(0, len(hook.Entries))
31
+
32
+	hook = NewGlobal()
33
+
34
+	logrus.Error("Hello error")
35
+	assert.Equal(logrus.ErrorLevel, hook.LastEntry().Level)
36
+	assert.Equal("Hello error", hook.LastEntry().Message)
37
+	assert.Equal(1, len(hook.Entries))
38
+
39
+}

+ 79
- 0
vendor/src/github.com/sirupsen/logrus/json_formatter.go Visa fil

@@ -0,0 +1,79 @@
1
+package logrus
2
+
3
+import (
4
+	"encoding/json"
5
+	"fmt"
6
+)
7
+
8
+type fieldKey string
9
+
10
+// FieldMap allows customization of the key names for default fields.
11
+type FieldMap map[fieldKey]string
12
+
13
+// Default key names for the default fields
14
+const (
15
+	FieldKeyMsg   = "msg"
16
+	FieldKeyLevel = "level"
17
+	FieldKeyTime  = "time"
18
+)
19
+
20
+func (f FieldMap) resolve(key fieldKey) string {
21
+	if k, ok := f[key]; ok {
22
+		return k
23
+	}
24
+
25
+	return string(key)
26
+}
27
+
28
+// JSONFormatter formats logs into parsable json
29
+type JSONFormatter struct {
30
+	// TimestampFormat sets the format used for marshaling timestamps.
31
+	TimestampFormat string
32
+
33
+	// DisableTimestamp allows disabling automatic timestamps in output
34
+	DisableTimestamp bool
35
+
36
+	// FieldMap allows users to customize the names of keys for default fields.
37
+	// As an example:
38
+	// formatter := &JSONFormatter{
39
+	//   	FieldMap: FieldMap{
40
+	// 		 FieldKeyTime: "@timestamp",
41
+	// 		 FieldKeyLevel: "@level",
42
+	// 		 FieldKeyMsg: "@message",
43
+	//    },
44
+	// }
45
+	FieldMap FieldMap
46
+}
47
+
48
+// Format renders a single log entry
49
+func (f *JSONFormatter) Format(entry *Entry) ([]byte, error) {
50
+	data := make(Fields, len(entry.Data)+3)
51
+	for k, v := range entry.Data {
52
+		switch v := v.(type) {
53
+		case error:
54
+			// Otherwise errors are ignored by `encoding/json`
55
+			// https://github.com/sirupsen/logrus/issues/137
56
+			data[k] = v.Error()
57
+		default:
58
+			data[k] = v
59
+		}
60
+	}
61
+	prefixFieldClashes(data)
62
+
63
+	timestampFormat := f.TimestampFormat
64
+	if timestampFormat == "" {
65
+		timestampFormat = defaultTimestampFormat
66
+	}
67
+
68
+	if !f.DisableTimestamp {
69
+		data[f.FieldMap.resolve(FieldKeyTime)] = entry.Time.Format(timestampFormat)
70
+	}
71
+	data[f.FieldMap.resolve(FieldKeyMsg)] = entry.Message
72
+	data[f.FieldMap.resolve(FieldKeyLevel)] = entry.Level.String()
73
+
74
+	serialized, err := json.Marshal(data)
75
+	if err != nil {
76
+		return nil, fmt.Errorf("Failed to marshal fields to JSON, %v", err)
77
+	}
78
+	return append(serialized, '\n'), nil
79
+}

+ 199
- 0
vendor/src/github.com/sirupsen/logrus/json_formatter_test.go Visa fil

@@ -0,0 +1,199 @@
1
+package logrus
2
+
3
+import (
4
+	"encoding/json"
5
+	"errors"
6
+	"strings"
7
+	"testing"
8
+)
9
+
10
+func TestErrorNotLost(t *testing.T) {
11
+	formatter := &JSONFormatter{}
12
+
13
+	b, err := formatter.Format(WithField("error", errors.New("wild walrus")))
14
+	if err != nil {
15
+		t.Fatal("Unable to format entry: ", err)
16
+	}
17
+
18
+	entry := make(map[string]interface{})
19
+	err = json.Unmarshal(b, &entry)
20
+	if err != nil {
21
+		t.Fatal("Unable to unmarshal formatted entry: ", err)
22
+	}
23
+
24
+	if entry["error"] != "wild walrus" {
25
+		t.Fatal("Error field not set")
26
+	}
27
+}
28
+
29
+func TestErrorNotLostOnFieldNotNamedError(t *testing.T) {
30
+	formatter := &JSONFormatter{}
31
+
32
+	b, err := formatter.Format(WithField("omg", errors.New("wild walrus")))
33
+	if err != nil {
34
+		t.Fatal("Unable to format entry: ", err)
35
+	}
36
+
37
+	entry := make(map[string]interface{})
38
+	err = json.Unmarshal(b, &entry)
39
+	if err != nil {
40
+		t.Fatal("Unable to unmarshal formatted entry: ", err)
41
+	}
42
+
43
+	if entry["omg"] != "wild walrus" {
44
+		t.Fatal("Error field not set")
45
+	}
46
+}
47
+
48
+func TestFieldClashWithTime(t *testing.T) {
49
+	formatter := &JSONFormatter{}
50
+
51
+	b, err := formatter.Format(WithField("time", "right now!"))
52
+	if err != nil {
53
+		t.Fatal("Unable to format entry: ", err)
54
+	}
55
+
56
+	entry := make(map[string]interface{})
57
+	err = json.Unmarshal(b, &entry)
58
+	if err != nil {
59
+		t.Fatal("Unable to unmarshal formatted entry: ", err)
60
+	}
61
+
62
+	if entry["fields.time"] != "right now!" {
63
+		t.Fatal("fields.time not set to original time field")
64
+	}
65
+
66
+	if entry["time"] != "0001-01-01T00:00:00Z" {
67
+		t.Fatal("time field not set to current time, was: ", entry["time"])
68
+	}
69
+}
70
+
71
+func TestFieldClashWithMsg(t *testing.T) {
72
+	formatter := &JSONFormatter{}
73
+
74
+	b, err := formatter.Format(WithField("msg", "something"))
75
+	if err != nil {
76
+		t.Fatal("Unable to format entry: ", err)
77
+	}
78
+
79
+	entry := make(map[string]interface{})
80
+	err = json.Unmarshal(b, &entry)
81
+	if err != nil {
82
+		t.Fatal("Unable to unmarshal formatted entry: ", err)
83
+	}
84
+
85
+	if entry["fields.msg"] != "something" {
86
+		t.Fatal("fields.msg not set to original msg field")
87
+	}
88
+}
89
+
90
+func TestFieldClashWithLevel(t *testing.T) {
91
+	formatter := &JSONFormatter{}
92
+
93
+	b, err := formatter.Format(WithField("level", "something"))
94
+	if err != nil {
95
+		t.Fatal("Unable to format entry: ", err)
96
+	}
97
+
98
+	entry := make(map[string]interface{})
99
+	err = json.Unmarshal(b, &entry)
100
+	if err != nil {
101
+		t.Fatal("Unable to unmarshal formatted entry: ", err)
102
+	}
103
+
104
+	if entry["fields.level"] != "something" {
105
+		t.Fatal("fields.level not set to original level field")
106
+	}
107
+}
108
+
109
+func TestJSONEntryEndsWithNewline(t *testing.T) {
110
+	formatter := &JSONFormatter{}
111
+
112
+	b, err := formatter.Format(WithField("level", "something"))
113
+	if err != nil {
114
+		t.Fatal("Unable to format entry: ", err)
115
+	}
116
+
117
+	if b[len(b)-1] != '\n' {
118
+		t.Fatal("Expected JSON log entry to end with a newline")
119
+	}
120
+}
121
+
122
+func TestJSONMessageKey(t *testing.T) {
123
+	formatter := &JSONFormatter{
124
+		FieldMap: FieldMap{
125
+			FieldKeyMsg: "message",
126
+		},
127
+	}
128
+
129
+	b, err := formatter.Format(&Entry{Message: "oh hai"})
130
+	if err != nil {
131
+		t.Fatal("Unable to format entry: ", err)
132
+	}
133
+	s := string(b)
134
+	if !(strings.Contains(s, "message") && strings.Contains(s, "oh hai")) {
135
+		t.Fatal("Expected JSON to format message key")
136
+	}
137
+}
138
+
139
+func TestJSONLevelKey(t *testing.T) {
140
+	formatter := &JSONFormatter{
141
+		FieldMap: FieldMap{
142
+			FieldKeyLevel: "somelevel",
143
+		},
144
+	}
145
+
146
+	b, err := formatter.Format(WithField("level", "something"))
147
+	if err != nil {
148
+		t.Fatal("Unable to format entry: ", err)
149
+	}
150
+	s := string(b)
151
+	if !strings.Contains(s, "somelevel") {
152
+		t.Fatal("Expected JSON to format level key")
153
+	}
154
+}
155
+
156
+func TestJSONTimeKey(t *testing.T) {
157
+	formatter := &JSONFormatter{
158
+		FieldMap: FieldMap{
159
+			FieldKeyTime: "timeywimey",
160
+		},
161
+	}
162
+
163
+	b, err := formatter.Format(WithField("level", "something"))
164
+	if err != nil {
165
+		t.Fatal("Unable to format entry: ", err)
166
+	}
167
+	s := string(b)
168
+	if !strings.Contains(s, "timeywimey") {
169
+		t.Fatal("Expected JSON to format time key")
170
+	}
171
+}
172
+
173
+func TestJSONDisableTimestamp(t *testing.T) {
174
+	formatter := &JSONFormatter{
175
+		DisableTimestamp: true,
176
+	}
177
+
178
+	b, err := formatter.Format(WithField("level", "something"))
179
+	if err != nil {
180
+		t.Fatal("Unable to format entry: ", err)
181
+	}
182
+	s := string(b)
183
+	if strings.Contains(s, FieldKeyTime) {
184
+		t.Error("Did not prevent timestamp", s)
185
+	}
186
+}
187
+
188
+func TestJSONEnableTimestamp(t *testing.T) {
189
+	formatter := &JSONFormatter{}
190
+
191
+	b, err := formatter.Format(WithField("level", "something"))
192
+	if err != nil {
193
+		t.Fatal("Unable to format entry: ", err)
194
+	}
195
+	s := string(b)
196
+	if !strings.Contains(s, FieldKeyTime) {
197
+		t.Error("Timestamp not present", s)
198
+	}
199
+}

+ 323
- 0
vendor/src/github.com/sirupsen/logrus/logger.go Visa fil

@@ -0,0 +1,323 @@
1
+package logrus
2
+
3
+import (
4
+	"io"
5
+	"os"
6
+	"sync"
7
+	"sync/atomic"
8
+)
9
+
10
+type Logger struct {
11
+	// The logs are `io.Copy`'d to this in a mutex. It's common to set this to a
12
+	// file, or leave it default which is `os.Stderr`. You can also set this to
13
+	// something more adventorous, such as logging to Kafka.
14
+	Out io.Writer
15
+	// Hooks for the logger instance. These allow firing events based on logging
16
+	// levels and log entries. For example, to send errors to an error tracking
17
+	// service, log to StatsD or dump the core on fatal errors.
18
+	Hooks LevelHooks
19
+	// All log entries pass through the formatter before logged to Out. The
20
+	// included formatters are `TextFormatter` and `JSONFormatter` for which
21
+	// TextFormatter is the default. In development (when a TTY is attached) it
22
+	// logs with colors, but to a file it wouldn't. You can easily implement your
23
+	// own that implements the `Formatter` interface, see the `README` or included
24
+	// formatters for examples.
25
+	Formatter Formatter
26
+	// The logging level the logger should log at. This is typically (and defaults
27
+	// to) `logrus.Info`, which allows Info(), Warn(), Error() and Fatal() to be
28
+	// logged.
29
+	Level Level
30
+	// Used to sync writing to the log. Locking is enabled by Default
31
+	mu MutexWrap
32
+	// Reusable empty entry
33
+	entryPool sync.Pool
34
+}
35
+
36
+type MutexWrap struct {
37
+	lock     sync.Mutex
38
+	disabled bool
39
+}
40
+
41
+func (mw *MutexWrap) Lock() {
42
+	if !mw.disabled {
43
+		mw.lock.Lock()
44
+	}
45
+}
46
+
47
+func (mw *MutexWrap) Unlock() {
48
+	if !mw.disabled {
49
+		mw.lock.Unlock()
50
+	}
51
+}
52
+
53
+func (mw *MutexWrap) Disable() {
54
+	mw.disabled = true
55
+}
56
+
57
+// Creates a new logger. Configuration should be set by changing `Formatter`,
58
+// `Out` and `Hooks` directly on the default logger instance. You can also just
59
+// instantiate your own:
60
+//
61
+//    var log = &Logger{
62
+//      Out: os.Stderr,
63
+//      Formatter: new(JSONFormatter),
64
+//      Hooks: make(LevelHooks),
65
+//      Level: logrus.DebugLevel,
66
+//    }
67
+//
68
+// It's recommended to make this a global instance called `log`.
69
+func New() *Logger {
70
+	return &Logger{
71
+		Out:       os.Stderr,
72
+		Formatter: new(TextFormatter),
73
+		Hooks:     make(LevelHooks),
74
+		Level:     InfoLevel,
75
+	}
76
+}
77
+
78
+func (logger *Logger) newEntry() *Entry {
79
+	entry, ok := logger.entryPool.Get().(*Entry)
80
+	if ok {
81
+		return entry
82
+	}
83
+	return NewEntry(logger)
84
+}
85
+
86
+func (logger *Logger) releaseEntry(entry *Entry) {
87
+	logger.entryPool.Put(entry)
88
+}
89
+
90
+// Adds a field to the log entry, note that it doesn't log until you call
91
+// Debug, Print, Info, Warn, Fatal or Panic. It only creates a log entry.
92
+// If you want multiple fields, use `WithFields`.
93
+func (logger *Logger) WithField(key string, value interface{}) *Entry {
94
+	entry := logger.newEntry()
95
+	defer logger.releaseEntry(entry)
96
+	return entry.WithField(key, value)
97
+}
98
+
99
+// Adds a struct of fields to the log entry. All it does is call `WithField` for
100
+// each `Field`.
101
+func (logger *Logger) WithFields(fields Fields) *Entry {
102
+	entry := logger.newEntry()
103
+	defer logger.releaseEntry(entry)
104
+	return entry.WithFields(fields)
105
+}
106
+
107
+// Add an error as single field to the log entry.  All it does is call
108
+// `WithError` for the given `error`.
109
+func (logger *Logger) WithError(err error) *Entry {
110
+	entry := logger.newEntry()
111
+	defer logger.releaseEntry(entry)
112
+	return entry.WithError(err)
113
+}
114
+
115
+func (logger *Logger) Debugf(format string, args ...interface{}) {
116
+	if logger.level() >= DebugLevel {
117
+		entry := logger.newEntry()
118
+		entry.Debugf(format, args...)
119
+		logger.releaseEntry(entry)
120
+	}
121
+}
122
+
123
+func (logger *Logger) Infof(format string, args ...interface{}) {
124
+	if logger.level() >= InfoLevel {
125
+		entry := logger.newEntry()
126
+		entry.Infof(format, args...)
127
+		logger.releaseEntry(entry)
128
+	}
129
+}
130
+
131
+func (logger *Logger) Printf(format string, args ...interface{}) {
132
+	entry := logger.newEntry()
133
+	entry.Printf(format, args...)
134
+	logger.releaseEntry(entry)
135
+}
136
+
137
+func (logger *Logger) Warnf(format string, args ...interface{}) {
138
+	if logger.level() >= WarnLevel {
139
+		entry := logger.newEntry()
140
+		entry.Warnf(format, args...)
141
+		logger.releaseEntry(entry)
142
+	}
143
+}
144
+
145
+func (logger *Logger) Warningf(format string, args ...interface{}) {
146
+	if logger.level() >= WarnLevel {
147
+		entry := logger.newEntry()
148
+		entry.Warnf(format, args...)
149
+		logger.releaseEntry(entry)
150
+	}
151
+}
152
+
153
+func (logger *Logger) Errorf(format string, args ...interface{}) {
154
+	if logger.level() >= ErrorLevel {
155
+		entry := logger.newEntry()
156
+		entry.Errorf(format, args...)
157
+		logger.releaseEntry(entry)
158
+	}
159
+}
160
+
161
+func (logger *Logger) Fatalf(format string, args ...interface{}) {
162
+	if logger.level() >= FatalLevel {
163
+		entry := logger.newEntry()
164
+		entry.Fatalf(format, args...)
165
+		logger.releaseEntry(entry)
166
+	}
167
+	Exit(1)
168
+}
169
+
170
+func (logger *Logger) Panicf(format string, args ...interface{}) {
171
+	if logger.level() >= PanicLevel {
172
+		entry := logger.newEntry()
173
+		entry.Panicf(format, args...)
174
+		logger.releaseEntry(entry)
175
+	}
176
+}
177
+
178
+func (logger *Logger) Debug(args ...interface{}) {
179
+	if logger.level() >= DebugLevel {
180
+		entry := logger.newEntry()
181
+		entry.Debug(args...)
182
+		logger.releaseEntry(entry)
183
+	}
184
+}
185
+
186
+func (logger *Logger) Info(args ...interface{}) {
187
+	if logger.level() >= InfoLevel {
188
+		entry := logger.newEntry()
189
+		entry.Info(args...)
190
+		logger.releaseEntry(entry)
191
+	}
192
+}
193
+
194
+func (logger *Logger) Print(args ...interface{}) {
195
+	entry := logger.newEntry()
196
+	entry.Info(args...)
197
+	logger.releaseEntry(entry)
198
+}
199
+
200
+func (logger *Logger) Warn(args ...interface{}) {
201
+	if logger.level() >= WarnLevel {
202
+		entry := logger.newEntry()
203
+		entry.Warn(args...)
204
+		logger.releaseEntry(entry)
205
+	}
206
+}
207
+
208
+func (logger *Logger) Warning(args ...interface{}) {
209
+	if logger.level() >= WarnLevel {
210
+		entry := logger.newEntry()
211
+		entry.Warn(args...)
212
+		logger.releaseEntry(entry)
213
+	}
214
+}
215
+
216
+func (logger *Logger) Error(args ...interface{}) {
217
+	if logger.level() >= ErrorLevel {
218
+		entry := logger.newEntry()
219
+		entry.Error(args...)
220
+		logger.releaseEntry(entry)
221
+	}
222
+}
223
+
224
+func (logger *Logger) Fatal(args ...interface{}) {
225
+	if logger.level() >= FatalLevel {
226
+		entry := logger.newEntry()
227
+		entry.Fatal(args...)
228
+		logger.releaseEntry(entry)
229
+	}
230
+	Exit(1)
231
+}
232
+
233
+func (logger *Logger) Panic(args ...interface{}) {
234
+	if logger.level() >= PanicLevel {
235
+		entry := logger.newEntry()
236
+		entry.Panic(args...)
237
+		logger.releaseEntry(entry)
238
+	}
239
+}
240
+
241
+func (logger *Logger) Debugln(args ...interface{}) {
242
+	if logger.level() >= DebugLevel {
243
+		entry := logger.newEntry()
244
+		entry.Debugln(args...)
245
+		logger.releaseEntry(entry)
246
+	}
247
+}
248
+
249
+func (logger *Logger) Infoln(args ...interface{}) {
250
+	if logger.level() >= InfoLevel {
251
+		entry := logger.newEntry()
252
+		entry.Infoln(args...)
253
+		logger.releaseEntry(entry)
254
+	}
255
+}
256
+
257
+func (logger *Logger) Println(args ...interface{}) {
258
+	entry := logger.newEntry()
259
+	entry.Println(args...)
260
+	logger.releaseEntry(entry)
261
+}
262
+
263
+func (logger *Logger) Warnln(args ...interface{}) {
264
+	if logger.level() >= WarnLevel {
265
+		entry := logger.newEntry()
266
+		entry.Warnln(args...)
267
+		logger.releaseEntry(entry)
268
+	}
269
+}
270
+
271
+func (logger *Logger) Warningln(args ...interface{}) {
272
+	if logger.level() >= WarnLevel {
273
+		entry := logger.newEntry()
274
+		entry.Warnln(args...)
275
+		logger.releaseEntry(entry)
276
+	}
277
+}
278
+
279
+func (logger *Logger) Errorln(args ...interface{}) {
280
+	if logger.level() >= ErrorLevel {
281
+		entry := logger.newEntry()
282
+		entry.Errorln(args...)
283
+		logger.releaseEntry(entry)
284
+	}
285
+}
286
+
287
+func (logger *Logger) Fatalln(args ...interface{}) {
288
+	if logger.level() >= FatalLevel {
289
+		entry := logger.newEntry()
290
+		entry.Fatalln(args...)
291
+		logger.releaseEntry(entry)
292
+	}
293
+	Exit(1)
294
+}
295
+
296
+func (logger *Logger) Panicln(args ...interface{}) {
297
+	if logger.level() >= PanicLevel {
298
+		entry := logger.newEntry()
299
+		entry.Panicln(args...)
300
+		logger.releaseEntry(entry)
301
+	}
302
+}
303
+
304
+//When file is opened with appending mode, it's safe to
305
+//write concurrently to a file (within 4k message on Linux).
306
+//In these cases user can choose to disable the lock.
307
+func (logger *Logger) SetNoLock() {
308
+	logger.mu.Disable()
309
+}
310
+
311
+func (logger *Logger) level() Level {
312
+	return Level(atomic.LoadUint32((*uint32)(&logger.Level)))
313
+}
314
+
315
+func (logger *Logger) SetLevel(level Level) {
316
+	atomic.StoreUint32((*uint32)(&logger.Level), uint32(level))
317
+}
318
+
319
+func (logger *Logger) AddHook(hook Hook) {
320
+	logger.mu.Lock()
321
+	defer logger.mu.Unlock()
322
+	logger.Hooks.Add(hook)
323
+}

+ 61
- 0
vendor/src/github.com/sirupsen/logrus/logger_bench_test.go Visa fil

@@ -0,0 +1,61 @@
1
+package logrus
2
+
3
+import (
4
+	"os"
5
+	"testing"
6
+)
7
+
8
+// smallFields is a small size data set for benchmarking
9
+var loggerFields = Fields{
10
+	"foo":   "bar",
11
+	"baz":   "qux",
12
+	"one":   "two",
13
+	"three": "four",
14
+}
15
+
16
+func BenchmarkDummyLogger(b *testing.B) {
17
+	nullf, err := os.OpenFile("/dev/null", os.O_WRONLY, 0666)
18
+	if err != nil {
19
+		b.Fatalf("%v", err)
20
+	}
21
+	defer nullf.Close()
22
+	doLoggerBenchmark(b, nullf, &TextFormatter{DisableColors: true}, smallFields)
23
+}
24
+
25
+func BenchmarkDummyLoggerNoLock(b *testing.B) {
26
+	nullf, err := os.OpenFile("/dev/null", os.O_WRONLY|os.O_APPEND, 0666)
27
+	if err != nil {
28
+		b.Fatalf("%v", err)
29
+	}
30
+	defer nullf.Close()
31
+	doLoggerBenchmarkNoLock(b, nullf, &TextFormatter{DisableColors: true}, smallFields)
32
+}
33
+
34
+func doLoggerBenchmark(b *testing.B, out *os.File, formatter Formatter, fields Fields) {
35
+	logger := Logger{
36
+		Out:       out,
37
+		Level:     InfoLevel,
38
+		Formatter: formatter,
39
+	}
40
+	entry := logger.WithFields(fields)
41
+	b.RunParallel(func(pb *testing.PB) {
42
+		for pb.Next() {
43
+			entry.Info("aaa")
44
+		}
45
+	})
46
+}
47
+
48
+func doLoggerBenchmarkNoLock(b *testing.B, out *os.File, formatter Formatter, fields Fields) {
49
+	logger := Logger{
50
+		Out:       out,
51
+		Level:     InfoLevel,
52
+		Formatter: formatter,
53
+	}
54
+	logger.SetNoLock()
55
+	entry := logger.WithFields(fields)
56
+	b.RunParallel(func(pb *testing.PB) {
57
+		for pb.Next() {
58
+			entry.Info("aaa")
59
+		}
60
+	})
61
+}

+ 143
- 0
vendor/src/github.com/sirupsen/logrus/logrus.go Visa fil

@@ -0,0 +1,143 @@
1
+package logrus
2
+
3
+import (
4
+	"fmt"
5
+	"log"
6
+	"strings"
7
+)
8
+
9
+// Fields type, used to pass to `WithFields`.
10
+type Fields map[string]interface{}
11
+
12
+// Level type
13
+type Level uint32
14
+
15
+// Convert the Level to a string. E.g. PanicLevel becomes "panic".
16
+func (level Level) String() string {
17
+	switch level {
18
+	case DebugLevel:
19
+		return "debug"
20
+	case InfoLevel:
21
+		return "info"
22
+	case WarnLevel:
23
+		return "warning"
24
+	case ErrorLevel:
25
+		return "error"
26
+	case FatalLevel:
27
+		return "fatal"
28
+	case PanicLevel:
29
+		return "panic"
30
+	}
31
+
32
+	return "unknown"
33
+}
34
+
35
+// ParseLevel takes a string level and returns the Logrus log level constant.
36
+func ParseLevel(lvl string) (Level, error) {
37
+	switch strings.ToLower(lvl) {
38
+	case "panic":
39
+		return PanicLevel, nil
40
+	case "fatal":
41
+		return FatalLevel, nil
42
+	case "error":
43
+		return ErrorLevel, nil
44
+	case "warn", "warning":
45
+		return WarnLevel, nil
46
+	case "info":
47
+		return InfoLevel, nil
48
+	case "debug":
49
+		return DebugLevel, nil
50
+	}
51
+
52
+	var l Level
53
+	return l, fmt.Errorf("not a valid logrus Level: %q", lvl)
54
+}
55
+
56
+// A constant exposing all logging levels
57
+var AllLevels = []Level{
58
+	PanicLevel,
59
+	FatalLevel,
60
+	ErrorLevel,
61
+	WarnLevel,
62
+	InfoLevel,
63
+	DebugLevel,
64
+}
65
+
66
+// These are the different logging levels. You can set the logging level to log
67
+// on your instance of logger, obtained with `logrus.New()`.
68
+const (
69
+	// PanicLevel level, highest level of severity. Logs and then calls panic with the
70
+	// message passed to Debug, Info, ...
71
+	PanicLevel Level = iota
72
+	// FatalLevel level. Logs and then calls `os.Exit(1)`. It will exit even if the
73
+	// logging level is set to Panic.
74
+	FatalLevel
75
+	// ErrorLevel level. Logs. Used for errors that should definitely be noted.
76
+	// Commonly used for hooks to send errors to an error tracking service.
77
+	ErrorLevel
78
+	// WarnLevel level. Non-critical entries that deserve eyes.
79
+	WarnLevel
80
+	// InfoLevel level. General operational entries about what's going on inside the
81
+	// application.
82
+	InfoLevel
83
+	// DebugLevel level. Usually only enabled when debugging. Very verbose logging.
84
+	DebugLevel
85
+)
86
+
87
+// Won't compile if StdLogger can't be realized by a log.Logger
88
+var (
89
+	_ StdLogger = &log.Logger{}
90
+	_ StdLogger = &Entry{}
91
+	_ StdLogger = &Logger{}
92
+)
93
+
94
+// StdLogger is what your logrus-enabled library should take, that way
95
+// it'll accept a stdlib logger and a logrus logger. There's no standard
96
+// interface, this is the closest we get, unfortunately.
97
+type StdLogger interface {
98
+	Print(...interface{})
99
+	Printf(string, ...interface{})
100
+	Println(...interface{})
101
+
102
+	Fatal(...interface{})
103
+	Fatalf(string, ...interface{})
104
+	Fatalln(...interface{})
105
+
106
+	Panic(...interface{})
107
+	Panicf(string, ...interface{})
108
+	Panicln(...interface{})
109
+}
110
+
111
+// The FieldLogger interface generalizes the Entry and Logger types
112
+type FieldLogger interface {
113
+	WithField(key string, value interface{}) *Entry
114
+	WithFields(fields Fields) *Entry
115
+	WithError(err error) *Entry
116
+
117
+	Debugf(format string, args ...interface{})
118
+	Infof(format string, args ...interface{})
119
+	Printf(format string, args ...interface{})
120
+	Warnf(format string, args ...interface{})
121
+	Warningf(format string, args ...interface{})
122
+	Errorf(format string, args ...interface{})
123
+	Fatalf(format string, args ...interface{})
124
+	Panicf(format string, args ...interface{})
125
+
126
+	Debug(args ...interface{})
127
+	Info(args ...interface{})
128
+	Print(args ...interface{})
129
+	Warn(args ...interface{})
130
+	Warning(args ...interface{})
131
+	Error(args ...interface{})
132
+	Fatal(args ...interface{})
133
+	Panic(args ...interface{})
134
+
135
+	Debugln(args ...interface{})
136
+	Infoln(args ...interface{})
137
+	Println(args ...interface{})
138
+	Warnln(args ...interface{})
139
+	Warningln(args ...interface{})
140
+	Errorln(args ...interface{})
141
+	Fatalln(args ...interface{})
142
+	Panicln(args ...interface{})
143
+}

+ 386
- 0
vendor/src/github.com/sirupsen/logrus/logrus_test.go Visa fil

@@ -0,0 +1,386 @@
1
+package logrus
2
+
3
+import (
4
+	"bytes"
5
+	"encoding/json"
6
+	"strconv"
7
+	"strings"
8
+	"sync"
9
+	"testing"
10
+
11
+	"github.com/stretchr/testify/assert"
12
+)
13
+
14
+func LogAndAssertJSON(t *testing.T, log func(*Logger), assertions func(fields Fields)) {
15
+	var buffer bytes.Buffer
16
+	var fields Fields
17
+
18
+	logger := New()
19
+	logger.Out = &buffer
20
+	logger.Formatter = new(JSONFormatter)
21
+
22
+	log(logger)
23
+
24
+	err := json.Unmarshal(buffer.Bytes(), &fields)
25
+	assert.Nil(t, err)
26
+
27
+	assertions(fields)
28
+}
29
+
30
+func LogAndAssertText(t *testing.T, log func(*Logger), assertions func(fields map[string]string)) {
31
+	var buffer bytes.Buffer
32
+
33
+	logger := New()
34
+	logger.Out = &buffer
35
+	logger.Formatter = &TextFormatter{
36
+		DisableColors: true,
37
+	}
38
+
39
+	log(logger)
40
+
41
+	fields := make(map[string]string)
42
+	for _, kv := range strings.Split(buffer.String(), " ") {
43
+		if !strings.Contains(kv, "=") {
44
+			continue
45
+		}
46
+		kvArr := strings.Split(kv, "=")
47
+		key := strings.TrimSpace(kvArr[0])
48
+		val := kvArr[1]
49
+		if kvArr[1][0] == '"' {
50
+			var err error
51
+			val, err = strconv.Unquote(val)
52
+			assert.NoError(t, err)
53
+		}
54
+		fields[key] = val
55
+	}
56
+	assertions(fields)
57
+}
58
+
59
+func TestPrint(t *testing.T) {
60
+	LogAndAssertJSON(t, func(log *Logger) {
61
+		log.Print("test")
62
+	}, func(fields Fields) {
63
+		assert.Equal(t, fields["msg"], "test")
64
+		assert.Equal(t, fields["level"], "info")
65
+	})
66
+}
67
+
68
+func TestInfo(t *testing.T) {
69
+	LogAndAssertJSON(t, func(log *Logger) {
70
+		log.Info("test")
71
+	}, func(fields Fields) {
72
+		assert.Equal(t, fields["msg"], "test")
73
+		assert.Equal(t, fields["level"], "info")
74
+	})
75
+}
76
+
77
+func TestWarn(t *testing.T) {
78
+	LogAndAssertJSON(t, func(log *Logger) {
79
+		log.Warn("test")
80
+	}, func(fields Fields) {
81
+		assert.Equal(t, fields["msg"], "test")
82
+		assert.Equal(t, fields["level"], "warning")
83
+	})
84
+}
85
+
86
+func TestInfolnShouldAddSpacesBetweenStrings(t *testing.T) {
87
+	LogAndAssertJSON(t, func(log *Logger) {
88
+		log.Infoln("test", "test")
89
+	}, func(fields Fields) {
90
+		assert.Equal(t, fields["msg"], "test test")
91
+	})
92
+}
93
+
94
+func TestInfolnShouldAddSpacesBetweenStringAndNonstring(t *testing.T) {
95
+	LogAndAssertJSON(t, func(log *Logger) {
96
+		log.Infoln("test", 10)
97
+	}, func(fields Fields) {
98
+		assert.Equal(t, fields["msg"], "test 10")
99
+	})
100
+}
101
+
102
+func TestInfolnShouldAddSpacesBetweenTwoNonStrings(t *testing.T) {
103
+	LogAndAssertJSON(t, func(log *Logger) {
104
+		log.Infoln(10, 10)
105
+	}, func(fields Fields) {
106
+		assert.Equal(t, fields["msg"], "10 10")
107
+	})
108
+}
109
+
110
+func TestInfoShouldAddSpacesBetweenTwoNonStrings(t *testing.T) {
111
+	LogAndAssertJSON(t, func(log *Logger) {
112
+		log.Infoln(10, 10)
113
+	}, func(fields Fields) {
114
+		assert.Equal(t, fields["msg"], "10 10")
115
+	})
116
+}
117
+
118
+func TestInfoShouldNotAddSpacesBetweenStringAndNonstring(t *testing.T) {
119
+	LogAndAssertJSON(t, func(log *Logger) {
120
+		log.Info("test", 10)
121
+	}, func(fields Fields) {
122
+		assert.Equal(t, fields["msg"], "test10")
123
+	})
124
+}
125
+
126
+func TestInfoShouldNotAddSpacesBetweenStrings(t *testing.T) {
127
+	LogAndAssertJSON(t, func(log *Logger) {
128
+		log.Info("test", "test")
129
+	}, func(fields Fields) {
130
+		assert.Equal(t, fields["msg"], "testtest")
131
+	})
132
+}
133
+
134
+func TestWithFieldsShouldAllowAssignments(t *testing.T) {
135
+	var buffer bytes.Buffer
136
+	var fields Fields
137
+
138
+	logger := New()
139
+	logger.Out = &buffer
140
+	logger.Formatter = new(JSONFormatter)
141
+
142
+	localLog := logger.WithFields(Fields{
143
+		"key1": "value1",
144
+	})
145
+
146
+	localLog.WithField("key2", "value2").Info("test")
147
+	err := json.Unmarshal(buffer.Bytes(), &fields)
148
+	assert.Nil(t, err)
149
+
150
+	assert.Equal(t, "value2", fields["key2"])
151
+	assert.Equal(t, "value1", fields["key1"])
152
+
153
+	buffer = bytes.Buffer{}
154
+	fields = Fields{}
155
+	localLog.Info("test")
156
+	err = json.Unmarshal(buffer.Bytes(), &fields)
157
+	assert.Nil(t, err)
158
+
159
+	_, ok := fields["key2"]
160
+	assert.Equal(t, false, ok)
161
+	assert.Equal(t, "value1", fields["key1"])
162
+}
163
+
164
+func TestUserSuppliedFieldDoesNotOverwriteDefaults(t *testing.T) {
165
+	LogAndAssertJSON(t, func(log *Logger) {
166
+		log.WithField("msg", "hello").Info("test")
167
+	}, func(fields Fields) {
168
+		assert.Equal(t, fields["msg"], "test")
169
+	})
170
+}
171
+
172
+func TestUserSuppliedMsgFieldHasPrefix(t *testing.T) {
173
+	LogAndAssertJSON(t, func(log *Logger) {
174
+		log.WithField("msg", "hello").Info("test")
175
+	}, func(fields Fields) {
176
+		assert.Equal(t, fields["msg"], "test")
177
+		assert.Equal(t, fields["fields.msg"], "hello")
178
+	})
179
+}
180
+
181
+func TestUserSuppliedTimeFieldHasPrefix(t *testing.T) {
182
+	LogAndAssertJSON(t, func(log *Logger) {
183
+		log.WithField("time", "hello").Info("test")
184
+	}, func(fields Fields) {
185
+		assert.Equal(t, fields["fields.time"], "hello")
186
+	})
187
+}
188
+
189
+func TestUserSuppliedLevelFieldHasPrefix(t *testing.T) {
190
+	LogAndAssertJSON(t, func(log *Logger) {
191
+		log.WithField("level", 1).Info("test")
192
+	}, func(fields Fields) {
193
+		assert.Equal(t, fields["level"], "info")
194
+		assert.Equal(t, fields["fields.level"], 1.0) // JSON has floats only
195
+	})
196
+}
197
+
198
+func TestDefaultFieldsAreNotPrefixed(t *testing.T) {
199
+	LogAndAssertText(t, func(log *Logger) {
200
+		ll := log.WithField("herp", "derp")
201
+		ll.Info("hello")
202
+		ll.Info("bye")
203
+	}, func(fields map[string]string) {
204
+		for _, fieldName := range []string{"fields.level", "fields.time", "fields.msg"} {
205
+			if _, ok := fields[fieldName]; ok {
206
+				t.Fatalf("should not have prefixed %q: %v", fieldName, fields)
207
+			}
208
+		}
209
+	})
210
+}
211
+
212
+func TestDoubleLoggingDoesntPrefixPreviousFields(t *testing.T) {
213
+
214
+	var buffer bytes.Buffer
215
+	var fields Fields
216
+
217
+	logger := New()
218
+	logger.Out = &buffer
219
+	logger.Formatter = new(JSONFormatter)
220
+
221
+	llog := logger.WithField("context", "eating raw fish")
222
+
223
+	llog.Info("looks delicious")
224
+
225
+	err := json.Unmarshal(buffer.Bytes(), &fields)
226
+	assert.NoError(t, err, "should have decoded first message")
227
+	assert.Equal(t, len(fields), 4, "should only have msg/time/level/context fields")
228
+	assert.Equal(t, fields["msg"], "looks delicious")
229
+	assert.Equal(t, fields["context"], "eating raw fish")
230
+
231
+	buffer.Reset()
232
+
233
+	llog.Warn("omg it is!")
234
+
235
+	err = json.Unmarshal(buffer.Bytes(), &fields)
236
+	assert.NoError(t, err, "should have decoded second message")
237
+	assert.Equal(t, len(fields), 4, "should only have msg/time/level/context fields")
238
+	assert.Equal(t, fields["msg"], "omg it is!")
239
+	assert.Equal(t, fields["context"], "eating raw fish")
240
+	assert.Nil(t, fields["fields.msg"], "should not have prefixed previous `msg` entry")
241
+
242
+}
243
+
244
+func TestConvertLevelToString(t *testing.T) {
245
+	assert.Equal(t, "debug", DebugLevel.String())
246
+	assert.Equal(t, "info", InfoLevel.String())
247
+	assert.Equal(t, "warning", WarnLevel.String())
248
+	assert.Equal(t, "error", ErrorLevel.String())
249
+	assert.Equal(t, "fatal", FatalLevel.String())
250
+	assert.Equal(t, "panic", PanicLevel.String())
251
+}
252
+
253
+func TestParseLevel(t *testing.T) {
254
+	l, err := ParseLevel("panic")
255
+	assert.Nil(t, err)
256
+	assert.Equal(t, PanicLevel, l)
257
+
258
+	l, err = ParseLevel("PANIC")
259
+	assert.Nil(t, err)
260
+	assert.Equal(t, PanicLevel, l)
261
+
262
+	l, err = ParseLevel("fatal")
263
+	assert.Nil(t, err)
264
+	assert.Equal(t, FatalLevel, l)
265
+
266
+	l, err = ParseLevel("FATAL")
267
+	assert.Nil(t, err)
268
+	assert.Equal(t, FatalLevel, l)
269
+
270
+	l, err = ParseLevel("error")
271
+	assert.Nil(t, err)
272
+	assert.Equal(t, ErrorLevel, l)
273
+
274
+	l, err = ParseLevel("ERROR")
275
+	assert.Nil(t, err)
276
+	assert.Equal(t, ErrorLevel, l)
277
+
278
+	l, err = ParseLevel("warn")
279
+	assert.Nil(t, err)
280
+	assert.Equal(t, WarnLevel, l)
281
+
282
+	l, err = ParseLevel("WARN")
283
+	assert.Nil(t, err)
284
+	assert.Equal(t, WarnLevel, l)
285
+
286
+	l, err = ParseLevel("warning")
287
+	assert.Nil(t, err)
288
+	assert.Equal(t, WarnLevel, l)
289
+
290
+	l, err = ParseLevel("WARNING")
291
+	assert.Nil(t, err)
292
+	assert.Equal(t, WarnLevel, l)
293
+
294
+	l, err = ParseLevel("info")
295
+	assert.Nil(t, err)
296
+	assert.Equal(t, InfoLevel, l)
297
+
298
+	l, err = ParseLevel("INFO")
299
+	assert.Nil(t, err)
300
+	assert.Equal(t, InfoLevel, l)
301
+
302
+	l, err = ParseLevel("debug")
303
+	assert.Nil(t, err)
304
+	assert.Equal(t, DebugLevel, l)
305
+
306
+	l, err = ParseLevel("DEBUG")
307
+	assert.Nil(t, err)
308
+	assert.Equal(t, DebugLevel, l)
309
+
310
+	l, err = ParseLevel("invalid")
311
+	assert.Equal(t, "not a valid logrus Level: \"invalid\"", err.Error())
312
+}
313
+
314
+func TestGetSetLevelRace(t *testing.T) {
315
+	wg := sync.WaitGroup{}
316
+	for i := 0; i < 100; i++ {
317
+		wg.Add(1)
318
+		go func(i int) {
319
+			defer wg.Done()
320
+			if i%2 == 0 {
321
+				SetLevel(InfoLevel)
322
+			} else {
323
+				GetLevel()
324
+			}
325
+		}(i)
326
+
327
+	}
328
+	wg.Wait()
329
+}
330
+
331
+func TestLoggingRace(t *testing.T) {
332
+	logger := New()
333
+
334
+	var wg sync.WaitGroup
335
+	wg.Add(100)
336
+
337
+	for i := 0; i < 100; i++ {
338
+		go func() {
339
+			logger.Info("info")
340
+			wg.Done()
341
+		}()
342
+	}
343
+	wg.Wait()
344
+}
345
+
346
+// Compile test
347
+func TestLogrusInterface(t *testing.T) {
348
+	var buffer bytes.Buffer
349
+	fn := func(l FieldLogger) {
350
+		b := l.WithField("key", "value")
351
+		b.Debug("Test")
352
+	}
353
+	// test logger
354
+	logger := New()
355
+	logger.Out = &buffer
356
+	fn(logger)
357
+
358
+	// test Entry
359
+	e := logger.WithField("another", "value")
360
+	fn(e)
361
+}
362
+
363
+// Implements io.Writer using channels for synchronization, so we can wait on
364
+// the Entry.Writer goroutine to write in a non-racey way. This does assume that
365
+// there is a single call to Logger.Out for each message.
366
+type channelWriter chan []byte
367
+
368
+func (cw channelWriter) Write(p []byte) (int, error) {
369
+	cw <- p
370
+	return len(p), nil
371
+}
372
+
373
+func TestEntryWriter(t *testing.T) {
374
+	cw := channelWriter(make(chan []byte, 1))
375
+	log := New()
376
+	log.Out = cw
377
+	log.Formatter = new(JSONFormatter)
378
+	log.WithField("foo", "bar").WriterLevel(WarnLevel).Write([]byte("hello\n"))
379
+
380
+	bs := <-cw
381
+	var fields Fields
382
+	err := json.Unmarshal(bs, &fields)
383
+	assert.Nil(t, err)
384
+	assert.Equal(t, fields["foo"], "bar")
385
+	assert.Equal(t, fields["level"], "warning")
386
+}

+ 10
- 0
vendor/src/github.com/sirupsen/logrus/terminal_bsd.go Visa fil

@@ -0,0 +1,10 @@
1
+// +build darwin freebsd openbsd netbsd dragonfly
2
+// +build !appengine
3
+
4
+package logrus
5
+
6
+import "golang.org/x/sys/unix"
7
+
8
+const ioctlReadTermios = unix.TIOCGETA
9
+
10
+type Termios unix.Termios

+ 11
- 0
vendor/src/github.com/sirupsen/logrus/terminal_check_appengine.go Visa fil

@@ -0,0 +1,11 @@
1
+// +build appengine
2
+
3
+package logrus
4
+
5
+import (
6
+	"io"
7
+)
8
+
9
+func checkIfTerminal(w io.Writer) bool {
10
+	return true
11
+}

+ 19
- 0
vendor/src/github.com/sirupsen/logrus/terminal_check_notappengine.go Visa fil

@@ -0,0 +1,19 @@
1
+// +build !appengine
2
+
3
+package logrus
4
+
5
+import (
6
+	"io"
7
+	"os"
8
+
9
+	"golang.org/x/crypto/ssh/terminal"
10
+)
11
+
12
+func checkIfTerminal(w io.Writer) bool {
13
+	switch v := w.(type) {
14
+	case *os.File:
15
+		return terminal.IsTerminal(int(v.Fd()))
16
+	default:
17
+		return false
18
+	}
19
+}

+ 14
- 0
vendor/src/github.com/sirupsen/logrus/terminal_linux.go Visa fil

@@ -0,0 +1,14 @@
1
+// Based on ssh/terminal:
2
+// Copyright 2013 The Go Authors. All rights reserved.
3
+// Use of this source code is governed by a BSD-style
4
+// license that can be found in the LICENSE file.
5
+
6
+// +build !appengine
7
+
8
+package logrus
9
+
10
+import "golang.org/x/sys/unix"
11
+
12
+const ioctlReadTermios = unix.TCGETS
13
+
14
+type Termios unix.Termios

+ 178
- 0
vendor/src/github.com/sirupsen/logrus/text_formatter.go Visa fil

@@ -0,0 +1,178 @@
1
+package logrus
2
+
3
+import (
4
+	"bytes"
5
+	"fmt"
6
+	"sort"
7
+	"strings"
8
+	"sync"
9
+	"time"
10
+)
11
+
12
+const (
13
+	nocolor = 0
14
+	red     = 31
15
+	green   = 32
16
+	yellow  = 33
17
+	blue    = 36
18
+	gray    = 37
19
+)
20
+
21
+var (
22
+	baseTimestamp time.Time
23
+)
24
+
25
+func init() {
26
+	baseTimestamp = time.Now()
27
+}
28
+
29
+// TextFormatter formats logs into text
30
+type TextFormatter struct {
31
+	// Set to true to bypass checking for a TTY before outputting colors.
32
+	ForceColors bool
33
+
34
+	// Force disabling colors.
35
+	DisableColors bool
36
+
37
+	// Disable timestamp logging. useful when output is redirected to logging
38
+	// system that already adds timestamps.
39
+	DisableTimestamp bool
40
+
41
+	// Enable logging the full timestamp when a TTY is attached instead of just
42
+	// the time passed since beginning of execution.
43
+	FullTimestamp bool
44
+
45
+	// TimestampFormat to use for display when a full timestamp is printed
46
+	TimestampFormat string
47
+
48
+	// The fields are sorted by default for a consistent output. For applications
49
+	// that log extremely frequently and don't use the JSON formatter this may not
50
+	// be desired.
51
+	DisableSorting bool
52
+
53
+	// QuoteEmptyFields will wrap empty fields in quotes if true
54
+	QuoteEmptyFields bool
55
+
56
+	// Whether the logger's out is to a terminal
57
+	isTerminal bool
58
+
59
+	sync.Once
60
+}
61
+
62
+func (f *TextFormatter) init(entry *Entry) {
63
+	if entry.Logger != nil {
64
+		f.isTerminal = checkIfTerminal(entry.Logger.Out)
65
+	}
66
+}
67
+
68
+// Format renders a single log entry
69
+func (f *TextFormatter) Format(entry *Entry) ([]byte, error) {
70
+	var b *bytes.Buffer
71
+	keys := make([]string, 0, len(entry.Data))
72
+	for k := range entry.Data {
73
+		keys = append(keys, k)
74
+	}
75
+
76
+	if !f.DisableSorting {
77
+		sort.Strings(keys)
78
+	}
79
+	if entry.Buffer != nil {
80
+		b = entry.Buffer
81
+	} else {
82
+		b = &bytes.Buffer{}
83
+	}
84
+
85
+	prefixFieldClashes(entry.Data)
86
+
87
+	f.Do(func() { f.init(entry) })
88
+
89
+	isColored := (f.ForceColors || f.isTerminal) && !f.DisableColors
90
+
91
+	timestampFormat := f.TimestampFormat
92
+	if timestampFormat == "" {
93
+		timestampFormat = defaultTimestampFormat
94
+	}
95
+	if isColored {
96
+		f.printColored(b, entry, keys, timestampFormat)
97
+	} else {
98
+		if !f.DisableTimestamp {
99
+			f.appendKeyValue(b, "time", entry.Time.Format(timestampFormat))
100
+		}
101
+		f.appendKeyValue(b, "level", entry.Level.String())
102
+		if entry.Message != "" {
103
+			f.appendKeyValue(b, "msg", entry.Message)
104
+		}
105
+		for _, key := range keys {
106
+			f.appendKeyValue(b, key, entry.Data[key])
107
+		}
108
+	}
109
+
110
+	b.WriteByte('\n')
111
+	return b.Bytes(), nil
112
+}
113
+
114
+func (f *TextFormatter) printColored(b *bytes.Buffer, entry *Entry, keys []string, timestampFormat string) {
115
+	var levelColor int
116
+	switch entry.Level {
117
+	case DebugLevel:
118
+		levelColor = gray
119
+	case WarnLevel:
120
+		levelColor = yellow
121
+	case ErrorLevel, FatalLevel, PanicLevel:
122
+		levelColor = red
123
+	default:
124
+		levelColor = blue
125
+	}
126
+
127
+	levelText := strings.ToUpper(entry.Level.String())[0:4]
128
+
129
+	if f.DisableTimestamp {
130
+		fmt.Fprintf(b, "\x1b[%dm%s\x1b[0m %-44s ", levelColor, levelText, entry.Message)
131
+	} else if !f.FullTimestamp {
132
+		fmt.Fprintf(b, "\x1b[%dm%s\x1b[0m[%04d] %-44s ", levelColor, levelText, int(entry.Time.Sub(baseTimestamp)/time.Second), entry.Message)
133
+	} else {
134
+		fmt.Fprintf(b, "\x1b[%dm%s\x1b[0m[%s] %-44s ", levelColor, levelText, entry.Time.Format(timestampFormat), entry.Message)
135
+	}
136
+	for _, k := range keys {
137
+		v := entry.Data[k]
138
+		fmt.Fprintf(b, " \x1b[%dm%s\x1b[0m=", levelColor, k)
139
+		f.appendValue(b, v)
140
+	}
141
+}
142
+
143
+func (f *TextFormatter) needsQuoting(text string) bool {
144
+	if f.QuoteEmptyFields && len(text) == 0 {
145
+		return true
146
+	}
147
+	for _, ch := range text {
148
+		if !((ch >= 'a' && ch <= 'z') ||
149
+			(ch >= 'A' && ch <= 'Z') ||
150
+			(ch >= '0' && ch <= '9') ||
151
+			ch == '-' || ch == '.' || ch == '_' || ch == '/' || ch == '@' || ch == '^' || ch == '+') {
152
+			return true
153
+		}
154
+	}
155
+	return false
156
+}
157
+
158
+func (f *TextFormatter) appendKeyValue(b *bytes.Buffer, key string, value interface{}) {
159
+	if b.Len() > 0 {
160
+		b.WriteByte(' ')
161
+	}
162
+	b.WriteString(key)
163
+	b.WriteByte('=')
164
+	f.appendValue(b, value)
165
+}
166
+
167
+func (f *TextFormatter) appendValue(b *bytes.Buffer, value interface{}) {
168
+	stringVal, ok := value.(string)
169
+	if !ok {
170
+		stringVal = fmt.Sprint(value)
171
+	}
172
+
173
+	if !f.needsQuoting(stringVal) {
174
+		b.WriteString(stringVal)
175
+	} else {
176
+		b.WriteString(fmt.Sprintf("%q", stringVal))
177
+	}
178
+}

+ 141
- 0
vendor/src/github.com/sirupsen/logrus/text_formatter_test.go Visa fil

@@ -0,0 +1,141 @@
1
+package logrus
2
+
3
+import (
4
+	"bytes"
5
+	"errors"
6
+	"fmt"
7
+	"strings"
8
+	"testing"
9
+	"time"
10
+)
11
+
12
+func TestFormatting(t *testing.T) {
13
+	tf := &TextFormatter{DisableColors: true}
14
+
15
+	testCases := []struct {
16
+		value    string
17
+		expected string
18
+	}{
19
+		{`foo`, "time=\"0001-01-01T00:00:00Z\" level=panic test=foo\n"},
20
+	}
21
+
22
+	for _, tc := range testCases {
23
+		b, _ := tf.Format(WithField("test", tc.value))
24
+
25
+		if string(b) != tc.expected {
26
+			t.Errorf("formatting expected for %q (result was %q instead of %q)", tc.value, string(b), tc.expected)
27
+		}
28
+	}
29
+}
30
+
31
+func TestQuoting(t *testing.T) {
32
+	tf := &TextFormatter{DisableColors: true}
33
+
34
+	checkQuoting := func(q bool, value interface{}) {
35
+		b, _ := tf.Format(WithField("test", value))
36
+		idx := bytes.Index(b, ([]byte)("test="))
37
+		cont := bytes.Contains(b[idx+5:], []byte("\""))
38
+		if cont != q {
39
+			if q {
40
+				t.Errorf("quoting expected for: %#v", value)
41
+			} else {
42
+				t.Errorf("quoting not expected for: %#v", value)
43
+			}
44
+		}
45
+	}
46
+
47
+	checkQuoting(false, "")
48
+	checkQuoting(false, "abcd")
49
+	checkQuoting(false, "v1.0")
50
+	checkQuoting(false, "1234567890")
51
+	checkQuoting(false, "/foobar")
52
+	checkQuoting(false, "foo_bar")
53
+	checkQuoting(false, "foo@bar")
54
+	checkQuoting(false, "foobar^")
55
+	checkQuoting(false, "+/-_^@f.oobar")
56
+	checkQuoting(true, "foobar$")
57
+	checkQuoting(true, "&foobar")
58
+	checkQuoting(true, "x y")
59
+	checkQuoting(true, "x,y")
60
+	checkQuoting(false, errors.New("invalid"))
61
+	checkQuoting(true, errors.New("invalid argument"))
62
+
63
+	// Test for quoting empty fields.
64
+	tf.QuoteEmptyFields = true
65
+	checkQuoting(true, "")
66
+	checkQuoting(false, "abcd")
67
+	checkQuoting(true, errors.New("invalid argument"))
68
+}
69
+
70
+func TestEscaping(t *testing.T) {
71
+	tf := &TextFormatter{DisableColors: true}
72
+
73
+	testCases := []struct {
74
+		value    string
75
+		expected string
76
+	}{
77
+		{`ba"r`, `ba\"r`},
78
+		{`ba'r`, `ba'r`},
79
+	}
80
+
81
+	for _, tc := range testCases {
82
+		b, _ := tf.Format(WithField("test", tc.value))
83
+		if !bytes.Contains(b, []byte(tc.expected)) {
84
+			t.Errorf("escaping expected for %q (result was %q instead of %q)", tc.value, string(b), tc.expected)
85
+		}
86
+	}
87
+}
88
+
89
+func TestEscaping_Interface(t *testing.T) {
90
+	tf := &TextFormatter{DisableColors: true}
91
+
92
+	ts := time.Now()
93
+
94
+	testCases := []struct {
95
+		value    interface{}
96
+		expected string
97
+	}{
98
+		{ts, fmt.Sprintf("\"%s\"", ts.String())},
99
+		{errors.New("error: something went wrong"), "\"error: something went wrong\""},
100
+	}
101
+
102
+	for _, tc := range testCases {
103
+		b, _ := tf.Format(WithField("test", tc.value))
104
+		if !bytes.Contains(b, []byte(tc.expected)) {
105
+			t.Errorf("escaping expected for %q (result was %q instead of %q)", tc.value, string(b), tc.expected)
106
+		}
107
+	}
108
+}
109
+
110
+func TestTimestampFormat(t *testing.T) {
111
+	checkTimeStr := func(format string) {
112
+		customFormatter := &TextFormatter{DisableColors: true, TimestampFormat: format}
113
+		customStr, _ := customFormatter.Format(WithField("test", "test"))
114
+		timeStart := bytes.Index(customStr, ([]byte)("time="))
115
+		timeEnd := bytes.Index(customStr, ([]byte)("level="))
116
+		timeStr := customStr[timeStart+5+len("\"") : timeEnd-1-len("\"")]
117
+		if format == "" {
118
+			format = time.RFC3339
119
+		}
120
+		_, e := time.Parse(format, (string)(timeStr))
121
+		if e != nil {
122
+			t.Errorf("time string \"%s\" did not match provided time format \"%s\": %s", timeStr, format, e)
123
+		}
124
+	}
125
+
126
+	checkTimeStr("2006-01-02T15:04:05.000000000Z07:00")
127
+	checkTimeStr("Mon Jan _2 15:04:05 2006")
128
+	checkTimeStr("")
129
+}
130
+
131
+func TestDisableTimestampWithColoredOutput(t *testing.T) {
132
+	tf := &TextFormatter{DisableTimestamp: true, ForceColors: true}
133
+
134
+	b, _ := tf.Format(WithField("test", "test"))
135
+	if strings.Contains(string(b), "[0000]") {
136
+		t.Error("timestamp not expected when DisableTimestamp is true")
137
+	}
138
+}
139
+
140
+// TODO add tests for sorting etc., this requires a parser for the text
141
+// formatter output.

+ 62
- 0
vendor/src/github.com/sirupsen/logrus/writer.go Visa fil

@@ -0,0 +1,62 @@
1
+package logrus
2
+
3
+import (
4
+	"bufio"
5
+	"io"
6
+	"runtime"
7
+)
8
+
9
+func (logger *Logger) Writer() *io.PipeWriter {
10
+	return logger.WriterLevel(InfoLevel)
11
+}
12
+
13
+func (logger *Logger) WriterLevel(level Level) *io.PipeWriter {
14
+	return NewEntry(logger).WriterLevel(level)
15
+}
16
+
17
+func (entry *Entry) Writer() *io.PipeWriter {
18
+	return entry.WriterLevel(InfoLevel)
19
+}
20
+
21
+func (entry *Entry) WriterLevel(level Level) *io.PipeWriter {
22
+	reader, writer := io.Pipe()
23
+
24
+	var printFunc func(args ...interface{})
25
+
26
+	switch level {
27
+	case DebugLevel:
28
+		printFunc = entry.Debug
29
+	case InfoLevel:
30
+		printFunc = entry.Info
31
+	case WarnLevel:
32
+		printFunc = entry.Warn
33
+	case ErrorLevel:
34
+		printFunc = entry.Error
35
+	case FatalLevel:
36
+		printFunc = entry.Fatal
37
+	case PanicLevel:
38
+		printFunc = entry.Panic
39
+	default:
40
+		printFunc = entry.Print
41
+	}
42
+
43
+	go entry.writerScanner(reader, printFunc)
44
+	runtime.SetFinalizer(writer, writerFinalizer)
45
+
46
+	return writer
47
+}
48
+
49
+func (entry *Entry) writerScanner(reader *io.PipeReader, printFunc func(args ...interface{})) {
50
+	scanner := bufio.NewScanner(reader)
51
+	for scanner.Scan() {
52
+		printFunc(scanner.Text())
53
+	}
54
+	if err := scanner.Err(); err != nil {
55
+		entry.Errorf("Error while reading from Writer: %s", err)
56
+	}
57
+	reader.Close()
58
+}
59
+
60
+func writerFinalizer(writer *io.PipeWriter) {
61
+	writer.Close()
62
+}

+ 173
- 0
vendor/src/golang.org/x/sys/unix/README.md Visa fil

@@ -0,0 +1,173 @@
1
+# Building `sys/unix`
2
+
3
+The sys/unix package provides access to the raw system call interface of the
4
+underlying operating system. See: https://godoc.org/golang.org/x/sys/unix
5
+
6
+Porting Go to a new architecture/OS combination or adding syscalls, types, or
7
+constants to an existing architecture/OS pair requires some manual effort;
8
+however, there are tools that automate much of the process.
9
+
10
+## Build Systems
11
+
12
+There are currently two ways we generate the necessary files. We are currently
13
+migrating the build system to use containers so the builds are reproducible.
14
+This is being done on an OS-by-OS basis. Please update this documentation as
15
+components of the build system change.
16
+
17
+### Old Build System (currently for `GOOS != "Linux" || GOARCH == "sparc64"`)
18
+
19
+The old build system generates the Go files based on the C header files
20
+present on your system. This means that files
21
+for a given GOOS/GOARCH pair must be generated on a system with that OS and
22
+architecture. This also means that the generated code can differ from system
23
+to system, based on differences in the header files.
24
+
25
+To avoid this, if you are using the old build system, only generate the Go
26
+files on an installation with unmodified header files. It is also important to
27
+keep track of which version of the OS the files were generated from (ex.
28
+Darwin 14 vs Darwin 15). This makes it easier to track the progress of changes
29
+and have each OS upgrade correspond to a single change.
30
+
31
+To build the files for your current OS and architecture, make sure GOOS and
32
+GOARCH are set correctly and run `mkall.sh`. This will generate the files for
33
+your specific system. Running `mkall.sh -n` shows the commands that will be run.
34
+
35
+Requirements: bash, perl, go
36
+
37
+### New Build System (currently for `GOOS == "Linux" && GOARCH != "sparc64"`)
38
+
39
+The new build system uses a Docker container to generate the go files directly
40
+from source checkouts of the kernel and various system libraries. This means
41
+that on any platform that supports Docker, all the files using the new build
42
+system can be generated at once, and generated files will not change based on
43
+what the person running the scripts has installed on their computer.
44
+
45
+The OS specific files for the new build system are located in the `${GOOS}`
46
+directory, and the build is coordinated by the `${GOOS}/mkall.go` program. When
47
+the kernel or system library updates, modify the Dockerfile at
48
+`${GOOS}/Dockerfile` to checkout the new release of the source.
49
+
50
+To build all the files under the new build system, you must be on an amd64/Linux
51
+system and have your GOOS and GOARCH set accordingly. Running `mkall.sh` will
52
+then generate all of the files for all of the GOOS/GOARCH pairs in the new build
53
+system. Running `mkall.sh -n` shows the commands that will be run.
54
+
55
+Requirements: bash, perl, go, docker
56
+
57
+## Component files
58
+
59
+This section describes the various files used in the code generation process.
60
+It also contains instructions on how to modify these files to add a new
61
+architecture/OS or to add additional syscalls, types, or constants. Note that
62
+if you are using the new build system, the scripts cannot be called normally.
63
+They must be called from within the docker container.
64
+
65
+### asm files
66
+
67
+The hand-written assembly file at `asm_${GOOS}_${GOARCH}.s` implements system
68
+call dispatch. There are three entry points:
69
+```
70
+  func Syscall(trap, a1, a2, a3 uintptr) (r1, r2, err uintptr)
71
+  func Syscall6(trap, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2, err uintptr)
72
+  func RawSyscall(trap, a1, a2, a3 uintptr) (r1, r2, err uintptr)
73
+```
74
+The first and second are the standard ones; they differ only in how many
75
+arguments can be passed to the kernel. The third is for low-level use by the
76
+ForkExec wrapper. Unlike the first two, it does not call into the scheduler to
77
+let it know that a system call is running.
78
+
79
+When porting Go to an new architecture/OS, this file must be implemented for
80
+each GOOS/GOARCH pair.
81
+
82
+### mksysnum
83
+
84
+Mksysnum is a script located at `${GOOS}/mksysnum.pl` (or `mksysnum_${GOOS}.pl`
85
+for the old system). This script takes in a list of header files containing the
86
+syscall number declarations and parses them to produce the corresponding list of
87
+Go numeric constants. See `zsysnum_${GOOS}_${GOARCH}.go` for the generated
88
+constants.
89
+
90
+Adding new syscall numbers is mostly done by running the build on a sufficiently
91
+new installation of the target OS (or updating the source checkouts for the
92
+new build system). However, depending on the OS, you make need to update the
93
+parsing in mksysnum.
94
+
95
+### mksyscall.pl
96
+
97
+The `syscall.go`, `syscall_${GOOS}.go`, `syscall_${GOOS}_${GOARCH}.go` are
98
+hand-written Go files which implement system calls (for unix, the specific OS,
99
+or the specific OS/Architecture pair respectively) that need special handling
100
+and list `//sys` comments giving prototypes for ones that can be generated.
101
+
102
+The mksyscall.pl script takes the `//sys` and `//sysnb` comments and converts
103
+them into syscalls. This requires the name of the prototype in the comment to
104
+match a syscall number in the `zsysnum_${GOOS}_${GOARCH}.go` file. The function
105
+prototype can be exported (capitalized) or not.
106
+
107
+Adding a new syscall often just requires adding a new `//sys` function prototype
108
+with the desired arguments and a capitalized name so it is exported. However, if
109
+you want the interface to the syscall to be different, often one will make an
110
+unexported `//sys` prototype, an then write a custom wrapper in
111
+`syscall_${GOOS}.go`.
112
+
113
+### types files
114
+
115
+For each OS, there is a hand-written Go file at `${GOOS}/types.go` (or
116
+`types_${GOOS}.go` on the old system). This file includes standard C headers and
117
+creates Go type aliases to the corresponding C types. The file is then fed
118
+through godef to get the Go compatible definitions. Finally, the generated code
119
+is fed though mkpost.go to format the code correctly and remove any hidden or
120
+private identifiers. This cleaned-up code is written to
121
+`ztypes_${GOOS}_${GOARCH}.go`.
122
+
123
+The hardest part about preparing this file is figuring out which headers to
124
+include and which symbols need to be `#define`d to get the actual data
125
+structures that pass through to the kernel system calls. Some C libraries
126
+preset alternate versions for binary compatibility and translate them on the
127
+way in and out of system calls, but there is almost always a `#define` that can
128
+get the real ones.
129
+See `types_darwin.go` and `linux/types.go` for examples.
130
+
131
+To add a new type, add in the necessary include statement at the top of the
132
+file (if it is not already there) and add in a type alias line. Note that if
133
+your type is significantly different on different architectures, you may need
134
+some `#if/#elif` macros in your include statements.
135
+
136
+### mkerrors.sh
137
+
138
+This script is used to generate the system's various constants. This doesn't
139
+just include the error numbers and error strings, but also the signal numbers
140
+an a wide variety of miscellaneous constants. The constants come from the list
141
+of include files in the `includes_${uname}` variable. A regex then picks out
142
+the desired `#define` statements, and generates the corresponding Go constants.
143
+The error numbers and strings are generated from `#include <errno.h>`, and the
144
+signal numbers and strings are generated from `#include <signal.h>`. All of
145
+these constants are written to `zerrors_${GOOS}_${GOARCH}.go` via a C program,
146
+`_errors.c`, which prints out all the constants.
147
+
148
+To add a constant, add the header that includes it to the appropriate variable.
149
+Then, edit the regex (if necessary) to match the desired constant. Avoid making
150
+the regex too broad to avoid matching unintended constants.
151
+
152
+
153
+## Generated files
154
+
155
+### `zerror_${GOOS}_${GOARCH}.go`
156
+
157
+A file containing all of the system's generated error numbers, error strings,
158
+signal numbers, and constants. Generated by `mkerrors.sh` (see above).
159
+
160
+### `zsyscall_${GOOS}_${GOARCH}.go`
161
+
162
+A file containing all the generated syscalls for a specific GOOS and GOARCH.
163
+Generated by `mksyscall.pl` (see above).
164
+
165
+### `zsysnum_${GOOS}_${GOARCH}.go`
166
+
167
+A list of numeric constants for all the syscall number of the specific GOOS
168
+and GOARCH. Generated by mksysnum (see above).
169
+
170
+### `ztypes_${GOOS}_${GOARCH}.go`
171
+
172
+A file containing Go types for passing into (or returning from) syscalls.
173
+Generated by godefs and the types file (see above).

+ 124
- 0
vendor/src/golang.org/x/sys/unix/affinity_linux.go Visa fil

@@ -0,0 +1,124 @@
1
+// Copyright 2018 The Go Authors. All rights reserved.
2
+// Use of this source code is governed by a BSD-style
3
+// license that can be found in the LICENSE file.
4
+
5
+// CPU affinity functions
6
+
7
+package unix
8
+
9
+import (
10
+	"unsafe"
11
+)
12
+
13
+const cpuSetSize = _CPU_SETSIZE / _NCPUBITS
14
+
15
+// CPUSet represents a CPU affinity mask.
16
+type CPUSet [cpuSetSize]cpuMask
17
+
18
+func schedAffinity(trap uintptr, pid int, set *CPUSet) error {
19
+	_, _, e := RawSyscall(trap, uintptr(pid), uintptr(unsafe.Sizeof(set)), uintptr(unsafe.Pointer(set)))
20
+	if e != 0 {
21
+		return errnoErr(e)
22
+	}
23
+	return nil
24
+}
25
+
26
+// SchedGetaffinity gets the CPU affinity mask of the thread specified by pid.
27
+// If pid is 0 the calling thread is used.
28
+func SchedGetaffinity(pid int, set *CPUSet) error {
29
+	return schedAffinity(SYS_SCHED_GETAFFINITY, pid, set)
30
+}
31
+
32
+// SchedSetaffinity sets the CPU affinity mask of the thread specified by pid.
33
+// If pid is 0 the calling thread is used.
34
+func SchedSetaffinity(pid int, set *CPUSet) error {
35
+	return schedAffinity(SYS_SCHED_SETAFFINITY, pid, set)
36
+}
37
+
38
+// Zero clears the set s, so that it contains no CPUs.
39
+func (s *CPUSet) Zero() {
40
+	for i := range s {
41
+		s[i] = 0
42
+	}
43
+}
44
+
45
+func cpuBitsIndex(cpu int) int {
46
+	return cpu / _NCPUBITS
47
+}
48
+
49
+func cpuBitsMask(cpu int) cpuMask {
50
+	return cpuMask(1 << (uint(cpu) % _NCPUBITS))
51
+}
52
+
53
+// Set adds cpu to the set s.
54
+func (s *CPUSet) Set(cpu int) {
55
+	i := cpuBitsIndex(cpu)
56
+	if i < len(s) {
57
+		s[i] |= cpuBitsMask(cpu)
58
+	}
59
+}
60
+
61
+// Clear removes cpu from the set s.
62
+func (s *CPUSet) Clear(cpu int) {
63
+	i := cpuBitsIndex(cpu)
64
+	if i < len(s) {
65
+		s[i] &^= cpuBitsMask(cpu)
66
+	}
67
+}
68
+
69
+// IsSet reports whether cpu is in the set s.
70
+func (s *CPUSet) IsSet(cpu int) bool {
71
+	i := cpuBitsIndex(cpu)
72
+	if i < len(s) {
73
+		return s[i]&cpuBitsMask(cpu) != 0
74
+	}
75
+	return false
76
+}
77
+
78
+// Count returns the number of CPUs in the set s.
79
+func (s *CPUSet) Count() int {
80
+	c := 0
81
+	for _, b := range s {
82
+		c += onesCount64(uint64(b))
83
+	}
84
+	return c
85
+}
86
+
87
+// onesCount64 is a copy of Go 1.9's math/bits.OnesCount64.
88
+// Once this package can require Go 1.9, we can delete this
89
+// and update the caller to use bits.OnesCount64.
90
+func onesCount64(x uint64) int {
91
+	const m0 = 0x5555555555555555 // 01010101 ...
92
+	const m1 = 0x3333333333333333 // 00110011 ...
93
+	const m2 = 0x0f0f0f0f0f0f0f0f // 00001111 ...
94
+	const m3 = 0x00ff00ff00ff00ff // etc.
95
+	const m4 = 0x0000ffff0000ffff
96
+
97
+	// Implementation: Parallel summing of adjacent bits.
98
+	// See "Hacker's Delight", Chap. 5: Counting Bits.
99
+	// The following pattern shows the general approach:
100
+	//
101
+	//   x = x>>1&(m0&m) + x&(m0&m)
102
+	//   x = x>>2&(m1&m) + x&(m1&m)
103
+	//   x = x>>4&(m2&m) + x&(m2&m)
104
+	//   x = x>>8&(m3&m) + x&(m3&m)
105
+	//   x = x>>16&(m4&m) + x&(m4&m)
106
+	//   x = x>>32&(m5&m) + x&(m5&m)
107
+	//   return int(x)
108
+	//
109
+	// Masking (& operations) can be left away when there's no
110
+	// danger that a field's sum will carry over into the next
111
+	// field: Since the result cannot be > 64, 8 bits is enough
112
+	// and we can ignore the masks for the shifts by 8 and up.
113
+	// Per "Hacker's Delight", the first line can be simplified
114
+	// more, but it saves at best one instruction, so we leave
115
+	// it alone for clarity.
116
+	const m = 1<<64 - 1
117
+	x = x>>1&(m0&m) + x&(m0&m)
118
+	x = x>>2&(m1&m) + x&(m1&m)
119
+	x = (x>>4 + x) & (m2 & m)
120
+	x += x >> 8
121
+	x += x >> 16
122
+	x += x >> 32
123
+	return int(x) & (1<<7 - 1)
124
+}

+ 29
- 0
vendor/src/golang.org/x/sys/unix/asm_darwin_386.s Visa fil

@@ -0,0 +1,29 @@
1
+// Copyright 2009 The Go Authors. All rights reserved.
2
+// Use of this source code is governed by a BSD-style
3
+// license that can be found in the LICENSE file.
4
+
5
+// +build !gccgo
6
+
7
+#include "textflag.h"
8
+
9
+//
10
+// System call support for 386, Darwin
11
+//
12
+
13
+// Just jump to package syscall's implementation for all these functions.
14
+// The runtime may know about them.
15
+
16
+TEXT	·Syscall(SB),NOSPLIT,$0-28
17
+	JMP	syscall·Syscall(SB)
18
+
19
+TEXT	·Syscall6(SB),NOSPLIT,$0-40
20
+	JMP	syscall·Syscall6(SB)
21
+
22
+TEXT	·Syscall9(SB),NOSPLIT,$0-52
23
+	JMP	syscall·Syscall9(SB)
24
+
25
+TEXT ·RawSyscall(SB),NOSPLIT,$0-28
26
+	JMP	syscall·RawSyscall(SB)
27
+
28
+TEXT	·RawSyscall6(SB),NOSPLIT,$0-40
29
+	JMP	syscall·RawSyscall6(SB)

+ 29
- 0
vendor/src/golang.org/x/sys/unix/asm_darwin_amd64.s Visa fil

@@ -0,0 +1,29 @@
1
+// Copyright 2009 The Go Authors. All rights reserved.
2
+// Use of this source code is governed by a BSD-style
3
+// license that can be found in the LICENSE file.
4
+
5
+// +build !gccgo
6
+
7
+#include "textflag.h"
8
+
9
+//
10
+// System call support for AMD64, Darwin
11
+//
12
+
13
+// Just jump to package syscall's implementation for all these functions.
14
+// The runtime may know about them.
15
+
16
+TEXT	·Syscall(SB),NOSPLIT,$0-56
17
+	JMP	syscall·Syscall(SB)
18
+
19
+TEXT	·Syscall6(SB),NOSPLIT,$0-80
20
+	JMP	syscall·Syscall6(SB)
21
+
22
+TEXT	·Syscall9(SB),NOSPLIT,$0-104
23
+	JMP	syscall·Syscall9(SB)
24
+
25
+TEXT	·RawSyscall(SB),NOSPLIT,$0-56
26
+	JMP	syscall·RawSyscall(SB)
27
+
28
+TEXT	·RawSyscall6(SB),NOSPLIT,$0-80
29
+	JMP	syscall·RawSyscall6(SB)

+ 30
- 0
vendor/src/golang.org/x/sys/unix/asm_darwin_arm.s Visa fil

@@ -0,0 +1,30 @@
1
+// Copyright 2015 The Go Authors. All rights reserved.
2
+// Use of this source code is governed by a BSD-style
3
+// license that can be found in the LICENSE file.
4
+
5
+// +build !gccgo
6
+// +build arm,darwin
7
+
8
+#include "textflag.h"
9
+
10
+//
11
+// System call support for ARM, Darwin
12
+//
13
+
14
+// Just jump to package syscall's implementation for all these functions.
15
+// The runtime may know about them.
16
+
17
+TEXT	·Syscall(SB),NOSPLIT,$0-28
18
+	B	syscall·Syscall(SB)
19
+
20
+TEXT	·Syscall6(SB),NOSPLIT,$0-40
21
+	B	syscall·Syscall6(SB)
22
+
23
+TEXT	·Syscall9(SB),NOSPLIT,$0-52
24
+	B	syscall·Syscall9(SB)
25
+
26
+TEXT	·RawSyscall(SB),NOSPLIT,$0-28
27
+	B	syscall·RawSyscall(SB)
28
+
29
+TEXT	·RawSyscall6(SB),NOSPLIT,$0-40
30
+	B	syscall·RawSyscall6(SB)

+ 30
- 0
vendor/src/golang.org/x/sys/unix/asm_darwin_arm64.s Visa fil

@@ -0,0 +1,30 @@
1
+// Copyright 2015 The Go Authors. All rights reserved.
2
+// Use of this source code is governed by a BSD-style
3
+// license that can be found in the LICENSE file.
4
+
5
+// +build !gccgo
6
+// +build arm64,darwin
7
+
8
+#include "textflag.h"
9
+
10
+//
11
+// System call support for AMD64, Darwin
12
+//
13
+
14
+// Just jump to package syscall's implementation for all these functions.
15
+// The runtime may know about them.
16
+
17
+TEXT	·Syscall(SB),NOSPLIT,$0-56
18
+	B	syscall·Syscall(SB)
19
+
20
+TEXT	·Syscall6(SB),NOSPLIT,$0-80
21
+	B	syscall·Syscall6(SB)
22
+
23
+TEXT	·Syscall9(SB),NOSPLIT,$0-104
24
+	B	syscall·Syscall9(SB)
25
+
26
+TEXT	·RawSyscall(SB),NOSPLIT,$0-56
27
+	B	syscall·RawSyscall(SB)
28
+
29
+TEXT	·RawSyscall6(SB),NOSPLIT,$0-80
30
+	B	syscall·RawSyscall6(SB)

+ 29
- 0
vendor/src/golang.org/x/sys/unix/asm_dragonfly_amd64.s Visa fil

@@ -0,0 +1,29 @@
1
+// Copyright 2009 The Go Authors. All rights reserved.
2
+// Use of this source code is governed by a BSD-style
3
+// license that can be found in the LICENSE file.
4
+
5
+// +build !gccgo
6
+
7
+#include "textflag.h"
8
+
9
+//
10
+// System call support for AMD64, DragonFly
11
+//
12
+
13
+// Just jump to package syscall's implementation for all these functions.
14
+// The runtime may know about them.
15
+
16
+TEXT	·Syscall(SB),NOSPLIT,$0-64
17
+	JMP	syscall·Syscall(SB)
18
+
19
+TEXT	·Syscall6(SB),NOSPLIT,$0-88
20
+	JMP	syscall·Syscall6(SB)
21
+
22
+TEXT	·Syscall9(SB),NOSPLIT,$0-112
23
+	JMP	syscall·Syscall9(SB)
24
+
25
+TEXT ·RawSyscall(SB),NOSPLIT,$0-64
26
+	JMP	syscall·RawSyscall(SB)
27
+
28
+TEXT	·RawSyscall6(SB),NOSPLIT,$0-88
29
+	JMP	syscall·RawSyscall6(SB)

+ 29
- 0
vendor/src/golang.org/x/sys/unix/asm_freebsd_386.s Visa fil

@@ -0,0 +1,29 @@
1
+// Copyright 2009 The Go Authors. All rights reserved.
2
+// Use of this source code is governed by a BSD-style
3
+// license that can be found in the LICENSE file.
4
+
5
+// +build !gccgo
6
+
7
+#include "textflag.h"
8
+
9
+//
10
+// System call support for 386, FreeBSD
11
+//
12
+
13
+// Just jump to package syscall's implementation for all these functions.
14
+// The runtime may know about them.
15
+
16
+TEXT	·Syscall(SB),NOSPLIT,$0-28
17
+	JMP	syscall·Syscall(SB)
18
+
19
+TEXT	·Syscall6(SB),NOSPLIT,$0-40
20
+	JMP	syscall·Syscall6(SB)
21
+
22
+TEXT	·Syscall9(SB),NOSPLIT,$0-52
23
+	JMP	syscall·Syscall9(SB)
24
+
25
+TEXT ·RawSyscall(SB),NOSPLIT,$0-28
26
+	JMP	syscall·RawSyscall(SB)
27
+
28
+TEXT	·RawSyscall6(SB),NOSPLIT,$0-40
29
+	JMP	syscall·RawSyscall6(SB)

+ 29
- 0
vendor/src/golang.org/x/sys/unix/asm_freebsd_amd64.s Visa fil

@@ -0,0 +1,29 @@
1
+// Copyright 2009 The Go Authors. All rights reserved.
2
+// Use of this source code is governed by a BSD-style
3
+// license that can be found in the LICENSE file.
4
+
5
+// +build !gccgo
6
+
7
+#include "textflag.h"
8
+
9
+//
10
+// System call support for AMD64, FreeBSD
11
+//
12
+
13
+// Just jump to package syscall's implementation for all these functions.
14
+// The runtime may know about them.
15
+
16
+TEXT	·Syscall(SB),NOSPLIT,$0-56
17
+	JMP	syscall·Syscall(SB)
18
+
19
+TEXT	·Syscall6(SB),NOSPLIT,$0-80
20
+	JMP	syscall·Syscall6(SB)
21
+
22
+TEXT	·Syscall9(SB),NOSPLIT,$0-104
23
+	JMP	syscall·Syscall9(SB)
24
+
25
+TEXT ·RawSyscall(SB),NOSPLIT,$0-56
26
+	JMP	syscall·RawSyscall(SB)
27
+
28
+TEXT	·RawSyscall6(SB),NOSPLIT,$0-80
29
+	JMP	syscall·RawSyscall6(SB)

+ 29
- 0
vendor/src/golang.org/x/sys/unix/asm_freebsd_arm.s Visa fil

@@ -0,0 +1,29 @@
1
+// Copyright 2012 The Go Authors. All rights reserved.
2
+// Use of this source code is governed by a BSD-style
3
+// license that can be found in the LICENSE file.
4
+
5
+// +build !gccgo
6
+
7
+#include "textflag.h"
8
+
9
+//
10
+// System call support for ARM, FreeBSD
11
+//
12
+
13
+// Just jump to package syscall's implementation for all these functions.
14
+// The runtime may know about them.
15
+
16
+TEXT	·Syscall(SB),NOSPLIT,$0-28
17
+	B	syscall·Syscall(SB)
18
+
19
+TEXT	·Syscall6(SB),NOSPLIT,$0-40
20
+	B	syscall·Syscall6(SB)
21
+
22
+TEXT	·Syscall9(SB),NOSPLIT,$0-52
23
+	B	syscall·Syscall9(SB)
24
+
25
+TEXT	·RawSyscall(SB),NOSPLIT,$0-28
26
+	B	syscall·RawSyscall(SB)
27
+
28
+TEXT	·RawSyscall6(SB),NOSPLIT,$0-40
29
+	B	syscall·RawSyscall6(SB)

+ 65
- 0
vendor/src/golang.org/x/sys/unix/asm_linux_386.s Visa fil

@@ -0,0 +1,65 @@
1
+// Copyright 2009 The Go Authors. All rights reserved.
2
+// Use of this source code is governed by a BSD-style
3
+// license that can be found in the LICENSE file.
4
+
5
+// +build !gccgo
6
+
7
+#include "textflag.h"
8
+
9
+//
10
+// System calls for 386, Linux
11
+//
12
+
13
+// See ../runtime/sys_linux_386.s for the reason why we always use int 0x80
14
+// instead of the glibc-specific "CALL 0x10(GS)".
15
+#define INVOKE_SYSCALL	INT	$0x80
16
+
17
+// Just jump to package syscall's implementation for all these functions.
18
+// The runtime may know about them.
19
+
20
+TEXT ·Syscall(SB),NOSPLIT,$0-28
21
+	JMP	syscall·Syscall(SB)
22
+
23
+TEXT ·Syscall6(SB),NOSPLIT,$0-40
24
+	JMP	syscall·Syscall6(SB)
25
+
26
+TEXT ·SyscallNoError(SB),NOSPLIT,$0-24
27
+	CALL	runtime·entersyscall(SB)
28
+	MOVL	trap+0(FP), AX  // syscall entry
29
+	MOVL	a1+4(FP), BX
30
+	MOVL	a2+8(FP), CX
31
+	MOVL	a3+12(FP), DX
32
+	MOVL	$0, SI
33
+	MOVL	$0, DI
34
+	INVOKE_SYSCALL
35
+	MOVL	AX, r1+16(FP)
36
+	MOVL	DX, r2+20(FP)
37
+	CALL	runtime·exitsyscall(SB)
38
+	RET
39
+
40
+TEXT ·RawSyscall(SB),NOSPLIT,$0-28
41
+	JMP	syscall·RawSyscall(SB)
42
+
43
+TEXT ·RawSyscall6(SB),NOSPLIT,$0-40
44
+	JMP	syscall·RawSyscall6(SB)
45
+
46
+TEXT ·RawSyscallNoError(SB),NOSPLIT,$0-24
47
+	MOVL	trap+0(FP), AX  // syscall entry
48
+	MOVL	a1+4(FP), BX
49
+	MOVL	a2+8(FP), CX
50
+	MOVL	a3+12(FP), DX
51
+	MOVL	$0, SI
52
+	MOVL	$0, DI
53
+	INVOKE_SYSCALL
54
+	MOVL	AX, r1+16(FP)
55
+	MOVL	DX, r2+20(FP)
56
+	RET
57
+
58
+TEXT ·socketcall(SB),NOSPLIT,$0-36
59
+	JMP	syscall·socketcall(SB)
60
+
61
+TEXT ·rawsocketcall(SB),NOSPLIT,$0-36
62
+	JMP	syscall·rawsocketcall(SB)
63
+
64
+TEXT ·seek(SB),NOSPLIT,$0-28
65
+	JMP	syscall·seek(SB)

+ 57
- 0
vendor/src/golang.org/x/sys/unix/asm_linux_amd64.s Visa fil

@@ -0,0 +1,57 @@
1
+// Copyright 2009 The Go Authors. All rights reserved.
2
+// Use of this source code is governed by a BSD-style
3
+// license that can be found in the LICENSE file.
4
+
5
+// +build !gccgo
6
+
7
+#include "textflag.h"
8
+
9
+//
10
+// System calls for AMD64, Linux
11
+//
12
+
13
+// Just jump to package syscall's implementation for all these functions.
14
+// The runtime may know about them.
15
+
16
+TEXT ·Syscall(SB),NOSPLIT,$0-56
17
+	JMP	syscall·Syscall(SB)
18
+
19
+TEXT ·Syscall6(SB),NOSPLIT,$0-80
20
+	JMP	syscall·Syscall6(SB)
21
+
22
+TEXT ·SyscallNoError(SB),NOSPLIT,$0-48
23
+	CALL	runtime·entersyscall(SB)
24
+	MOVQ	a1+8(FP), DI
25
+	MOVQ	a2+16(FP), SI
26
+	MOVQ	a3+24(FP), DX
27
+	MOVQ	$0, R10
28
+	MOVQ	$0, R8
29
+	MOVQ	$0, R9
30
+	MOVQ	trap+0(FP), AX	// syscall entry
31
+	SYSCALL
32
+	MOVQ	AX, r1+32(FP)
33
+	MOVQ	DX, r2+40(FP)
34
+	CALL	runtime·exitsyscall(SB)
35
+	RET
36
+
37
+TEXT ·RawSyscall(SB),NOSPLIT,$0-56
38
+	JMP	syscall·RawSyscall(SB)
39
+
40
+TEXT ·RawSyscall6(SB),NOSPLIT,$0-80
41
+	JMP	syscall·RawSyscall6(SB)
42
+
43
+TEXT ·RawSyscallNoError(SB),NOSPLIT,$0-48
44
+	MOVQ	a1+8(FP), DI
45
+	MOVQ	a2+16(FP), SI
46
+	MOVQ	a3+24(FP), DX
47
+	MOVQ	$0, R10
48
+	MOVQ	$0, R8
49
+	MOVQ	$0, R9
50
+	MOVQ	trap+0(FP), AX	// syscall entry
51
+	SYSCALL
52
+	MOVQ	AX, r1+32(FP)
53
+	MOVQ	DX, r2+40(FP)
54
+	RET
55
+
56
+TEXT ·gettimeofday(SB),NOSPLIT,$0-16
57
+	JMP	syscall·gettimeofday(SB)

+ 57
- 0
vendor/src/golang.org/x/sys/unix/asm_linux_arm.s Visa fil

@@ -0,0 +1,57 @@
1
+// Copyright 2009 The Go Authors. All rights reserved.
2
+// Use of this source code is governed by a BSD-style
3
+// license that can be found in the LICENSE file.
4
+
5
+// +build !gccgo
6
+
7
+#include "textflag.h"
8
+
9
+//
10
+// System calls for arm, Linux
11
+//
12
+
13
+// Just jump to package syscall's implementation for all these functions.
14
+// The runtime may know about them.
15
+
16
+TEXT ·Syscall(SB),NOSPLIT,$0-28
17
+	B	syscall·Syscall(SB)
18
+
19
+TEXT ·Syscall6(SB),NOSPLIT,$0-40
20
+	B	syscall·Syscall6(SB)
21
+
22
+TEXT ·SyscallNoError(SB),NOSPLIT,$0-24
23
+	BL	runtime·entersyscall(SB)
24
+	MOVW	trap+0(FP), R7
25
+	MOVW	a1+4(FP), R0
26
+	MOVW	a2+8(FP), R1
27
+	MOVW	a3+12(FP), R2
28
+	MOVW	$0, R3
29
+	MOVW	$0, R4
30
+	MOVW	$0, R5
31
+	SWI	$0
32
+	MOVW	R0, r1+16(FP)
33
+	MOVW	$0, R0
34
+	MOVW	R0, r2+20(FP)
35
+	BL	runtime·exitsyscall(SB)
36
+	RET
37
+
38
+
39
+TEXT ·RawSyscall(SB),NOSPLIT,$0-28
40
+	B	syscall·RawSyscall(SB)
41
+
42
+TEXT ·RawSyscall6(SB),NOSPLIT,$0-40
43
+	B	syscall·RawSyscall6(SB)
44
+
45
+TEXT ·RawSyscallNoError(SB),NOSPLIT,$0-24
46
+	MOVW	trap+0(FP), R7	// syscall entry
47
+	MOVW	a1+4(FP), R0
48
+	MOVW	a2+8(FP), R1
49
+	MOVW	a3+12(FP), R2
50
+	SWI	$0
51
+	MOVW	R0, r1+16(FP)
52
+	MOVW	$0, R0
53
+	MOVW	R0, r2+20(FP)
54
+	RET
55
+
56
+TEXT ·seek(SB),NOSPLIT,$0-32
57
+	B	syscall·seek(SB)

+ 52
- 0
vendor/src/golang.org/x/sys/unix/asm_linux_arm64.s Visa fil

@@ -0,0 +1,52 @@
1
+// Copyright 2015 The Go Authors. All rights reserved.
2
+// Use of this source code is governed by a BSD-style
3
+// license that can be found in the LICENSE file.
4
+
5
+// +build linux
6
+// +build arm64
7
+// +build !gccgo
8
+
9
+#include "textflag.h"
10
+
11
+// Just jump to package syscall's implementation for all these functions.
12
+// The runtime may know about them.
13
+
14
+TEXT ·Syscall(SB),NOSPLIT,$0-56
15
+	B	syscall·Syscall(SB)
16
+
17
+TEXT ·Syscall6(SB),NOSPLIT,$0-80
18
+	B	syscall·Syscall6(SB)
19
+
20
+TEXT ·SyscallNoError(SB),NOSPLIT,$0-48
21
+	BL	runtime·entersyscall(SB)
22
+	MOVD	a1+8(FP), R0
23
+	MOVD	a2+16(FP), R1
24
+	MOVD	a3+24(FP), R2
25
+	MOVD	$0, R3
26
+	MOVD	$0, R4
27
+	MOVD	$0, R5
28
+	MOVD	trap+0(FP), R8	// syscall entry
29
+	SVC
30
+	MOVD	R0, r1+32(FP)	// r1
31
+	MOVD	R1, r2+40(FP)	// r2
32
+	BL	runtime·exitsyscall(SB)
33
+	RET
34
+
35
+TEXT ·RawSyscall(SB),NOSPLIT,$0-56
36
+	B	syscall·RawSyscall(SB)
37
+
38
+TEXT ·RawSyscall6(SB),NOSPLIT,$0-80
39
+	B	syscall·RawSyscall6(SB)
40
+
41
+TEXT ·RawSyscallNoError(SB),NOSPLIT,$0-48
42
+	MOVD	a1+8(FP), R0
43
+	MOVD	a2+16(FP), R1
44
+	MOVD	a3+24(FP), R2
45
+	MOVD	$0, R3
46
+	MOVD	$0, R4
47
+	MOVD	$0, R5
48
+	MOVD	trap+0(FP), R8	// syscall entry
49
+	SVC
50
+	MOVD	R0, r1+32(FP)
51
+	MOVD	R1, r2+40(FP)
52
+	RET

+ 56
- 0
vendor/src/golang.org/x/sys/unix/asm_linux_mips64x.s Visa fil

@@ -0,0 +1,56 @@
1
+// Copyright 2015 The Go Authors. All rights reserved.
2
+// Use of this source code is governed by a BSD-style
3
+// license that can be found in the LICENSE file.
4
+
5
+// +build linux
6
+// +build mips64 mips64le
7
+// +build !gccgo
8
+
9
+#include "textflag.h"
10
+
11
+//
12
+// System calls for mips64, Linux
13
+//
14
+
15
+// Just jump to package syscall's implementation for all these functions.
16
+// The runtime may know about them.
17
+
18
+TEXT ·Syscall(SB),NOSPLIT,$0-56
19
+	JMP	syscall·Syscall(SB)
20
+
21
+TEXT ·Syscall6(SB),NOSPLIT,$0-80
22
+	JMP	syscall·Syscall6(SB)
23
+
24
+TEXT ·SyscallNoError(SB),NOSPLIT,$0-48
25
+	JAL	runtime·entersyscall(SB)
26
+	MOVV	a1+8(FP), R4
27
+	MOVV	a2+16(FP), R5
28
+	MOVV	a3+24(FP), R6
29
+	MOVV	R0, R7
30
+	MOVV	R0, R8
31
+	MOVV	R0, R9
32
+	MOVV	trap+0(FP), R2	// syscall entry
33
+	SYSCALL
34
+	MOVV	R2, r1+32(FP)
35
+	MOVV	R3, r2+40(FP)
36
+	JAL	runtime·exitsyscall(SB)
37
+	RET
38
+
39
+TEXT ·RawSyscall(SB),NOSPLIT,$0-56
40
+	JMP	syscall·RawSyscall(SB)
41
+
42
+TEXT ·RawSyscall6(SB),NOSPLIT,$0-80
43
+	JMP	syscall·RawSyscall6(SB)
44
+
45
+TEXT ·RawSyscallNoError(SB),NOSPLIT,$0-48
46
+	MOVV	a1+8(FP), R4
47
+	MOVV	a2+16(FP), R5
48
+	MOVV	a3+24(FP), R6
49
+	MOVV	R0, R7
50
+	MOVV	R0, R8
51
+	MOVV	R0, R9
52
+	MOVV	trap+0(FP), R2	// syscall entry
53
+	SYSCALL
54
+	MOVV	R2, r1+32(FP)
55
+	MOVV	R3, r2+40(FP)
56
+	RET

+ 54
- 0
vendor/src/golang.org/x/sys/unix/asm_linux_mipsx.s Visa fil

@@ -0,0 +1,54 @@
1
+// Copyright 2016 The Go Authors. All rights reserved.
2
+// Use of this source code is governed by a BSD-style
3
+// license that can be found in the LICENSE file.
4
+
5
+// +build linux
6
+// +build mips mipsle
7
+// +build !gccgo
8
+
9
+#include "textflag.h"
10
+
11
+//
12
+// System calls for mips, Linux
13
+//
14
+
15
+// Just jump to package syscall's implementation for all these functions.
16
+// The runtime may know about them.
17
+
18
+TEXT ·Syscall(SB),NOSPLIT,$0-28
19
+	JMP syscall·Syscall(SB)
20
+
21
+TEXT ·Syscall6(SB),NOSPLIT,$0-40
22
+	JMP syscall·Syscall6(SB)
23
+
24
+TEXT ·Syscall9(SB),NOSPLIT,$0-52
25
+	JMP syscall·Syscall9(SB)
26
+
27
+TEXT ·SyscallNoError(SB),NOSPLIT,$0-24
28
+	JAL	runtime·entersyscall(SB)
29
+	MOVW	a1+4(FP), R4
30
+	MOVW	a2+8(FP), R5
31
+	MOVW	a3+12(FP), R6
32
+	MOVW	R0, R7
33
+	MOVW	trap+0(FP), R2	// syscall entry
34
+	SYSCALL
35
+	MOVW	R2, r1+16(FP)	// r1
36
+	MOVW	R3, r2+20(FP)	// r2
37
+	JAL	runtime·exitsyscall(SB)
38
+	RET
39
+
40
+TEXT ·RawSyscall(SB),NOSPLIT,$0-28
41
+	JMP syscall·RawSyscall(SB)
42
+
43
+TEXT ·RawSyscall6(SB),NOSPLIT,$0-40
44
+	JMP syscall·RawSyscall6(SB)
45
+
46
+TEXT ·RawSyscallNoError(SB),NOSPLIT,$0-24
47
+	MOVW	a1+4(FP), R4
48
+	MOVW	a2+8(FP), R5
49
+	MOVW	a3+12(FP), R6
50
+	MOVW	trap+0(FP), R2	// syscall entry
51
+	SYSCALL
52
+	MOVW	R2, r1+16(FP)
53
+	MOVW	R3, r2+20(FP)
54
+	RET

+ 56
- 0
vendor/src/golang.org/x/sys/unix/asm_linux_ppc64x.s Visa fil

@@ -0,0 +1,56 @@
1
+// Copyright 2014 The Go Authors. All rights reserved.
2
+// Use of this source code is governed by a BSD-style
3
+// license that can be found in the LICENSE file.
4
+
5
+// +build linux
6
+// +build ppc64 ppc64le
7
+// +build !gccgo
8
+
9
+#include "textflag.h"
10
+
11
+//
12
+// System calls for ppc64, Linux
13
+//
14
+
15
+// Just jump to package syscall's implementation for all these functions.
16
+// The runtime may know about them.
17
+
18
+TEXT ·Syscall(SB),NOSPLIT,$0-56
19
+	BR	syscall·Syscall(SB)
20
+
21
+TEXT ·Syscall6(SB),NOSPLIT,$0-80
22
+	BR	syscall·Syscall6(SB)
23
+
24
+TEXT ·SyscallNoError(SB),NOSPLIT,$0-48
25
+	BL	runtime·entersyscall(SB)
26
+	MOVD	a1+8(FP), R3
27
+	MOVD	a2+16(FP), R4
28
+	MOVD	a3+24(FP), R5
29
+	MOVD	R0, R6
30
+	MOVD	R0, R7
31
+	MOVD	R0, R8
32
+	MOVD	trap+0(FP), R9	// syscall entry
33
+	SYSCALL R9
34
+	MOVD	R3, r1+32(FP)
35
+	MOVD	R4, r2+40(FP)
36
+	BL	runtime·exitsyscall(SB)
37
+	RET
38
+
39
+TEXT ·RawSyscall(SB),NOSPLIT,$0-56
40
+	BR	syscall·RawSyscall(SB)
41
+
42
+TEXT ·RawSyscall6(SB),NOSPLIT,$0-80
43
+	BR	syscall·RawSyscall6(SB)
44
+
45
+TEXT ·RawSyscallNoError(SB),NOSPLIT,$0-48
46
+	MOVD	a1+8(FP), R3
47
+	MOVD	a2+16(FP), R4
48
+	MOVD	a3+24(FP), R5
49
+	MOVD	R0, R6
50
+	MOVD	R0, R7
51
+	MOVD	R0, R8
52
+	MOVD	trap+0(FP), R9	// syscall entry
53
+	SYSCALL R9
54
+	MOVD	R3, r1+32(FP)
55
+	MOVD	R4, r2+40(FP)
56
+	RET

+ 56
- 0
vendor/src/golang.org/x/sys/unix/asm_linux_s390x.s Visa fil

@@ -0,0 +1,56 @@
1
+// Copyright 2016 The Go Authors. All rights reserved.
2
+// Use of this source code is governed by a BSD-style
3
+// license that can be found in the LICENSE file.
4
+
5
+// +build s390x
6
+// +build linux
7
+// +build !gccgo
8
+
9
+#include "textflag.h"
10
+
11
+//
12
+// System calls for s390x, Linux
13
+//
14
+
15
+// Just jump to package syscall's implementation for all these functions.
16
+// The runtime may know about them.
17
+
18
+TEXT ·Syscall(SB),NOSPLIT,$0-56
19
+	BR	syscall·Syscall(SB)
20
+
21
+TEXT ·Syscall6(SB),NOSPLIT,$0-80
22
+	BR	syscall·Syscall6(SB)
23
+
24
+TEXT ·SyscallNoError(SB),NOSPLIT,$0-48
25
+	BL	runtime·entersyscall(SB)
26
+	MOVD	a1+8(FP), R2
27
+	MOVD	a2+16(FP), R3
28
+	MOVD	a3+24(FP), R4
29
+	MOVD	$0, R5
30
+	MOVD	$0, R6
31
+	MOVD	$0, R7
32
+	MOVD	trap+0(FP), R1	// syscall entry
33
+	SYSCALL
34
+	MOVD	R2, r1+32(FP)
35
+	MOVD	R3, r2+40(FP)
36
+	BL	runtime·exitsyscall(SB)
37
+	RET
38
+
39
+TEXT ·RawSyscall(SB),NOSPLIT,$0-56
40
+	BR	syscall·RawSyscall(SB)
41
+
42
+TEXT ·RawSyscall6(SB),NOSPLIT,$0-80
43
+	BR	syscall·RawSyscall6(SB)
44
+
45
+TEXT ·RawSyscallNoError(SB),NOSPLIT,$0-48
46
+	MOVD	a1+8(FP), R2
47
+	MOVD	a2+16(FP), R3
48
+	MOVD	a3+24(FP), R4
49
+	MOVD	$0, R5
50
+	MOVD	$0, R6
51
+	MOVD	$0, R7
52
+	MOVD	trap+0(FP), R1	// syscall entry
53
+	SYSCALL
54
+	MOVD	R2, r1+32(FP)
55
+	MOVD	R3, r2+40(FP)
56
+	RET

+ 29
- 0
vendor/src/golang.org/x/sys/unix/asm_netbsd_386.s Visa fil

@@ -0,0 +1,29 @@
1
+// Copyright 2009 The Go Authors. All rights reserved.
2
+// Use of this source code is governed by a BSD-style
3
+// license that can be found in the LICENSE file.
4
+
5
+// +build !gccgo
6
+
7
+#include "textflag.h"
8
+
9
+//
10
+// System call support for 386, NetBSD
11
+//
12
+
13
+// Just jump to package syscall's implementation for all these functions.
14
+// The runtime may know about them.
15
+
16
+TEXT	·Syscall(SB),NOSPLIT,$0-28
17
+	JMP	syscall·Syscall(SB)
18
+
19
+TEXT	·Syscall6(SB),NOSPLIT,$0-40
20
+	JMP	syscall·Syscall6(SB)
21
+
22
+TEXT	·Syscall9(SB),NOSPLIT,$0-52
23
+	JMP	syscall·Syscall9(SB)
24
+
25
+TEXT ·RawSyscall(SB),NOSPLIT,$0-28
26
+	JMP	syscall·RawSyscall(SB)
27
+
28
+TEXT	·RawSyscall6(SB),NOSPLIT,$0-40
29
+	JMP	syscall·RawSyscall6(SB)

+ 29
- 0
vendor/src/golang.org/x/sys/unix/asm_netbsd_amd64.s Visa fil

@@ -0,0 +1,29 @@
1
+// Copyright 2009 The Go Authors. All rights reserved.
2
+// Use of this source code is governed by a BSD-style
3
+// license that can be found in the LICENSE file.
4
+
5
+// +build !gccgo
6
+
7
+#include "textflag.h"
8
+
9
+//
10
+// System call support for AMD64, NetBSD
11
+//
12
+
13
+// Just jump to package syscall's implementation for all these functions.
14
+// The runtime may know about them.
15
+
16
+TEXT	·Syscall(SB),NOSPLIT,$0-56
17
+	JMP	syscall·Syscall(SB)
18
+
19
+TEXT	·Syscall6(SB),NOSPLIT,$0-80
20
+	JMP	syscall·Syscall6(SB)
21
+
22
+TEXT	·Syscall9(SB),NOSPLIT,$0-104
23
+	JMP	syscall·Syscall9(SB)
24
+
25
+TEXT	·RawSyscall(SB),NOSPLIT,$0-56
26
+	JMP	syscall·RawSyscall(SB)
27
+
28
+TEXT	·RawSyscall6(SB),NOSPLIT,$0-80
29
+	JMP	syscall·RawSyscall6(SB)

+ 29
- 0
vendor/src/golang.org/x/sys/unix/asm_netbsd_arm.s Visa fil

@@ -0,0 +1,29 @@
1
+// Copyright 2013 The Go Authors. All rights reserved.
2
+// Use of this source code is governed by a BSD-style
3
+// license that can be found in the LICENSE file.
4
+
5
+// +build !gccgo
6
+
7
+#include "textflag.h"
8
+
9
+//
10
+// System call support for ARM, NetBSD
11
+//
12
+
13
+// Just jump to package syscall's implementation for all these functions.
14
+// The runtime may know about them.
15
+
16
+TEXT	·Syscall(SB),NOSPLIT,$0-28
17
+	B	syscall·Syscall(SB)
18
+
19
+TEXT	·Syscall6(SB),NOSPLIT,$0-40
20
+	B	syscall·Syscall6(SB)
21
+
22
+TEXT	·Syscall9(SB),NOSPLIT,$0-52
23
+	B	syscall·Syscall9(SB)
24
+
25
+TEXT	·RawSyscall(SB),NOSPLIT,$0-28
26
+	B	syscall·RawSyscall(SB)
27
+
28
+TEXT	·RawSyscall6(SB),NOSPLIT,$0-40
29
+	B	syscall·RawSyscall6(SB)

+ 29
- 0
vendor/src/golang.org/x/sys/unix/asm_openbsd_386.s Visa fil

@@ -0,0 +1,29 @@
1
+// Copyright 2009 The Go Authors. All rights reserved.
2
+// Use of this source code is governed by a BSD-style
3
+// license that can be found in the LICENSE file.
4
+
5
+// +build !gccgo
6
+
7
+#include "textflag.h"
8
+
9
+//
10
+// System call support for 386, OpenBSD
11
+//
12
+
13
+// Just jump to package syscall's implementation for all these functions.
14
+// The runtime may know about them.
15
+
16
+TEXT	·Syscall(SB),NOSPLIT,$0-28
17
+	JMP	syscall·Syscall(SB)
18
+
19
+TEXT	·Syscall6(SB),NOSPLIT,$0-40
20
+	JMP	syscall·Syscall6(SB)
21
+
22
+TEXT	·Syscall9(SB),NOSPLIT,$0-52
23
+	JMP	syscall·Syscall9(SB)
24
+
25
+TEXT ·RawSyscall(SB),NOSPLIT,$0-28
26
+	JMP	syscall·RawSyscall(SB)
27
+
28
+TEXT	·RawSyscall6(SB),NOSPLIT,$0-40
29
+	JMP	syscall·RawSyscall6(SB)

+ 29
- 0
vendor/src/golang.org/x/sys/unix/asm_openbsd_amd64.s Visa fil

@@ -0,0 +1,29 @@
1
+// Copyright 2009 The Go Authors. All rights reserved.
2
+// Use of this source code is governed by a BSD-style
3
+// license that can be found in the LICENSE file.
4
+
5
+// +build !gccgo
6
+
7
+#include "textflag.h"
8
+
9
+//
10
+// System call support for AMD64, OpenBSD
11
+//
12
+
13
+// Just jump to package syscall's implementation for all these functions.
14
+// The runtime may know about them.
15
+
16
+TEXT	·Syscall(SB),NOSPLIT,$0-56
17
+	JMP	syscall·Syscall(SB)
18
+
19
+TEXT	·Syscall6(SB),NOSPLIT,$0-80
20
+	JMP	syscall·Syscall6(SB)
21
+
22
+TEXT	·Syscall9(SB),NOSPLIT,$0-104
23
+	JMP	syscall·Syscall9(SB)
24
+
25
+TEXT	·RawSyscall(SB),NOSPLIT,$0-56
26
+	JMP	syscall·RawSyscall(SB)
27
+
28
+TEXT	·RawSyscall6(SB),NOSPLIT,$0-80
29
+	JMP	syscall·RawSyscall6(SB)

+ 29
- 0
vendor/src/golang.org/x/sys/unix/asm_openbsd_arm.s Visa fil

@@ -0,0 +1,29 @@
1
+// Copyright 2017 The Go Authors. All rights reserved.
2
+// Use of this source code is governed by a BSD-style
3
+// license that can be found in the LICENSE file.
4
+
5
+// +build !gccgo
6
+
7
+#include "textflag.h"
8
+
9
+//
10
+// System call support for ARM, OpenBSD
11
+//
12
+
13
+// Just jump to package syscall's implementation for all these functions.
14
+// The runtime may know about them.
15
+
16
+TEXT	·Syscall(SB),NOSPLIT,$0-28
17
+	B	syscall·Syscall(SB)
18
+
19
+TEXT	·Syscall6(SB),NOSPLIT,$0-40
20
+	B	syscall·Syscall6(SB)
21
+
22
+TEXT	·Syscall9(SB),NOSPLIT,$0-52
23
+	B	syscall·Syscall9(SB)
24
+
25
+TEXT	·RawSyscall(SB),NOSPLIT,$0-28
26
+	B	syscall·RawSyscall(SB)
27
+
28
+TEXT	·RawSyscall6(SB),NOSPLIT,$0-40
29
+	B	syscall·RawSyscall6(SB)

+ 17
- 0
vendor/src/golang.org/x/sys/unix/asm_solaris_amd64.s Visa fil

@@ -0,0 +1,17 @@
1
+// Copyright 2014 The Go Authors. All rights reserved.
2
+// Use of this source code is governed by a BSD-style
3
+// license that can be found in the LICENSE file.
4
+
5
+// +build !gccgo
6
+
7
+#include "textflag.h"
8
+
9
+//
10
+// System calls for amd64, Solaris are implemented in runtime/syscall_solaris.go
11
+//
12
+
13
+TEXT ·sysvicall6(SB),NOSPLIT,$0-88
14
+	JMP	syscall·sysvicall6(SB)
15
+
16
+TEXT ·rawSysvicall6(SB),NOSPLIT,$0-88
17
+	JMP	syscall·rawSysvicall6(SB)

+ 35
- 0
vendor/src/golang.org/x/sys/unix/bluetooth_linux.go Visa fil

@@ -0,0 +1,35 @@
1
+// Copyright 2016 The Go Authors. All rights reserved.
2
+// Use of this source code is governed by a BSD-style
3
+// license that can be found in the LICENSE file.
4
+
5
+// Bluetooth sockets and messages
6
+
7
+package unix
8
+
9
+// Bluetooth Protocols
10
+const (
11
+	BTPROTO_L2CAP  = 0
12
+	BTPROTO_HCI    = 1
13
+	BTPROTO_SCO    = 2
14
+	BTPROTO_RFCOMM = 3
15
+	BTPROTO_BNEP   = 4
16
+	BTPROTO_CMTP   = 5
17
+	BTPROTO_HIDP   = 6
18
+	BTPROTO_AVDTP  = 7
19
+)
20
+
21
+const (
22
+	HCI_CHANNEL_RAW     = 0
23
+	HCI_CHANNEL_USER    = 1
24
+	HCI_CHANNEL_MONITOR = 2
25
+	HCI_CHANNEL_CONTROL = 3
26
+)
27
+
28
+// Socketoption Level
29
+const (
30
+	SOL_BLUETOOTH = 0x112
31
+	SOL_HCI       = 0x0
32
+	SOL_L2CAP     = 0x6
33
+	SOL_RFCOMM    = 0x12
34
+	SOL_SCO       = 0x11
35
+)

+ 195
- 0
vendor/src/golang.org/x/sys/unix/cap_freebsd.go Visa fil

@@ -0,0 +1,195 @@
1
+// Copyright 2017 The Go Authors. All rights reserved.
2
+// Use of this source code is governed by a BSD-style
3
+// license that can be found in the LICENSE file.
4
+
5
+// +build freebsd
6
+
7
+package unix
8
+
9
+import (
10
+	errorspkg "errors"
11
+	"fmt"
12
+)
13
+
14
+// Go implementation of C mostly found in /usr/src/sys/kern/subr_capability.c
15
+
16
+const (
17
+	// This is the version of CapRights this package understands. See C implementation for parallels.
18
+	capRightsGoVersion = CAP_RIGHTS_VERSION_00
19
+	capArSizeMin       = CAP_RIGHTS_VERSION_00 + 2
20
+	capArSizeMax       = capRightsGoVersion + 2
21
+)
22
+
23
+var (
24
+	bit2idx = []int{
25
+		-1, 0, 1, -1, 2, -1, -1, -1, 3, -1, -1, -1, -1, -1, -1, -1,
26
+		4, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
27
+	}
28
+)
29
+
30
+func capidxbit(right uint64) int {
31
+	return int((right >> 57) & 0x1f)
32
+}
33
+
34
+func rightToIndex(right uint64) (int, error) {
35
+	idx := capidxbit(right)
36
+	if idx < 0 || idx >= len(bit2idx) {
37
+		return -2, fmt.Errorf("index for right 0x%x out of range", right)
38
+	}
39
+	return bit2idx[idx], nil
40
+}
41
+
42
+func caprver(right uint64) int {
43
+	return int(right >> 62)
44
+}
45
+
46
+func capver(rights *CapRights) int {
47
+	return caprver(rights.Rights[0])
48
+}
49
+
50
+func caparsize(rights *CapRights) int {
51
+	return capver(rights) + 2
52
+}
53
+
54
+// CapRightsSet sets the permissions in setrights in rights.
55
+func CapRightsSet(rights *CapRights, setrights []uint64) error {
56
+	// This is essentially a copy of cap_rights_vset()
57
+	if capver(rights) != CAP_RIGHTS_VERSION_00 {
58
+		return fmt.Errorf("bad rights version %d", capver(rights))
59
+	}
60
+
61
+	n := caparsize(rights)
62
+	if n < capArSizeMin || n > capArSizeMax {
63
+		return errorspkg.New("bad rights size")
64
+	}
65
+
66
+	for _, right := range setrights {
67
+		if caprver(right) != CAP_RIGHTS_VERSION_00 {
68
+			return errorspkg.New("bad right version")
69
+		}
70
+		i, err := rightToIndex(right)
71
+		if err != nil {
72
+			return err
73
+		}
74
+		if i >= n {
75
+			return errorspkg.New("index overflow")
76
+		}
77
+		if capidxbit(rights.Rights[i]) != capidxbit(right) {
78
+			return errorspkg.New("index mismatch")
79
+		}
80
+		rights.Rights[i] |= right
81
+		if capidxbit(rights.Rights[i]) != capidxbit(right) {
82
+			return errorspkg.New("index mismatch (after assign)")
83
+		}
84
+	}
85
+
86
+	return nil
87
+}
88
+
89
+// CapRightsClear clears the permissions in clearrights from rights.
90
+func CapRightsClear(rights *CapRights, clearrights []uint64) error {
91
+	// This is essentially a copy of cap_rights_vclear()
92
+	if capver(rights) != CAP_RIGHTS_VERSION_00 {
93
+		return fmt.Errorf("bad rights version %d", capver(rights))
94
+	}
95
+
96
+	n := caparsize(rights)
97
+	if n < capArSizeMin || n > capArSizeMax {
98
+		return errorspkg.New("bad rights size")
99
+	}
100
+
101
+	for _, right := range clearrights {
102
+		if caprver(right) != CAP_RIGHTS_VERSION_00 {
103
+			return errorspkg.New("bad right version")
104
+		}
105
+		i, err := rightToIndex(right)
106
+		if err != nil {
107
+			return err
108
+		}
109
+		if i >= n {
110
+			return errorspkg.New("index overflow")
111
+		}
112
+		if capidxbit(rights.Rights[i]) != capidxbit(right) {
113
+			return errorspkg.New("index mismatch")
114
+		}
115
+		rights.Rights[i] &= ^(right & 0x01FFFFFFFFFFFFFF)
116
+		if capidxbit(rights.Rights[i]) != capidxbit(right) {
117
+			return errorspkg.New("index mismatch (after assign)")
118
+		}
119
+	}
120
+
121
+	return nil
122
+}
123
+
124
+// CapRightsIsSet checks whether all the permissions in setrights are present in rights.
125
+func CapRightsIsSet(rights *CapRights, setrights []uint64) (bool, error) {
126
+	// This is essentially a copy of cap_rights_is_vset()
127
+	if capver(rights) != CAP_RIGHTS_VERSION_00 {
128
+		return false, fmt.Errorf("bad rights version %d", capver(rights))
129
+	}
130
+
131
+	n := caparsize(rights)
132
+	if n < capArSizeMin || n > capArSizeMax {
133
+		return false, errorspkg.New("bad rights size")
134
+	}
135
+
136
+	for _, right := range setrights {
137
+		if caprver(right) != CAP_RIGHTS_VERSION_00 {
138
+			return false, errorspkg.New("bad right version")
139
+		}
140
+		i, err := rightToIndex(right)
141
+		if err != nil {
142
+			return false, err
143
+		}
144
+		if i >= n {
145
+			return false, errorspkg.New("index overflow")
146
+		}
147
+		if capidxbit(rights.Rights[i]) != capidxbit(right) {
148
+			return false, errorspkg.New("index mismatch")
149
+		}
150
+		if (rights.Rights[i] & right) != right {
151
+			return false, nil
152
+		}
153
+	}
154
+
155
+	return true, nil
156
+}
157
+
158
+func capright(idx uint64, bit uint64) uint64 {
159
+	return ((1 << (57 + idx)) | bit)
160
+}
161
+
162
+// CapRightsInit returns a pointer to an initialised CapRights structure filled with rights.
163
+// See man cap_rights_init(3) and rights(4).
164
+func CapRightsInit(rights []uint64) (*CapRights, error) {
165
+	var r CapRights
166
+	r.Rights[0] = (capRightsGoVersion << 62) | capright(0, 0)
167
+	r.Rights[1] = capright(1, 0)
168
+
169
+	err := CapRightsSet(&r, rights)
170
+	if err != nil {
171
+		return nil, err
172
+	}
173
+	return &r, nil
174
+}
175
+
176
+// CapRightsLimit reduces the operations permitted on fd to at most those contained in rights.
177
+// The capability rights on fd can never be increased by CapRightsLimit.
178
+// See man cap_rights_limit(2) and rights(4).
179
+func CapRightsLimit(fd uintptr, rights *CapRights) error {
180
+	return capRightsLimit(int(fd), rights)
181
+}
182
+
183
+// CapRightsGet returns a CapRights structure containing the operations permitted on fd.
184
+// See man cap_rights_get(3) and rights(4).
185
+func CapRightsGet(fd uintptr) (*CapRights, error) {
186
+	r, err := CapRightsInit(nil)
187
+	if err != nil {
188
+		return nil, err
189
+	}
190
+	err = capRightsGet(capRightsGoVersion, int(fd), r)
191
+	if err != nil {
192
+		return nil, err
193
+	}
194
+	return r, nil
195
+}

+ 13
- 0
vendor/src/golang.org/x/sys/unix/constants.go Visa fil

@@ -0,0 +1,13 @@
1
+// Copyright 2015 The Go Authors. All rights reserved.
2
+// Use of this source code is governed by a BSD-style
3
+// license that can be found in the LICENSE file.
4
+
5
+// +build darwin dragonfly freebsd linux netbsd openbsd solaris
6
+
7
+package unix
8
+
9
+const (
10
+	R_OK = 0x4
11
+	W_OK = 0x2
12
+	X_OK = 0x1
13
+)

+ 152
- 0
vendor/src/golang.org/x/sys/unix/creds_test.go Visa fil

@@ -0,0 +1,152 @@
1
+// Copyright 2012 The Go Authors. All rights reserved.
2
+// Use of this source code is governed by a BSD-style
3
+// license that can be found in the LICENSE file.
4
+
5
+// +build linux
6
+
7
+package unix_test
8
+
9
+import (
10
+	"bytes"
11
+	"go/build"
12
+	"net"
13
+	"os"
14
+	"syscall"
15
+	"testing"
16
+
17
+	"golang.org/x/sys/unix"
18
+)
19
+
20
+// TestSCMCredentials tests the sending and receiving of credentials
21
+// (PID, UID, GID) in an ancillary message between two UNIX
22
+// sockets. The SO_PASSCRED socket option is enabled on the sending
23
+// socket for this to work.
24
+func TestSCMCredentials(t *testing.T) {
25
+	socketTypeTests := []struct {
26
+		socketType int
27
+		dataLen    int
28
+	}{
29
+		{
30
+			unix.SOCK_STREAM,
31
+			1,
32
+		}, {
33
+			unix.SOCK_DGRAM,
34
+			0,
35
+		},
36
+	}
37
+
38
+	for _, tt := range socketTypeTests {
39
+		if tt.socketType == unix.SOCK_DGRAM && !atLeast1p10() {
40
+			t.Log("skipping DGRAM test on pre-1.10")
41
+			continue
42
+		}
43
+
44
+		fds, err := unix.Socketpair(unix.AF_LOCAL, tt.socketType, 0)
45
+		if err != nil {
46
+			t.Fatalf("Socketpair: %v", err)
47
+		}
48
+		defer unix.Close(fds[0])
49
+		defer unix.Close(fds[1])
50
+
51
+		err = unix.SetsockoptInt(fds[0], unix.SOL_SOCKET, unix.SO_PASSCRED, 1)
52
+		if err != nil {
53
+			t.Fatalf("SetsockoptInt: %v", err)
54
+		}
55
+
56
+		srvFile := os.NewFile(uintptr(fds[0]), "server")
57
+		defer srvFile.Close()
58
+		srv, err := net.FileConn(srvFile)
59
+		if err != nil {
60
+			t.Errorf("FileConn: %v", err)
61
+			return
62
+		}
63
+		defer srv.Close()
64
+
65
+		cliFile := os.NewFile(uintptr(fds[1]), "client")
66
+		defer cliFile.Close()
67
+		cli, err := net.FileConn(cliFile)
68
+		if err != nil {
69
+			t.Errorf("FileConn: %v", err)
70
+			return
71
+		}
72
+		defer cli.Close()
73
+
74
+		var ucred unix.Ucred
75
+		if os.Getuid() != 0 {
76
+			ucred.Pid = int32(os.Getpid())
77
+			ucred.Uid = 0
78
+			ucred.Gid = 0
79
+			oob := unix.UnixCredentials(&ucred)
80
+			_, _, err := cli.(*net.UnixConn).WriteMsgUnix(nil, oob, nil)
81
+			if op, ok := err.(*net.OpError); ok {
82
+				err = op.Err
83
+			}
84
+			if sys, ok := err.(*os.SyscallError); ok {
85
+				err = sys.Err
86
+			}
87
+			if err != syscall.EPERM {
88
+				t.Fatalf("WriteMsgUnix failed with %v, want EPERM", err)
89
+			}
90
+		}
91
+
92
+		ucred.Pid = int32(os.Getpid())
93
+		ucred.Uid = uint32(os.Getuid())
94
+		ucred.Gid = uint32(os.Getgid())
95
+		oob := unix.UnixCredentials(&ucred)
96
+
97
+		// On SOCK_STREAM, this is internally going to send a dummy byte
98
+		n, oobn, err := cli.(*net.UnixConn).WriteMsgUnix(nil, oob, nil)
99
+		if err != nil {
100
+			t.Fatalf("WriteMsgUnix: %v", err)
101
+		}
102
+		if n != 0 {
103
+			t.Fatalf("WriteMsgUnix n = %d, want 0", n)
104
+		}
105
+		if oobn != len(oob) {
106
+			t.Fatalf("WriteMsgUnix oobn = %d, want %d", oobn, len(oob))
107
+		}
108
+
109
+		oob2 := make([]byte, 10*len(oob))
110
+		n, oobn2, flags, _, err := srv.(*net.UnixConn).ReadMsgUnix(nil, oob2)
111
+		if err != nil {
112
+			t.Fatalf("ReadMsgUnix: %v", err)
113
+		}
114
+		if flags != 0 {
115
+			t.Fatalf("ReadMsgUnix flags = 0x%x, want 0", flags)
116
+		}
117
+		if n != tt.dataLen {
118
+			t.Fatalf("ReadMsgUnix n = %d, want %d", n, tt.dataLen)
119
+		}
120
+		if oobn2 != oobn {
121
+			// without SO_PASSCRED set on the socket, ReadMsgUnix will
122
+			// return zero oob bytes
123
+			t.Fatalf("ReadMsgUnix oobn = %d, want %d", oobn2, oobn)
124
+		}
125
+		oob2 = oob2[:oobn2]
126
+		if !bytes.Equal(oob, oob2) {
127
+			t.Fatal("ReadMsgUnix oob bytes don't match")
128
+		}
129
+
130
+		scm, err := unix.ParseSocketControlMessage(oob2)
131
+		if err != nil {
132
+			t.Fatalf("ParseSocketControlMessage: %v", err)
133
+		}
134
+		newUcred, err := unix.ParseUnixCredentials(&scm[0])
135
+		if err != nil {
136
+			t.Fatalf("ParseUnixCredentials: %v", err)
137
+		}
138
+		if *newUcred != ucred {
139
+			t.Fatalf("ParseUnixCredentials = %+v, want %+v", newUcred, ucred)
140
+		}
141
+	}
142
+}
143
+
144
+// atLeast1p10 reports whether we are running on Go 1.10 or later.
145
+func atLeast1p10() bool {
146
+	for _, ver := range build.Default.ReleaseTags {
147
+		if ver == "go1.10" {
148
+			return true
149
+		}
150
+	}
151
+	return false
152
+}

+ 24
- 0
vendor/src/golang.org/x/sys/unix/dev_darwin.go Visa fil

@@ -0,0 +1,24 @@
1
+// Copyright 2017 The Go Authors. All rights reserved.
2
+// Use of this source code is governed by a BSD-style
3
+// license that can be found in the LICENSE file.
4
+
5
+// Functions to access/create device major and minor numbers matching the
6
+// encoding used in Darwin's sys/types.h header.
7
+
8
+package unix
9
+
10
+// Major returns the major component of a Darwin device number.
11
+func Major(dev uint64) uint32 {
12
+	return uint32((dev >> 24) & 0xff)
13
+}
14
+
15
+// Minor returns the minor component of a Darwin device number.
16
+func Minor(dev uint64) uint32 {
17
+	return uint32(dev & 0xffffff)
18
+}
19
+
20
+// Mkdev returns a Darwin device number generated from the given major and minor
21
+// components.
22
+func Mkdev(major, minor uint32) uint64 {
23
+	return (uint64(major) << 24) | uint64(minor)
24
+}

+ 51
- 0
vendor/src/golang.org/x/sys/unix/dev_darwin_test.go Visa fil

@@ -0,0 +1,51 @@
1
+// Copyright 2017 The Go Authors. All rights reserved.
2
+// Use of this source code is governed by a BSD-style
3
+// license that can be found in the LICENSE file.
4
+
5
+// +build go1.7
6
+
7
+package unix_test
8
+
9
+import (
10
+	"fmt"
11
+	"testing"
12
+
13
+	"golang.org/x/sys/unix"
14
+)
15
+
16
+func TestDevices(t *testing.T) {
17
+	testCases := []struct {
18
+		path  string
19
+		major uint32
20
+		minor uint32
21
+	}{
22
+		// Most of the device major/minor numbers on Darwin are
23
+		// dynamically generated by devfs. These are some well-known
24
+		// static numbers.
25
+		{"/dev/ttyp0", 4, 0},
26
+		{"/dev/ttys0", 4, 48},
27
+		{"/dev/ptyp0", 5, 0},
28
+		{"/dev/ptyr0", 5, 32},
29
+	}
30
+	for _, tc := range testCases {
31
+		t.Run(fmt.Sprintf("%s %v:%v", tc.path, tc.major, tc.minor), func(t *testing.T) {
32
+			var stat unix.Stat_t
33
+			err := unix.Stat(tc.path, &stat)
34
+			if err != nil {
35
+				t.Errorf("failed to stat device: %v", err)
36
+				return
37
+			}
38
+
39
+			dev := uint64(stat.Rdev)
40
+			if unix.Major(dev) != tc.major {
41
+				t.Errorf("for %s Major(%#x) == %d, want %d", tc.path, dev, unix.Major(dev), tc.major)
42
+			}
43
+			if unix.Minor(dev) != tc.minor {
44
+				t.Errorf("for %s Minor(%#x) == %d, want %d", tc.path, dev, unix.Minor(dev), tc.minor)
45
+			}
46
+			if unix.Mkdev(tc.major, tc.minor) != dev {
47
+				t.Errorf("for %s Mkdev(%d, %d) == %#x, want %#x", tc.path, tc.major, tc.minor, unix.Mkdev(tc.major, tc.minor), dev)
48
+			}
49
+		})
50
+	}
51
+}

+ 30
- 0
vendor/src/golang.org/x/sys/unix/dev_dragonfly.go Visa fil

@@ -0,0 +1,30 @@
1
+// Copyright 2017 The Go Authors. All rights reserved.
2
+// Use of this source code is governed by a BSD-style
3
+// license that can be found in the LICENSE file.
4
+
5
+// Functions to access/create device major and minor numbers matching the
6
+// encoding used in Dragonfly's sys/types.h header.
7
+//
8
+// The information below is extracted and adapted from sys/types.h:
9
+//
10
+// Minor gives a cookie instead of an index since in order to avoid changing the
11
+// meanings of bits 0-15 or wasting time and space shifting bits 16-31 for
12
+// devices that don't use them.
13
+
14
+package unix
15
+
16
+// Major returns the major component of a DragonFlyBSD device number.
17
+func Major(dev uint64) uint32 {
18
+	return uint32((dev >> 8) & 0xff)
19
+}
20
+
21
+// Minor returns the minor component of a DragonFlyBSD device number.
22
+func Minor(dev uint64) uint32 {
23
+	return uint32(dev & 0xffff00ff)
24
+}
25
+
26
+// Mkdev returns a DragonFlyBSD device number generated from the given major and
27
+// minor components.
28
+func Mkdev(major, minor uint32) uint64 {
29
+	return (uint64(major) << 8) | uint64(minor)
30
+}

+ 50
- 0
vendor/src/golang.org/x/sys/unix/dev_dragonfly_test.go Visa fil

@@ -0,0 +1,50 @@
1
+// Copyright 2017 The Go Authors. All rights reserved.
2
+// Use of this source code is governed by a BSD-style
3
+// license that can be found in the LICENSE file.
4
+
5
+// +build go1.7
6
+
7
+package unix_test
8
+
9
+import (
10
+	"fmt"
11
+	"testing"
12
+
13
+	"golang.org/x/sys/unix"
14
+)
15
+
16
+func TestDevices(t *testing.T) {
17
+	testCases := []struct {
18
+		path  string
19
+		major uint32
20
+		minor uint32
21
+	}{
22
+		// Minor is a cookie instead of an index on DragonFlyBSD
23
+		{"/dev/null", 10, 0x00000002},
24
+		{"/dev/random", 10, 0x00000003},
25
+		{"/dev/urandom", 10, 0x00000004},
26
+		{"/dev/zero", 10, 0x0000000c},
27
+		{"/dev/bpf", 15, 0xffff00ff},
28
+	}
29
+	for _, tc := range testCases {
30
+		t.Run(fmt.Sprintf("%s %v:%v", tc.path, tc.major, tc.minor), func(t *testing.T) {
31
+			var stat unix.Stat_t
32
+			err := unix.Stat(tc.path, &stat)
33
+			if err != nil {
34
+				t.Errorf("failed to stat device: %v", err)
35
+				return
36
+			}
37
+
38
+			dev := uint64(stat.Rdev)
39
+			if unix.Major(dev) != tc.major {
40
+				t.Errorf("for %s Major(%#x) == %d, want %d", tc.path, dev, unix.Major(dev), tc.major)
41
+			}
42
+			if unix.Minor(dev) != tc.minor {
43
+				t.Errorf("for %s Minor(%#x) == %d, want %d", tc.path, dev, unix.Minor(dev), tc.minor)
44
+			}
45
+			if unix.Mkdev(tc.major, tc.minor) != dev {
46
+				t.Errorf("for %s Mkdev(%d, %d) == %#x, want %#x", tc.path, tc.major, tc.minor, unix.Mkdev(tc.major, tc.minor), dev)
47
+			}
48
+		})
49
+	}
50
+}

+ 30
- 0
vendor/src/golang.org/x/sys/unix/dev_freebsd.go Visa fil

@@ -0,0 +1,30 @@
1
+// Copyright 2017 The Go Authors. All rights reserved.
2
+// Use of this source code is governed by a BSD-style
3
+// license that can be found in the LICENSE file.
4
+
5
+// Functions to access/create device major and minor numbers matching the
6
+// encoding used in FreeBSD's sys/types.h header.
7
+//
8
+// The information below is extracted and adapted from sys/types.h:
9
+//
10
+// Minor gives a cookie instead of an index since in order to avoid changing the
11
+// meanings of bits 0-15 or wasting time and space shifting bits 16-31 for
12
+// devices that don't use them.
13
+
14
+package unix
15
+
16
+// Major returns the major component of a FreeBSD device number.
17
+func Major(dev uint64) uint32 {
18
+	return uint32((dev >> 8) & 0xff)
19
+}
20
+
21
+// Minor returns the minor component of a FreeBSD device number.
22
+func Minor(dev uint64) uint32 {
23
+	return uint32(dev & 0xffff00ff)
24
+}
25
+
26
+// Mkdev returns a FreeBSD device number generated from the given major and
27
+// minor components.
28
+func Mkdev(major, minor uint32) uint64 {
29
+	return (uint64(major) << 8) | uint64(minor)
30
+}

+ 42
- 0
vendor/src/golang.org/x/sys/unix/dev_linux.go Visa fil

@@ -0,0 +1,42 @@
1
+// Copyright 2017 The Go Authors. All rights reserved.
2
+// Use of this source code is governed by a BSD-style
3
+// license that can be found in the LICENSE file.
4
+
5
+// Functions to access/create device major and minor numbers matching the
6
+// encoding used by the Linux kernel and glibc.
7
+//
8
+// The information below is extracted and adapted from bits/sysmacros.h in the
9
+// glibc sources:
10
+//
11
+// dev_t in glibc is 64-bit, with 32-bit major and minor numbers. glibc's
12
+// default encoding is MMMM Mmmm mmmM MMmm, where M is a hex digit of the major
13
+// number and m is a hex digit of the minor number. This is backward compatible
14
+// with legacy systems where dev_t is 16 bits wide, encoded as MMmm. It is also
15
+// backward compatible with the Linux kernel, which for some architectures uses
16
+// 32-bit dev_t, encoded as mmmM MMmm.
17
+
18
+package unix
19
+
20
+// Major returns the major component of a Linux device number.
21
+func Major(dev uint64) uint32 {
22
+	major := uint32((dev & 0x00000000000fff00) >> 8)
23
+	major |= uint32((dev & 0xfffff00000000000) >> 32)
24
+	return major
25
+}
26
+
27
+// Minor returns the minor component of a Linux device number.
28
+func Minor(dev uint64) uint32 {
29
+	minor := uint32((dev & 0x00000000000000ff) >> 0)
30
+	minor |= uint32((dev & 0x00000ffffff00000) >> 12)
31
+	return minor
32
+}
33
+
34
+// Mkdev returns a Linux device number generated from the given major and minor
35
+// components.
36
+func Mkdev(major, minor uint32) uint64 {
37
+	dev := (uint64(major) & 0x00000fff) << 8
38
+	dev |= (uint64(major) & 0xfffff000) << 32
39
+	dev |= (uint64(minor) & 0x000000ff) << 0
40
+	dev |= (uint64(minor) & 0xffffff00) << 12
41
+	return dev
42
+}

+ 53
- 0
vendor/src/golang.org/x/sys/unix/dev_linux_test.go Visa fil

@@ -0,0 +1,53 @@
1
+// Copyright 2017 The Go Authors. All rights reserved.
2
+// Use of this source code is governed by a BSD-style
3
+// license that can be found in the LICENSE file.
4
+
5
+// +build go1.7
6
+
7
+package unix_test
8
+
9
+import (
10
+	"fmt"
11
+	"testing"
12
+
13
+	"golang.org/x/sys/unix"
14
+)
15
+
16
+func TestDevices(t *testing.T) {
17
+	testCases := []struct {
18
+		path  string
19
+		major uint32
20
+		minor uint32
21
+	}{
22
+		// well known major/minor numbers according to
23
+		// https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/admin-guide/devices.txt
24
+		{"/dev/null", 1, 3},
25
+		{"/dev/zero", 1, 5},
26
+		{"/dev/random", 1, 8},
27
+		{"/dev/full", 1, 7},
28
+		{"/dev/urandom", 1, 9},
29
+		{"/dev/tty", 5, 0},
30
+	}
31
+	for _, tc := range testCases {
32
+		t.Run(fmt.Sprintf("%s %v:%v", tc.path, tc.major, tc.minor), func(t *testing.T) {
33
+			var stat unix.Stat_t
34
+			err := unix.Stat(tc.path, &stat)
35
+			if err != nil {
36
+				t.Errorf("failed to stat device: %v", err)
37
+				return
38
+			}
39
+
40
+			dev := uint64(stat.Rdev)
41
+			if unix.Major(dev) != tc.major {
42
+				t.Errorf("for %s Major(%#x) == %d, want %d", tc.path, dev, unix.Major(dev), tc.major)
43
+			}
44
+			if unix.Minor(dev) != tc.minor {
45
+				t.Errorf("for %s Minor(%#x) == %d, want %d", tc.path, dev, unix.Minor(dev), tc.minor)
46
+			}
47
+			if unix.Mkdev(tc.major, tc.minor) != dev {
48
+				t.Errorf("for %s Mkdev(%d, %d) == %#x, want %#x", tc.path, tc.major, tc.minor, unix.Mkdev(tc.major, tc.minor), dev)
49
+			}
50
+		})
51
+
52
+	}
53
+}

+ 29
- 0
vendor/src/golang.org/x/sys/unix/dev_netbsd.go Visa fil

@@ -0,0 +1,29 @@
1
+// Copyright 2017 The Go Authors. All rights reserved.
2
+// Use of this source code is governed by a BSD-style
3
+// license that can be found in the LICENSE file.
4
+
5
+// Functions to access/create device major and minor numbers matching the
6
+// encoding used in NetBSD's sys/types.h header.
7
+
8
+package unix
9
+
10
+// Major returns the major component of a NetBSD device number.
11
+func Major(dev uint64) uint32 {
12
+	return uint32((dev & 0x000fff00) >> 8)
13
+}
14
+
15
+// Minor returns the minor component of a NetBSD device number.
16
+func Minor(dev uint64) uint32 {
17
+	minor := uint32((dev & 0x000000ff) >> 0)
18
+	minor |= uint32((dev & 0xfff00000) >> 12)
19
+	return minor
20
+}
21
+
22
+// Mkdev returns a NetBSD device number generated from the given major and minor
23
+// components.
24
+func Mkdev(major, minor uint32) uint64 {
25
+	dev := (uint64(major) << 8) & 0x000fff00
26
+	dev |= (uint64(minor) << 12) & 0xfff00000
27
+	dev |= (uint64(minor) << 0) & 0x000000ff
28
+	return dev
29
+}

+ 50
- 0
vendor/src/golang.org/x/sys/unix/dev_netbsd_test.go Visa fil

@@ -0,0 +1,50 @@
1
+// Copyright 2017 The Go Authors. All rights reserved.
2
+// Use of this source code is governed by a BSD-style
3
+// license that can be found in the LICENSE file.
4
+
5
+// +build go1.7
6
+
7
+package unix_test
8
+
9
+import (
10
+	"fmt"
11
+	"testing"
12
+
13
+	"golang.org/x/sys/unix"
14
+)
15
+
16
+func TestDevices(t *testing.T) {
17
+	testCases := []struct {
18
+		path  string
19
+		major uint32
20
+		minor uint32
21
+	}{
22
+		// well known major/minor numbers according to /dev/MAKEDEV on
23
+		// NetBSD 8.0
24
+		{"/dev/null", 2, 2},
25
+		{"/dev/zero", 2, 12},
26
+		{"/dev/random", 46, 0},
27
+		{"/dev/urandom", 46, 1},
28
+	}
29
+	for _, tc := range testCases {
30
+		t.Run(fmt.Sprintf("%s %v:%v", tc.path, tc.major, tc.minor), func(t *testing.T) {
31
+			var stat unix.Stat_t
32
+			err := unix.Stat(tc.path, &stat)
33
+			if err != nil {
34
+				t.Errorf("failed to stat device: %v", err)
35
+				return
36
+			}
37
+
38
+			dev := uint64(stat.Rdev)
39
+			if unix.Major(dev) != tc.major {
40
+				t.Errorf("for %s Major(%#x) == %d, want %d", tc.path, dev, unix.Major(dev), tc.major)
41
+			}
42
+			if unix.Minor(dev) != tc.minor {
43
+				t.Errorf("for %s Minor(%#x) == %d, want %d", tc.path, dev, unix.Minor(dev), tc.minor)
44
+			}
45
+			if unix.Mkdev(tc.major, tc.minor) != dev {
46
+				t.Errorf("for %s Mkdev(%d, %d) == %#x, want %#x", tc.path, tc.major, tc.minor, unix.Mkdev(tc.major, tc.minor), dev)
47
+			}
48
+		})
49
+	}
50
+}

+ 29
- 0
vendor/src/golang.org/x/sys/unix/dev_openbsd.go Visa fil

@@ -0,0 +1,29 @@
1
+// Copyright 2017 The Go Authors. All rights reserved.
2
+// Use of this source code is governed by a BSD-style
3
+// license that can be found in the LICENSE file.
4
+
5
+// Functions to access/create device major and minor numbers matching the
6
+// encoding used in OpenBSD's sys/types.h header.
7
+
8
+package unix
9
+
10
+// Major returns the major component of an OpenBSD device number.
11
+func Major(dev uint64) uint32 {
12
+	return uint32((dev & 0x0000ff00) >> 8)
13
+}
14
+
15
+// Minor returns the minor component of an OpenBSD device number.
16
+func Minor(dev uint64) uint32 {
17
+	minor := uint32((dev & 0x000000ff) >> 0)
18
+	minor |= uint32((dev & 0xffff0000) >> 8)
19
+	return minor
20
+}
21
+
22
+// Mkdev returns an OpenBSD device number generated from the given major and minor
23
+// components.
24
+func Mkdev(major, minor uint32) uint64 {
25
+	dev := (uint64(major) << 8) & 0x0000ff00
26
+	dev |= (uint64(minor) << 8) & 0xffff0000
27
+	dev |= (uint64(minor) << 0) & 0x000000ff
28
+	return dev
29
+}

+ 54
- 0
vendor/src/golang.org/x/sys/unix/dev_openbsd_test.go Visa fil

@@ -0,0 +1,54 @@
1
+// Copyright 2017 The Go Authors. All rights reserved.
2
+// Use of this source code is governed by a BSD-style
3
+// license that can be found in the LICENSE file.
4
+
5
+// +build go1.7
6
+
7
+package unix_test
8
+
9
+import (
10
+	"fmt"
11
+	"testing"
12
+
13
+	"golang.org/x/sys/unix"
14
+)
15
+
16
+func TestDevices(t *testing.T) {
17
+	testCases := []struct {
18
+		path  string
19
+		major uint32
20
+		minor uint32
21
+	}{
22
+		// well known major/minor numbers according to /dev/MAKEDEV on
23
+		// OpenBSD 6.0
24
+		{"/dev/null", 2, 2},
25
+		{"/dev/zero", 2, 12},
26
+		{"/dev/ttyp0", 5, 0},
27
+		{"/dev/ttyp1", 5, 1},
28
+		{"/dev/random", 45, 0},
29
+		{"/dev/srandom", 45, 1},
30
+		{"/dev/urandom", 45, 2},
31
+		{"/dev/arandom", 45, 3},
32
+	}
33
+	for _, tc := range testCases {
34
+		t.Run(fmt.Sprintf("%s %v:%v", tc.path, tc.major, tc.minor), func(t *testing.T) {
35
+			var stat unix.Stat_t
36
+			err := unix.Stat(tc.path, &stat)
37
+			if err != nil {
38
+				t.Errorf("failed to stat device: %v", err)
39
+				return
40
+			}
41
+
42
+			dev := uint64(stat.Rdev)
43
+			if unix.Major(dev) != tc.major {
44
+				t.Errorf("for %s Major(%#x) == %d, want %d", tc.path, dev, unix.Major(dev), tc.major)
45
+			}
46
+			if unix.Minor(dev) != tc.minor {
47
+				t.Errorf("for %s Minor(%#x) == %d, want %d", tc.path, dev, unix.Minor(dev), tc.minor)
48
+			}
49
+			if unix.Mkdev(tc.major, tc.minor) != dev {
50
+				t.Errorf("for %s Mkdev(%d, %d) == %#x, want %#x", tc.path, tc.major, tc.minor, unix.Mkdev(tc.major, tc.minor), dev)
51
+			}
52
+		})
53
+	}
54
+}

+ 51
- 0
vendor/src/golang.org/x/sys/unix/dev_solaris_test.go Visa fil

@@ -0,0 +1,51 @@
1
+// Copyright 2017 The Go Authors. All rights reserved.
2
+// Use of this source code is governed by a BSD-style
3
+// license that can be found in the LICENSE file.
4
+
5
+// +build go1.7
6
+
7
+package unix_test
8
+
9
+import (
10
+	"fmt"
11
+	"testing"
12
+
13
+	"golang.org/x/sys/unix"
14
+)
15
+
16
+func TestDevices(t *testing.T) {
17
+	testCases := []struct {
18
+		path  string
19
+		major uint32
20
+		minor uint32
21
+	}{
22
+		// Well-known major/minor numbers on OpenSolaris according to
23
+		// /etc/name_to_major
24
+		{"/dev/zero", 134, 12},
25
+		{"/dev/null", 134, 2},
26
+		{"/dev/ptyp0", 172, 0},
27
+		{"/dev/ttyp0", 175, 0},
28
+		{"/dev/ttyp1", 175, 1},
29
+	}
30
+	for _, tc := range testCases {
31
+		t.Run(fmt.Sprintf("%s %v:%v", tc.path, tc.major, tc.minor), func(t *testing.T) {
32
+			var stat unix.Stat_t
33
+			err := unix.Stat(tc.path, &stat)
34
+			if err != nil {
35
+				t.Errorf("failed to stat device: %v", err)
36
+				return
37
+			}
38
+
39
+			dev := uint64(stat.Rdev)
40
+			if unix.Major(dev) != tc.major {
41
+				t.Errorf("for %s Major(%#x) == %d, want %d", tc.path, dev, unix.Major(dev), tc.major)
42
+			}
43
+			if unix.Minor(dev) != tc.minor {
44
+				t.Errorf("for %s Minor(%#x) == %d, want %d", tc.path, dev, unix.Minor(dev), tc.minor)
45
+			}
46
+			if unix.Mkdev(tc.major, tc.minor) != dev {
47
+				t.Errorf("for %s Mkdev(%d, %d) == %#x, want %#x", tc.path, tc.major, tc.minor, unix.Mkdev(tc.major, tc.minor), dev)
48
+			}
49
+		})
50
+	}
51
+}

+ 102
- 0
vendor/src/golang.org/x/sys/unix/dirent.go Visa fil

@@ -0,0 +1,102 @@
1
+// Copyright 2009 The Go Authors. All rights reserved.
2
+// Use of this source code is governed by a BSD-style
3
+// license that can be found in the LICENSE file.
4
+
5
+// +build darwin dragonfly freebsd linux nacl netbsd openbsd solaris
6
+
7
+package unix
8
+
9
+import "unsafe"
10
+
11
+// readInt returns the size-bytes unsigned integer in native byte order at offset off.
12
+func readInt(b []byte, off, size uintptr) (u uint64, ok bool) {
13
+	if len(b) < int(off+size) {
14
+		return 0, false
15
+	}
16
+	if isBigEndian {
17
+		return readIntBE(b[off:], size), true
18
+	}
19
+	return readIntLE(b[off:], size), true
20
+}
21
+
22
+func readIntBE(b []byte, size uintptr) uint64 {
23
+	switch size {
24
+	case 1:
25
+		return uint64(b[0])
26
+	case 2:
27
+		_ = b[1] // bounds check hint to compiler; see golang.org/issue/14808
28
+		return uint64(b[1]) | uint64(b[0])<<8
29
+	case 4:
30
+		_ = b[3] // bounds check hint to compiler; see golang.org/issue/14808
31
+		return uint64(b[3]) | uint64(b[2])<<8 | uint64(b[1])<<16 | uint64(b[0])<<24
32
+	case 8:
33
+		_ = b[7] // bounds check hint to compiler; see golang.org/issue/14808
34
+		return uint64(b[7]) | uint64(b[6])<<8 | uint64(b[5])<<16 | uint64(b[4])<<24 |
35
+			uint64(b[3])<<32 | uint64(b[2])<<40 | uint64(b[1])<<48 | uint64(b[0])<<56
36
+	default:
37
+		panic("syscall: readInt with unsupported size")
38
+	}
39
+}
40
+
41
+func readIntLE(b []byte, size uintptr) uint64 {
42
+	switch size {
43
+	case 1:
44
+		return uint64(b[0])
45
+	case 2:
46
+		_ = b[1] // bounds check hint to compiler; see golang.org/issue/14808
47
+		return uint64(b[0]) | uint64(b[1])<<8
48
+	case 4:
49
+		_ = b[3] // bounds check hint to compiler; see golang.org/issue/14808
50
+		return uint64(b[0]) | uint64(b[1])<<8 | uint64(b[2])<<16 | uint64(b[3])<<24
51
+	case 8:
52
+		_ = b[7] // bounds check hint to compiler; see golang.org/issue/14808
53
+		return uint64(b[0]) | uint64(b[1])<<8 | uint64(b[2])<<16 | uint64(b[3])<<24 |
54
+			uint64(b[4])<<32 | uint64(b[5])<<40 | uint64(b[6])<<48 | uint64(b[7])<<56
55
+	default:
56
+		panic("syscall: readInt with unsupported size")
57
+	}
58
+}
59
+
60
+// ParseDirent parses up to max directory entries in buf,
61
+// appending the names to names. It returns the number of
62
+// bytes consumed from buf, the number of entries added
63
+// to names, and the new names slice.
64
+func ParseDirent(buf []byte, max int, names []string) (consumed int, count int, newnames []string) {
65
+	origlen := len(buf)
66
+	count = 0
67
+	for max != 0 && len(buf) > 0 {
68
+		reclen, ok := direntReclen(buf)
69
+		if !ok || reclen > uint64(len(buf)) {
70
+			return origlen, count, names
71
+		}
72
+		rec := buf[:reclen]
73
+		buf = buf[reclen:]
74
+		ino, ok := direntIno(rec)
75
+		if !ok {
76
+			break
77
+		}
78
+		if ino == 0 { // File absent in directory.
79
+			continue
80
+		}
81
+		const namoff = uint64(unsafe.Offsetof(Dirent{}.Name))
82
+		namlen, ok := direntNamlen(rec)
83
+		if !ok || namoff+namlen > uint64(len(rec)) {
84
+			break
85
+		}
86
+		name := rec[namoff : namoff+namlen]
87
+		for i, c := range name {
88
+			if c == 0 {
89
+				name = name[:i]
90
+				break
91
+			}
92
+		}
93
+		// Check for useless names before allocating a string.
94
+		if string(name) == "." || string(name) == ".." {
95
+			continue
96
+		}
97
+		max--
98
+		count++
99
+		names = append(names, string(name))
100
+	}
101
+	return origlen - len(buf), count, names
102
+}

+ 9
- 0
vendor/src/golang.org/x/sys/unix/endian_big.go Visa fil

@@ -0,0 +1,9 @@
1
+// Copyright 2016 The Go Authors. All rights reserved.
2
+// Use of this source code is governed by a BSD-style
3
+// license that can be found in the LICENSE file.
4
+//
5
+// +build ppc64 s390x mips mips64
6
+
7
+package unix
8
+
9
+const isBigEndian = true

+ 9
- 0
vendor/src/golang.org/x/sys/unix/endian_little.go Visa fil

@@ -0,0 +1,9 @@
1
+// Copyright 2016 The Go Authors. All rights reserved.
2
+// Use of this source code is governed by a BSD-style
3
+// license that can be found in the LICENSE file.
4
+//
5
+// +build 386 amd64 amd64p32 arm arm64 ppc64le mipsle mips64le
6
+
7
+package unix
8
+
9
+const isBigEndian = false

+ 31
- 0
vendor/src/golang.org/x/sys/unix/env_unix.go Visa fil

@@ -0,0 +1,31 @@
1
+// Copyright 2010 The Go Authors. All rights reserved.
2
+// Use of this source code is governed by a BSD-style
3
+// license that can be found in the LICENSE file.
4
+
5
+// +build darwin dragonfly freebsd linux netbsd openbsd solaris
6
+
7
+// Unix environment variables.
8
+
9
+package unix
10
+
11
+import "syscall"
12
+
13
+func Getenv(key string) (value string, found bool) {
14
+	return syscall.Getenv(key)
15
+}
16
+
17
+func Setenv(key, value string) error {
18
+	return syscall.Setenv(key, value)
19
+}
20
+
21
+func Clearenv() {
22
+	syscall.Clearenv()
23
+}
24
+
25
+func Environ() []string {
26
+	return syscall.Environ()
27
+}
28
+
29
+func Unsetenv(key string) error {
30
+	return syscall.Unsetenv(key)
31
+}

+ 227
- 0
vendor/src/golang.org/x/sys/unix/errors_freebsd_386.go Visa fil

@@ -0,0 +1,227 @@
1
+// Copyright 2017 The Go Authors. All rights reserved.
2
+// Use of this source code is governed by a BSD-style
3
+// license that can be found in the LICENSE file.
4
+
5
+// Constants that were deprecated or moved to enums in the FreeBSD headers. Keep
6
+// them here for backwards compatibility.
7
+
8
+package unix
9
+
10
+const (
11
+	IFF_SMART                         = 0x20
12
+	IFT_1822                          = 0x2
13
+	IFT_A12MPPSWITCH                  = 0x82
14
+	IFT_AAL2                          = 0xbb
15
+	IFT_AAL5                          = 0x31
16
+	IFT_ADSL                          = 0x5e
17
+	IFT_AFLANE8023                    = 0x3b
18
+	IFT_AFLANE8025                    = 0x3c
19
+	IFT_ARAP                          = 0x58
20
+	IFT_ARCNET                        = 0x23
21
+	IFT_ARCNETPLUS                    = 0x24
22
+	IFT_ASYNC                         = 0x54
23
+	IFT_ATM                           = 0x25
24
+	IFT_ATMDXI                        = 0x69
25
+	IFT_ATMFUNI                       = 0x6a
26
+	IFT_ATMIMA                        = 0x6b
27
+	IFT_ATMLOGICAL                    = 0x50
28
+	IFT_ATMRADIO                      = 0xbd
29
+	IFT_ATMSUBINTERFACE               = 0x86
30
+	IFT_ATMVCIENDPT                   = 0xc2
31
+	IFT_ATMVIRTUAL                    = 0x95
32
+	IFT_BGPPOLICYACCOUNTING           = 0xa2
33
+	IFT_BSC                           = 0x53
34
+	IFT_CCTEMUL                       = 0x3d
35
+	IFT_CEPT                          = 0x13
36
+	IFT_CES                           = 0x85
37
+	IFT_CHANNEL                       = 0x46
38
+	IFT_CNR                           = 0x55
39
+	IFT_COFFEE                        = 0x84
40
+	IFT_COMPOSITELINK                 = 0x9b
41
+	IFT_DCN                           = 0x8d
42
+	IFT_DIGITALPOWERLINE              = 0x8a
43
+	IFT_DIGITALWRAPPEROVERHEADCHANNEL = 0xba
44
+	IFT_DLSW                          = 0x4a
45
+	IFT_DOCSCABLEDOWNSTREAM           = 0x80
46
+	IFT_DOCSCABLEMACLAYER             = 0x7f
47
+	IFT_DOCSCABLEUPSTREAM             = 0x81
48
+	IFT_DS0                           = 0x51
49
+	IFT_DS0BUNDLE                     = 0x52
50
+	IFT_DS1FDL                        = 0xaa
51
+	IFT_DS3                           = 0x1e
52
+	IFT_DTM                           = 0x8c
53
+	IFT_DVBASILN                      = 0xac
54
+	IFT_DVBASIOUT                     = 0xad
55
+	IFT_DVBRCCDOWNSTREAM              = 0x93
56
+	IFT_DVBRCCMACLAYER                = 0x92
57
+	IFT_DVBRCCUPSTREAM                = 0x94
58
+	IFT_ENC                           = 0xf4
59
+	IFT_EON                           = 0x19
60
+	IFT_EPLRS                         = 0x57
61
+	IFT_ESCON                         = 0x49
62
+	IFT_ETHER                         = 0x6
63
+	IFT_FAITH                         = 0xf2
64
+	IFT_FAST                          = 0x7d
65
+	IFT_FASTETHER                     = 0x3e
66
+	IFT_FASTETHERFX                   = 0x45
67
+	IFT_FDDI                          = 0xf
68
+	IFT_FIBRECHANNEL                  = 0x38
69
+	IFT_FRAMERELAYINTERCONNECT        = 0x3a
70
+	IFT_FRAMERELAYMPI                 = 0x5c
71
+	IFT_FRDLCIENDPT                   = 0xc1
72
+	IFT_FRELAY                        = 0x20
73
+	IFT_FRELAYDCE                     = 0x2c
74
+	IFT_FRF16MFRBUNDLE                = 0xa3
75
+	IFT_FRFORWARD                     = 0x9e
76
+	IFT_G703AT2MB                     = 0x43
77
+	IFT_G703AT64K                     = 0x42
78
+	IFT_GIF                           = 0xf0
79
+	IFT_GIGABITETHERNET               = 0x75
80
+	IFT_GR303IDT                      = 0xb2
81
+	IFT_GR303RDT                      = 0xb1
82
+	IFT_H323GATEKEEPER                = 0xa4
83
+	IFT_H323PROXY                     = 0xa5
84
+	IFT_HDH1822                       = 0x3
85
+	IFT_HDLC                          = 0x76
86
+	IFT_HDSL2                         = 0xa8
87
+	IFT_HIPERLAN2                     = 0xb7
88
+	IFT_HIPPI                         = 0x2f
89
+	IFT_HIPPIINTERFACE                = 0x39
90
+	IFT_HOSTPAD                       = 0x5a
91
+	IFT_HSSI                          = 0x2e
92
+	IFT_HY                            = 0xe
93
+	IFT_IBM370PARCHAN                 = 0x48
94
+	IFT_IDSL                          = 0x9a
95
+	IFT_IEEE80211                     = 0x47
96
+	IFT_IEEE80212                     = 0x37
97
+	IFT_IEEE8023ADLAG                 = 0xa1
98
+	IFT_IFGSN                         = 0x91
99
+	IFT_IMT                           = 0xbe
100
+	IFT_INTERLEAVE                    = 0x7c
101
+	IFT_IP                            = 0x7e
102
+	IFT_IPFORWARD                     = 0x8e
103
+	IFT_IPOVERATM                     = 0x72
104
+	IFT_IPOVERCDLC                    = 0x6d
105
+	IFT_IPOVERCLAW                    = 0x6e
106
+	IFT_IPSWITCH                      = 0x4e
107
+	IFT_IPXIP                         = 0xf9
108
+	IFT_ISDN                          = 0x3f
109
+	IFT_ISDNBASIC                     = 0x14
110
+	IFT_ISDNPRIMARY                   = 0x15
111
+	IFT_ISDNS                         = 0x4b
112
+	IFT_ISDNU                         = 0x4c
113
+	IFT_ISO88022LLC                   = 0x29
114
+	IFT_ISO88023                      = 0x7
115
+	IFT_ISO88024                      = 0x8
116
+	IFT_ISO88025                      = 0x9
117
+	IFT_ISO88025CRFPINT               = 0x62
118
+	IFT_ISO88025DTR                   = 0x56
119
+	IFT_ISO88025FIBER                 = 0x73
120
+	IFT_ISO88026                      = 0xa
121
+	IFT_ISUP                          = 0xb3
122
+	IFT_L3IPXVLAN                     = 0x89
123
+	IFT_LAPB                          = 0x10
124
+	IFT_LAPD                          = 0x4d
125
+	IFT_LAPF                          = 0x77
126
+	IFT_LOCALTALK                     = 0x2a
127
+	IFT_LOOP                          = 0x18
128
+	IFT_MEDIAMAILOVERIP               = 0x8b
129
+	IFT_MFSIGLINK                     = 0xa7
130
+	IFT_MIOX25                        = 0x26
131
+	IFT_MODEM                         = 0x30
132
+	IFT_MPC                           = 0x71
133
+	IFT_MPLS                          = 0xa6
134
+	IFT_MPLSTUNNEL                    = 0x96
135
+	IFT_MSDSL                         = 0x8f
136
+	IFT_MVL                           = 0xbf
137
+	IFT_MYRINET                       = 0x63
138
+	IFT_NFAS                          = 0xaf
139
+	IFT_NSIP                          = 0x1b
140
+	IFT_OPTICALCHANNEL                = 0xc3
141
+	IFT_OPTICALTRANSPORT              = 0xc4
142
+	IFT_OTHER                         = 0x1
143
+	IFT_P10                           = 0xc
144
+	IFT_P80                           = 0xd
145
+	IFT_PARA                          = 0x22
146
+	IFT_PFLOG                         = 0xf6
147
+	IFT_PFSYNC                        = 0xf7
148
+	IFT_PLC                           = 0xae
149
+	IFT_POS                           = 0xab
150
+	IFT_PPPMULTILINKBUNDLE            = 0x6c
151
+	IFT_PROPBWAP2MP                   = 0xb8
152
+	IFT_PROPCNLS                      = 0x59
153
+	IFT_PROPDOCSWIRELESSDOWNSTREAM    = 0xb5
154
+	IFT_PROPDOCSWIRELESSMACLAYER      = 0xb4
155
+	IFT_PROPDOCSWIRELESSUPSTREAM      = 0xb6
156
+	IFT_PROPMUX                       = 0x36
157
+	IFT_PROPWIRELESSP2P               = 0x9d
158
+	IFT_PTPSERIAL                     = 0x16
159
+	IFT_PVC                           = 0xf1
160
+	IFT_QLLC                          = 0x44
161
+	IFT_RADIOMAC                      = 0xbc
162
+	IFT_RADSL                         = 0x5f
163
+	IFT_REACHDSL                      = 0xc0
164
+	IFT_RFC1483                       = 0x9f
165
+	IFT_RS232                         = 0x21
166
+	IFT_RSRB                          = 0x4f
167
+	IFT_SDLC                          = 0x11
168
+	IFT_SDSL                          = 0x60
169
+	IFT_SHDSL                         = 0xa9
170
+	IFT_SIP                           = 0x1f
171
+	IFT_SLIP                          = 0x1c
172
+	IFT_SMDSDXI                       = 0x2b
173
+	IFT_SMDSICIP                      = 0x34
174
+	IFT_SONET                         = 0x27
175
+	IFT_SONETOVERHEADCHANNEL          = 0xb9
176
+	IFT_SONETPATH                     = 0x32
177
+	IFT_SONETVT                       = 0x33
178
+	IFT_SRP                           = 0x97
179
+	IFT_SS7SIGLINK                    = 0x9c
180
+	IFT_STACKTOSTACK                  = 0x6f
181
+	IFT_STARLAN                       = 0xb
182
+	IFT_STF                           = 0xd7
183
+	IFT_T1                            = 0x12
184
+	IFT_TDLC                          = 0x74
185
+	IFT_TERMPAD                       = 0x5b
186
+	IFT_TR008                         = 0xb0
187
+	IFT_TRANSPHDLC                    = 0x7b
188
+	IFT_TUNNEL                        = 0x83
189
+	IFT_ULTRA                         = 0x1d
190
+	IFT_USB                           = 0xa0
191
+	IFT_V11                           = 0x40
192
+	IFT_V35                           = 0x2d
193
+	IFT_V36                           = 0x41
194
+	IFT_V37                           = 0x78
195
+	IFT_VDSL                          = 0x61
196
+	IFT_VIRTUALIPADDRESS              = 0x70
197
+	IFT_VOICEEM                       = 0x64
198
+	IFT_VOICEENCAP                    = 0x67
199
+	IFT_VOICEFXO                      = 0x65
200
+	IFT_VOICEFXS                      = 0x66
201
+	IFT_VOICEOVERATM                  = 0x98
202
+	IFT_VOICEOVERFRAMERELAY           = 0x99
203
+	IFT_VOICEOVERIP                   = 0x68
204
+	IFT_X213                          = 0x5d
205
+	IFT_X25                           = 0x5
206
+	IFT_X25DDN                        = 0x4
207
+	IFT_X25HUNTGROUP                  = 0x7a
208
+	IFT_X25MLP                        = 0x79
209
+	IFT_X25PLE                        = 0x28
210
+	IFT_XETHER                        = 0x1a
211
+	IPPROTO_MAXID                     = 0x34
212
+	IPV6_FAITH                        = 0x1d
213
+	IP_FAITH                          = 0x16
214
+	MAP_NORESERVE                     = 0x40
215
+	MAP_RENAME                        = 0x20
216
+	NET_RT_MAXID                      = 0x6
217
+	RTF_PRCLONING                     = 0x10000
218
+	RTM_OLDADD                        = 0x9
219
+	RTM_OLDDEL                        = 0xa
220
+	SIOCADDRT                         = 0x8030720a
221
+	SIOCALIFADDR                      = 0x8118691b
222
+	SIOCDELRT                         = 0x8030720b
223
+	SIOCDLIFADDR                      = 0x8118691d
224
+	SIOCGLIFADDR                      = 0xc118691c
225
+	SIOCGLIFPHYADDR                   = 0xc118694b
226
+	SIOCSLIFPHYADDR                   = 0x8118694a
227
+)

+ 227
- 0
vendor/src/golang.org/x/sys/unix/errors_freebsd_amd64.go Visa fil

@@ -0,0 +1,227 @@
1
+// Copyright 2017 The Go Authors. All rights reserved.
2
+// Use of this source code is governed by a BSD-style
3
+// license that can be found in the LICENSE file.
4
+
5
+// Constants that were deprecated or moved to enums in the FreeBSD headers. Keep
6
+// them here for backwards compatibility.
7
+
8
+package unix
9
+
10
+const (
11
+	IFF_SMART                         = 0x20
12
+	IFT_1822                          = 0x2
13
+	IFT_A12MPPSWITCH                  = 0x82
14
+	IFT_AAL2                          = 0xbb
15
+	IFT_AAL5                          = 0x31
16
+	IFT_ADSL                          = 0x5e
17
+	IFT_AFLANE8023                    = 0x3b
18
+	IFT_AFLANE8025                    = 0x3c
19
+	IFT_ARAP                          = 0x58
20
+	IFT_ARCNET                        = 0x23
21
+	IFT_ARCNETPLUS                    = 0x24
22
+	IFT_ASYNC                         = 0x54
23
+	IFT_ATM                           = 0x25
24
+	IFT_ATMDXI                        = 0x69
25
+	IFT_ATMFUNI                       = 0x6a
26
+	IFT_ATMIMA                        = 0x6b
27
+	IFT_ATMLOGICAL                    = 0x50
28
+	IFT_ATMRADIO                      = 0xbd
29
+	IFT_ATMSUBINTERFACE               = 0x86
30
+	IFT_ATMVCIENDPT                   = 0xc2
31
+	IFT_ATMVIRTUAL                    = 0x95
32
+	IFT_BGPPOLICYACCOUNTING           = 0xa2
33
+	IFT_BSC                           = 0x53
34
+	IFT_CCTEMUL                       = 0x3d
35
+	IFT_CEPT                          = 0x13
36
+	IFT_CES                           = 0x85
37
+	IFT_CHANNEL                       = 0x46
38
+	IFT_CNR                           = 0x55
39
+	IFT_COFFEE                        = 0x84
40
+	IFT_COMPOSITELINK                 = 0x9b
41
+	IFT_DCN                           = 0x8d
42
+	IFT_DIGITALPOWERLINE              = 0x8a
43
+	IFT_DIGITALWRAPPEROVERHEADCHANNEL = 0xba
44
+	IFT_DLSW                          = 0x4a
45
+	IFT_DOCSCABLEDOWNSTREAM           = 0x80
46
+	IFT_DOCSCABLEMACLAYER             = 0x7f
47
+	IFT_DOCSCABLEUPSTREAM             = 0x81
48
+	IFT_DS0                           = 0x51
49
+	IFT_DS0BUNDLE                     = 0x52
50
+	IFT_DS1FDL                        = 0xaa
51
+	IFT_DS3                           = 0x1e
52
+	IFT_DTM                           = 0x8c
53
+	IFT_DVBASILN                      = 0xac
54
+	IFT_DVBASIOUT                     = 0xad
55
+	IFT_DVBRCCDOWNSTREAM              = 0x93
56
+	IFT_DVBRCCMACLAYER                = 0x92
57
+	IFT_DVBRCCUPSTREAM                = 0x94
58
+	IFT_ENC                           = 0xf4
59
+	IFT_EON                           = 0x19
60
+	IFT_EPLRS                         = 0x57
61
+	IFT_ESCON                         = 0x49
62
+	IFT_ETHER                         = 0x6
63
+	IFT_FAITH                         = 0xf2
64
+	IFT_FAST                          = 0x7d
65
+	IFT_FASTETHER                     = 0x3e
66
+	IFT_FASTETHERFX                   = 0x45
67
+	IFT_FDDI                          = 0xf
68
+	IFT_FIBRECHANNEL                  = 0x38
69
+	IFT_FRAMERELAYINTERCONNECT        = 0x3a
70
+	IFT_FRAMERELAYMPI                 = 0x5c
71
+	IFT_FRDLCIENDPT                   = 0xc1
72
+	IFT_FRELAY                        = 0x20
73
+	IFT_FRELAYDCE                     = 0x2c
74
+	IFT_FRF16MFRBUNDLE                = 0xa3
75
+	IFT_FRFORWARD                     = 0x9e
76
+	IFT_G703AT2MB                     = 0x43
77
+	IFT_G703AT64K                     = 0x42
78
+	IFT_GIF                           = 0xf0
79
+	IFT_GIGABITETHERNET               = 0x75
80
+	IFT_GR303IDT                      = 0xb2
81
+	IFT_GR303RDT                      = 0xb1
82
+	IFT_H323GATEKEEPER                = 0xa4
83
+	IFT_H323PROXY                     = 0xa5
84
+	IFT_HDH1822                       = 0x3
85
+	IFT_HDLC                          = 0x76
86
+	IFT_HDSL2                         = 0xa8
87
+	IFT_HIPERLAN2                     = 0xb7
88
+	IFT_HIPPI                         = 0x2f
89
+	IFT_HIPPIINTERFACE                = 0x39
90
+	IFT_HOSTPAD                       = 0x5a
91
+	IFT_HSSI                          = 0x2e
92
+	IFT_HY                            = 0xe
93
+	IFT_IBM370PARCHAN                 = 0x48
94
+	IFT_IDSL                          = 0x9a
95
+	IFT_IEEE80211                     = 0x47
96
+	IFT_IEEE80212                     = 0x37
97
+	IFT_IEEE8023ADLAG                 = 0xa1
98
+	IFT_IFGSN                         = 0x91
99
+	IFT_IMT                           = 0xbe
100
+	IFT_INTERLEAVE                    = 0x7c
101
+	IFT_IP                            = 0x7e
102
+	IFT_IPFORWARD                     = 0x8e
103
+	IFT_IPOVERATM                     = 0x72
104
+	IFT_IPOVERCDLC                    = 0x6d
105
+	IFT_IPOVERCLAW                    = 0x6e
106
+	IFT_IPSWITCH                      = 0x4e
107
+	IFT_IPXIP                         = 0xf9
108
+	IFT_ISDN                          = 0x3f
109
+	IFT_ISDNBASIC                     = 0x14
110
+	IFT_ISDNPRIMARY                   = 0x15
111
+	IFT_ISDNS                         = 0x4b
112
+	IFT_ISDNU                         = 0x4c
113
+	IFT_ISO88022LLC                   = 0x29
114
+	IFT_ISO88023                      = 0x7
115
+	IFT_ISO88024                      = 0x8
116
+	IFT_ISO88025                      = 0x9
117
+	IFT_ISO88025CRFPINT               = 0x62
118
+	IFT_ISO88025DTR                   = 0x56
119
+	IFT_ISO88025FIBER                 = 0x73
120
+	IFT_ISO88026                      = 0xa
121
+	IFT_ISUP                          = 0xb3
122
+	IFT_L3IPXVLAN                     = 0x89
123
+	IFT_LAPB                          = 0x10
124
+	IFT_LAPD                          = 0x4d
125
+	IFT_LAPF                          = 0x77
126
+	IFT_LOCALTALK                     = 0x2a
127
+	IFT_LOOP                          = 0x18
128
+	IFT_MEDIAMAILOVERIP               = 0x8b
129
+	IFT_MFSIGLINK                     = 0xa7
130
+	IFT_MIOX25                        = 0x26
131
+	IFT_MODEM                         = 0x30
132
+	IFT_MPC                           = 0x71
133
+	IFT_MPLS                          = 0xa6
134
+	IFT_MPLSTUNNEL                    = 0x96
135
+	IFT_MSDSL                         = 0x8f
136
+	IFT_MVL                           = 0xbf
137
+	IFT_MYRINET                       = 0x63
138
+	IFT_NFAS                          = 0xaf
139
+	IFT_NSIP                          = 0x1b
140
+	IFT_OPTICALCHANNEL                = 0xc3
141
+	IFT_OPTICALTRANSPORT              = 0xc4
142
+	IFT_OTHER                         = 0x1
143
+	IFT_P10                           = 0xc
144
+	IFT_P80                           = 0xd
145
+	IFT_PARA                          = 0x22
146
+	IFT_PFLOG                         = 0xf6
147
+	IFT_PFSYNC                        = 0xf7
148
+	IFT_PLC                           = 0xae
149
+	IFT_POS                           = 0xab
150
+	IFT_PPPMULTILINKBUNDLE            = 0x6c
151
+	IFT_PROPBWAP2MP                   = 0xb8
152
+	IFT_PROPCNLS                      = 0x59
153
+	IFT_PROPDOCSWIRELESSDOWNSTREAM    = 0xb5
154
+	IFT_PROPDOCSWIRELESSMACLAYER      = 0xb4
155
+	IFT_PROPDOCSWIRELESSUPSTREAM      = 0xb6
156
+	IFT_PROPMUX                       = 0x36
157
+	IFT_PROPWIRELESSP2P               = 0x9d
158
+	IFT_PTPSERIAL                     = 0x16
159
+	IFT_PVC                           = 0xf1
160
+	IFT_QLLC                          = 0x44
161
+	IFT_RADIOMAC                      = 0xbc
162
+	IFT_RADSL                         = 0x5f
163
+	IFT_REACHDSL                      = 0xc0
164
+	IFT_RFC1483                       = 0x9f
165
+	IFT_RS232                         = 0x21
166
+	IFT_RSRB                          = 0x4f
167
+	IFT_SDLC                          = 0x11
168
+	IFT_SDSL                          = 0x60
169
+	IFT_SHDSL                         = 0xa9
170
+	IFT_SIP                           = 0x1f
171
+	IFT_SLIP                          = 0x1c
172
+	IFT_SMDSDXI                       = 0x2b
173
+	IFT_SMDSICIP                      = 0x34
174
+	IFT_SONET                         = 0x27
175
+	IFT_SONETOVERHEADCHANNEL          = 0xb9
176
+	IFT_SONETPATH                     = 0x32
177
+	IFT_SONETVT                       = 0x33
178
+	IFT_SRP                           = 0x97
179
+	IFT_SS7SIGLINK                    = 0x9c
180
+	IFT_STACKTOSTACK                  = 0x6f
181
+	IFT_STARLAN                       = 0xb
182
+	IFT_STF                           = 0xd7
183
+	IFT_T1                            = 0x12
184
+	IFT_TDLC                          = 0x74
185
+	IFT_TERMPAD                       = 0x5b
186
+	IFT_TR008                         = 0xb0
187
+	IFT_TRANSPHDLC                    = 0x7b
188
+	IFT_TUNNEL                        = 0x83
189
+	IFT_ULTRA                         = 0x1d
190
+	IFT_USB                           = 0xa0
191
+	IFT_V11                           = 0x40
192
+	IFT_V35                           = 0x2d
193
+	IFT_V36                           = 0x41
194
+	IFT_V37                           = 0x78
195
+	IFT_VDSL                          = 0x61
196
+	IFT_VIRTUALIPADDRESS              = 0x70
197
+	IFT_VOICEEM                       = 0x64
198
+	IFT_VOICEENCAP                    = 0x67
199
+	IFT_VOICEFXO                      = 0x65
200
+	IFT_VOICEFXS                      = 0x66
201
+	IFT_VOICEOVERATM                  = 0x98
202
+	IFT_VOICEOVERFRAMERELAY           = 0x99
203
+	IFT_VOICEOVERIP                   = 0x68
204
+	IFT_X213                          = 0x5d
205
+	IFT_X25                           = 0x5
206
+	IFT_X25DDN                        = 0x4
207
+	IFT_X25HUNTGROUP                  = 0x7a
208
+	IFT_X25MLP                        = 0x79
209
+	IFT_X25PLE                        = 0x28
210
+	IFT_XETHER                        = 0x1a
211
+	IPPROTO_MAXID                     = 0x34
212
+	IPV6_FAITH                        = 0x1d
213
+	IP_FAITH                          = 0x16
214
+	MAP_NORESERVE                     = 0x40
215
+	MAP_RENAME                        = 0x20
216
+	NET_RT_MAXID                      = 0x6
217
+	RTF_PRCLONING                     = 0x10000
218
+	RTM_OLDADD                        = 0x9
219
+	RTM_OLDDEL                        = 0xa
220
+	SIOCADDRT                         = 0x8040720a
221
+	SIOCALIFADDR                      = 0x8118691b
222
+	SIOCDELRT                         = 0x8040720b
223
+	SIOCDLIFADDR                      = 0x8118691d
224
+	SIOCGLIFADDR                      = 0xc118691c
225
+	SIOCGLIFPHYADDR                   = 0xc118694b
226
+	SIOCSLIFPHYADDR                   = 0x8118694a
227
+)

+ 226
- 0
vendor/src/golang.org/x/sys/unix/errors_freebsd_arm.go Visa fil

@@ -0,0 +1,226 @@
1
+// Copyright 2017 The Go Authors. All rights reserved.
2
+// Use of this source code is governed by a BSD-style
3
+// license that can be found in the LICENSE file.
4
+
5
+package unix
6
+
7
+const (
8
+	IFT_1822                          = 0x2
9
+	IFT_A12MPPSWITCH                  = 0x82
10
+	IFT_AAL2                          = 0xbb
11
+	IFT_AAL5                          = 0x31
12
+	IFT_ADSL                          = 0x5e
13
+	IFT_AFLANE8023                    = 0x3b
14
+	IFT_AFLANE8025                    = 0x3c
15
+	IFT_ARAP                          = 0x58
16
+	IFT_ARCNET                        = 0x23
17
+	IFT_ARCNETPLUS                    = 0x24
18
+	IFT_ASYNC                         = 0x54
19
+	IFT_ATM                           = 0x25
20
+	IFT_ATMDXI                        = 0x69
21
+	IFT_ATMFUNI                       = 0x6a
22
+	IFT_ATMIMA                        = 0x6b
23
+	IFT_ATMLOGICAL                    = 0x50
24
+	IFT_ATMRADIO                      = 0xbd
25
+	IFT_ATMSUBINTERFACE               = 0x86
26
+	IFT_ATMVCIENDPT                   = 0xc2
27
+	IFT_ATMVIRTUAL                    = 0x95
28
+	IFT_BGPPOLICYACCOUNTING           = 0xa2
29
+	IFT_BSC                           = 0x53
30
+	IFT_CCTEMUL                       = 0x3d
31
+	IFT_CEPT                          = 0x13
32
+	IFT_CES                           = 0x85
33
+	IFT_CHANNEL                       = 0x46
34
+	IFT_CNR                           = 0x55
35
+	IFT_COFFEE                        = 0x84
36
+	IFT_COMPOSITELINK                 = 0x9b
37
+	IFT_DCN                           = 0x8d
38
+	IFT_DIGITALPOWERLINE              = 0x8a
39
+	IFT_DIGITALWRAPPEROVERHEADCHANNEL = 0xba
40
+	IFT_DLSW                          = 0x4a
41
+	IFT_DOCSCABLEDOWNSTREAM           = 0x80
42
+	IFT_DOCSCABLEMACLAYER             = 0x7f
43
+	IFT_DOCSCABLEUPSTREAM             = 0x81
44
+	IFT_DS0                           = 0x51
45
+	IFT_DS0BUNDLE                     = 0x52
46
+	IFT_DS1FDL                        = 0xaa
47
+	IFT_DS3                           = 0x1e
48
+	IFT_DTM                           = 0x8c
49
+	IFT_DVBASILN                      = 0xac
50
+	IFT_DVBASIOUT                     = 0xad
51
+	IFT_DVBRCCDOWNSTREAM              = 0x93
52
+	IFT_DVBRCCMACLAYER                = 0x92
53
+	IFT_DVBRCCUPSTREAM                = 0x94
54
+	IFT_ENC                           = 0xf4
55
+	IFT_EON                           = 0x19
56
+	IFT_EPLRS                         = 0x57
57
+	IFT_ESCON                         = 0x49
58
+	IFT_ETHER                         = 0x6
59
+	IFT_FAST                          = 0x7d
60
+	IFT_FASTETHER                     = 0x3e
61
+	IFT_FASTETHERFX                   = 0x45
62
+	IFT_FDDI                          = 0xf
63
+	IFT_FIBRECHANNEL                  = 0x38
64
+	IFT_FRAMERELAYINTERCONNECT        = 0x3a
65
+	IFT_FRAMERELAYMPI                 = 0x5c
66
+	IFT_FRDLCIENDPT                   = 0xc1
67
+	IFT_FRELAY                        = 0x20
68
+	IFT_FRELAYDCE                     = 0x2c
69
+	IFT_FRF16MFRBUNDLE                = 0xa3
70
+	IFT_FRFORWARD                     = 0x9e
71
+	IFT_G703AT2MB                     = 0x43
72
+	IFT_G703AT64K                     = 0x42
73
+	IFT_GIF                           = 0xf0
74
+	IFT_GIGABITETHERNET               = 0x75
75
+	IFT_GR303IDT                      = 0xb2
76
+	IFT_GR303RDT                      = 0xb1
77
+	IFT_H323GATEKEEPER                = 0xa4
78
+	IFT_H323PROXY                     = 0xa5
79
+	IFT_HDH1822                       = 0x3
80
+	IFT_HDLC                          = 0x76
81
+	IFT_HDSL2                         = 0xa8
82
+	IFT_HIPERLAN2                     = 0xb7
83
+	IFT_HIPPI                         = 0x2f
84
+	IFT_HIPPIINTERFACE                = 0x39
85
+	IFT_HOSTPAD                       = 0x5a
86
+	IFT_HSSI                          = 0x2e
87
+	IFT_HY                            = 0xe
88
+	IFT_IBM370PARCHAN                 = 0x48
89
+	IFT_IDSL                          = 0x9a
90
+	IFT_IEEE80211                     = 0x47
91
+	IFT_IEEE80212                     = 0x37
92
+	IFT_IEEE8023ADLAG                 = 0xa1
93
+	IFT_IFGSN                         = 0x91
94
+	IFT_IMT                           = 0xbe
95
+	IFT_INTERLEAVE                    = 0x7c
96
+	IFT_IP                            = 0x7e
97
+	IFT_IPFORWARD                     = 0x8e
98
+	IFT_IPOVERATM                     = 0x72
99
+	IFT_IPOVERCDLC                    = 0x6d
100
+	IFT_IPOVERCLAW                    = 0x6e
101
+	IFT_IPSWITCH                      = 0x4e
102
+	IFT_ISDN                          = 0x3f
103
+	IFT_ISDNBASIC                     = 0x14
104
+	IFT_ISDNPRIMARY                   = 0x15
105
+	IFT_ISDNS                         = 0x4b
106
+	IFT_ISDNU                         = 0x4c
107
+	IFT_ISO88022LLC                   = 0x29
108
+	IFT_ISO88023                      = 0x7
109
+	IFT_ISO88024                      = 0x8
110
+	IFT_ISO88025                      = 0x9
111
+	IFT_ISO88025CRFPINT               = 0x62
112
+	IFT_ISO88025DTR                   = 0x56
113
+	IFT_ISO88025FIBER                 = 0x73
114
+	IFT_ISO88026                      = 0xa
115
+	IFT_ISUP                          = 0xb3
116
+	IFT_L3IPXVLAN                     = 0x89
117
+	IFT_LAPB                          = 0x10
118
+	IFT_LAPD                          = 0x4d
119
+	IFT_LAPF                          = 0x77
120
+	IFT_LOCALTALK                     = 0x2a
121
+	IFT_LOOP                          = 0x18
122
+	IFT_MEDIAMAILOVERIP               = 0x8b
123
+	IFT_MFSIGLINK                     = 0xa7
124
+	IFT_MIOX25                        = 0x26
125
+	IFT_MODEM                         = 0x30
126
+	IFT_MPC                           = 0x71
127
+	IFT_MPLS                          = 0xa6
128
+	IFT_MPLSTUNNEL                    = 0x96
129
+	IFT_MSDSL                         = 0x8f
130
+	IFT_MVL                           = 0xbf
131
+	IFT_MYRINET                       = 0x63
132
+	IFT_NFAS                          = 0xaf
133
+	IFT_NSIP                          = 0x1b
134
+	IFT_OPTICALCHANNEL                = 0xc3
135
+	IFT_OPTICALTRANSPORT              = 0xc4
136
+	IFT_OTHER                         = 0x1
137
+	IFT_P10                           = 0xc
138
+	IFT_P80                           = 0xd
139
+	IFT_PARA                          = 0x22
140
+	IFT_PFLOG                         = 0xf6
141
+	IFT_PFSYNC                        = 0xf7
142
+	IFT_PLC                           = 0xae
143
+	IFT_POS                           = 0xab
144
+	IFT_PPPMULTILINKBUNDLE            = 0x6c
145
+	IFT_PROPBWAP2MP                   = 0xb8
146
+	IFT_PROPCNLS                      = 0x59
147
+	IFT_PROPDOCSWIRELESSDOWNSTREAM    = 0xb5
148
+	IFT_PROPDOCSWIRELESSMACLAYER      = 0xb4
149
+	IFT_PROPDOCSWIRELESSUPSTREAM      = 0xb6
150
+	IFT_PROPMUX                       = 0x36
151
+	IFT_PROPWIRELESSP2P               = 0x9d
152
+	IFT_PTPSERIAL                     = 0x16
153
+	IFT_PVC                           = 0xf1
154
+	IFT_QLLC                          = 0x44
155
+	IFT_RADIOMAC                      = 0xbc
156
+	IFT_RADSL                         = 0x5f
157
+	IFT_REACHDSL                      = 0xc0
158
+	IFT_RFC1483                       = 0x9f
159
+	IFT_RS232                         = 0x21
160
+	IFT_RSRB                          = 0x4f
161
+	IFT_SDLC                          = 0x11
162
+	IFT_SDSL                          = 0x60
163
+	IFT_SHDSL                         = 0xa9
164
+	IFT_SIP                           = 0x1f
165
+	IFT_SLIP                          = 0x1c
166
+	IFT_SMDSDXI                       = 0x2b
167
+	IFT_SMDSICIP                      = 0x34
168
+	IFT_SONET                         = 0x27
169
+	IFT_SONETOVERHEADCHANNEL          = 0xb9
170
+	IFT_SONETPATH                     = 0x32
171
+	IFT_SONETVT                       = 0x33
172
+	IFT_SRP                           = 0x97
173
+	IFT_SS7SIGLINK                    = 0x9c
174
+	IFT_STACKTOSTACK                  = 0x6f
175
+	IFT_STARLAN                       = 0xb
176
+	IFT_STF                           = 0xd7
177
+	IFT_T1                            = 0x12
178
+	IFT_TDLC                          = 0x74
179
+	IFT_TERMPAD                       = 0x5b
180
+	IFT_TR008                         = 0xb0
181
+	IFT_TRANSPHDLC                    = 0x7b
182
+	IFT_TUNNEL                        = 0x83
183
+	IFT_ULTRA                         = 0x1d
184
+	IFT_USB                           = 0xa0
185
+	IFT_V11                           = 0x40
186
+	IFT_V35                           = 0x2d
187
+	IFT_V36                           = 0x41
188
+	IFT_V37                           = 0x78
189
+	IFT_VDSL                          = 0x61
190
+	IFT_VIRTUALIPADDRESS              = 0x70
191
+	IFT_VOICEEM                       = 0x64
192
+	IFT_VOICEENCAP                    = 0x67
193
+	IFT_VOICEFXO                      = 0x65
194
+	IFT_VOICEFXS                      = 0x66
195
+	IFT_VOICEOVERATM                  = 0x98
196
+	IFT_VOICEOVERFRAMERELAY           = 0x99
197
+	IFT_VOICEOVERIP                   = 0x68
198
+	IFT_X213                          = 0x5d
199
+	IFT_X25                           = 0x5
200
+	IFT_X25DDN                        = 0x4
201
+	IFT_X25HUNTGROUP                  = 0x7a
202
+	IFT_X25MLP                        = 0x79
203
+	IFT_X25PLE                        = 0x28
204
+	IFT_XETHER                        = 0x1a
205
+
206
+	// missing constants on FreeBSD-11.1-RELEASE, copied from old values in ztypes_freebsd_arm.go
207
+	IFF_SMART       = 0x20
208
+	IFT_FAITH       = 0xf2
209
+	IFT_IPXIP       = 0xf9
210
+	IPPROTO_MAXID   = 0x34
211
+	IPV6_FAITH      = 0x1d
212
+	IP_FAITH        = 0x16
213
+	MAP_NORESERVE   = 0x40
214
+	MAP_RENAME      = 0x20
215
+	NET_RT_MAXID    = 0x6
216
+	RTF_PRCLONING   = 0x10000
217
+	RTM_OLDADD      = 0x9
218
+	RTM_OLDDEL      = 0xa
219
+	SIOCADDRT       = 0x8030720a
220
+	SIOCALIFADDR    = 0x8118691b
221
+	SIOCDELRT       = 0x8030720b
222
+	SIOCDLIFADDR    = 0x8118691d
223
+	SIOCGLIFADDR    = 0xc118691c
224
+	SIOCGLIFPHYADDR = 0xc118694b
225
+	SIOCSLIFPHYADDR = 0x8118694a
226
+)

+ 9
- 0
vendor/src/golang.org/x/sys/unix/export_test.go Visa fil

@@ -0,0 +1,9 @@
1
+// Copyright 2015 The Go Authors. All rights reserved.
2
+// Use of this source code is governed by a BSD-style
3
+// license that can be found in the LICENSE file.
4
+
5
+// +build darwin dragonfly freebsd linux netbsd openbsd solaris
6
+
7
+package unix
8
+
9
+var Itoa = itoa

+ 22
- 0
vendor/src/golang.org/x/sys/unix/flock.go Visa fil

@@ -0,0 +1,22 @@
1
+// Copyright 2014 The Go Authors. All rights reserved.
2
+// Use of this source code is governed by a BSD-style
3
+// license that can be found in the LICENSE file.
4
+
5
+// +build darwin dragonfly freebsd linux netbsd openbsd
6
+
7
+package unix
8
+
9
+import "unsafe"
10
+
11
+// fcntl64Syscall is usually SYS_FCNTL, but is overridden on 32-bit Linux
12
+// systems by flock_linux_32bit.go to be SYS_FCNTL64.
13
+var fcntl64Syscall uintptr = SYS_FCNTL
14
+
15
+// FcntlFlock performs a fcntl syscall for the F_GETLK, F_SETLK or F_SETLKW command.
16
+func FcntlFlock(fd uintptr, cmd int, lk *Flock_t) error {
17
+	_, _, errno := Syscall(fcntl64Syscall, fd, uintptr(cmd), uintptr(unsafe.Pointer(lk)))
18
+	if errno == 0 {
19
+		return nil
20
+	}
21
+	return errno
22
+}

+ 13
- 0
vendor/src/golang.org/x/sys/unix/flock_linux_32bit.go Visa fil

@@ -0,0 +1,13 @@
1
+// +build linux,386 linux,arm linux,mips linux,mipsle
2
+
3
+// Copyright 2014 The Go Authors. All rights reserved.
4
+// Use of this source code is governed by a BSD-style
5
+// license that can be found in the LICENSE file.
6
+
7
+package unix
8
+
9
+func init() {
10
+	// On 32-bit Linux systems, the fcntl syscall that matches Go's
11
+	// Flock_t type is SYS_FCNTL64, not SYS_FCNTL.
12
+	fcntl64Syscall = SYS_FCNTL64
13
+}

+ 46
- 0
vendor/src/golang.org/x/sys/unix/gccgo.go Visa fil

@@ -0,0 +1,46 @@
1
+// Copyright 2015 The Go Authors. All rights reserved.
2
+// Use of this source code is governed by a BSD-style
3
+// license that can be found in the LICENSE file.
4
+
5
+// +build gccgo
6
+
7
+package unix
8
+
9
+import "syscall"
10
+
11
+// We can't use the gc-syntax .s files for gccgo. On the plus side
12
+// much of the functionality can be written directly in Go.
13
+
14
+//extern gccgoRealSyscall
15
+func realSyscall(trap, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r, errno uintptr)
16
+
17
+func Syscall(trap, a1, a2, a3 uintptr) (r1, r2 uintptr, err syscall.Errno) {
18
+	syscall.Entersyscall()
19
+	r, errno := realSyscall(trap, a1, a2, a3, 0, 0, 0, 0, 0, 0)
20
+	syscall.Exitsyscall()
21
+	return r, 0, syscall.Errno(errno)
22
+}
23
+
24
+func Syscall6(trap, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err syscall.Errno) {
25
+	syscall.Entersyscall()
26
+	r, errno := realSyscall(trap, a1, a2, a3, a4, a5, a6, 0, 0, 0)
27
+	syscall.Exitsyscall()
28
+	return r, 0, syscall.Errno(errno)
29
+}
30
+
31
+func Syscall9(trap, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) {
32
+	syscall.Entersyscall()
33
+	r, errno := realSyscall(trap, a1, a2, a3, a4, a5, a6, a7, a8, a9)
34
+	syscall.Exitsyscall()
35
+	return r, 0, syscall.Errno(errno)
36
+}
37
+
38
+func RawSyscall(trap, a1, a2, a3 uintptr) (r1, r2 uintptr, err syscall.Errno) {
39
+	r, errno := realSyscall(trap, a1, a2, a3, 0, 0, 0, 0, 0, 0)
40
+	return r, 0, syscall.Errno(errno)
41
+}
42
+
43
+func RawSyscall6(trap, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err syscall.Errno) {
44
+	r, errno := realSyscall(trap, a1, a2, a3, a4, a5, a6, 0, 0, 0)
45
+	return r, 0, syscall.Errno(errno)
46
+}

+ 41
- 0
vendor/src/golang.org/x/sys/unix/gccgo_c.c Visa fil

@@ -0,0 +1,41 @@
1
+// Copyright 2015 The Go Authors. All rights reserved.
2
+// Use of this source code is governed by a BSD-style
3
+// license that can be found in the LICENSE file.
4
+
5
+// +build gccgo
6
+
7
+#include <errno.h>
8
+#include <stdint.h>
9
+#include <unistd.h>
10
+
11
+#define _STRINGIFY2_(x) #x
12
+#define _STRINGIFY_(x) _STRINGIFY2_(x)
13
+#define GOSYM_PREFIX _STRINGIFY_(__USER_LABEL_PREFIX__)
14
+
15
+// Call syscall from C code because the gccgo support for calling from
16
+// Go to C does not support varargs functions.
17
+
18
+struct ret {
19
+	uintptr_t r;
20
+	uintptr_t err;
21
+};
22
+
23
+struct ret
24
+gccgoRealSyscall(uintptr_t trap, uintptr_t a1, uintptr_t a2, uintptr_t a3, uintptr_t a4, uintptr_t a5, uintptr_t a6, uintptr_t a7, uintptr_t a8, uintptr_t a9)
25
+{
26
+	struct ret r;
27
+
28
+	errno = 0;
29
+	r.r = syscall(trap, a1, a2, a3, a4, a5, a6, a7, a8, a9);
30
+	r.err = errno;
31
+	return r;
32
+}
33
+
34
+// Define the use function in C so that it is not inlined.
35
+
36
+extern void use(void *) __asm__ (GOSYM_PREFIX GOPKGPATH ".use") __attribute__((noinline));
37
+
38
+void
39
+use(void *p __attribute__ ((unused)))
40
+{
41
+}

+ 20
- 0
vendor/src/golang.org/x/sys/unix/gccgo_linux_amd64.go Visa fil

@@ -0,0 +1,20 @@
1
+// Copyright 2015 The Go Authors. All rights reserved.
2
+// Use of this source code is governed by a BSD-style
3
+// license that can be found in the LICENSE file.
4
+
5
+// +build gccgo,linux,amd64
6
+
7
+package unix
8
+
9
+import "syscall"
10
+
11
+//extern gettimeofday
12
+func realGettimeofday(*Timeval, *byte) int32
13
+
14
+func gettimeofday(tv *Timeval) (err syscall.Errno) {
15
+	r := realGettimeofday(tv, nil)
16
+	if r < 0 {
17
+		return syscall.GetErrno()
18
+	}
19
+	return 0
20
+}

+ 51
- 0
vendor/src/golang.org/x/sys/unix/linux/Dockerfile Visa fil

@@ -0,0 +1,51 @@
1
+FROM ubuntu:16.04
2
+
3
+# Use the most recent ubuntu sources
4
+RUN echo 'deb http://en.archive.ubuntu.com/ubuntu/ artful main universe' >> /etc/apt/sources.list
5
+
6
+# Dependencies to get the git sources and go binaries
7
+RUN apt-get update && apt-get install -y \
8
+        curl \
9
+        git \
10
+    && rm -rf /var/lib/apt/lists/*
11
+
12
+# Get the git sources. If not cached, this takes O(5 minutes).
13
+WORKDIR /git
14
+RUN git config --global advice.detachedHead false
15
+# Linux Kernel: Released 03 Sep 2017
16
+RUN git clone --branch v4.13 --depth 1 https://kernel.googlesource.com/pub/scm/linux/kernel/git/torvalds/linux
17
+# GNU C library: Released 02 Aug 2017 (we should try to get a secure way to clone this)
18
+RUN git clone --branch glibc-2.26 --depth 1 git://sourceware.org/git/glibc.git
19
+
20
+# Get Go 1.9.2
21
+ENV GOLANG_VERSION 1.9.2
22
+ENV GOLANG_DOWNLOAD_URL https://golang.org/dl/go$GOLANG_VERSION.linux-amd64.tar.gz
23
+ENV GOLANG_DOWNLOAD_SHA256 de874549d9a8d8d8062be05808509c09a88a248e77ec14eb77453530829ac02b
24
+
25
+RUN curl -fsSL "$GOLANG_DOWNLOAD_URL" -o golang.tar.gz \
26
+    && echo "$GOLANG_DOWNLOAD_SHA256  golang.tar.gz" | sha256sum -c - \
27
+    && tar -C /usr/local -xzf golang.tar.gz \
28
+    && rm golang.tar.gz
29
+
30
+ENV PATH /usr/local/go/bin:$PATH
31
+
32
+# Linux and Glibc build dependencies
33
+RUN apt-get update && apt-get install -y \
34
+        gawk make python \
35
+        gcc gcc-multilib \
36
+        gettext texinfo \
37
+    && rm -rf /var/lib/apt/lists/*
38
+# Emulator and cross compilers
39
+RUN apt-get update && apt-get install -y \
40
+        qemu \
41
+        gcc-aarch64-linux-gnu       gcc-arm-linux-gnueabi     \
42
+        gcc-mips-linux-gnu          gcc-mips64-linux-gnuabi64 \
43
+        gcc-mips64el-linux-gnuabi64 gcc-mipsel-linux-gnu      \
44
+        gcc-powerpc64-linux-gnu     gcc-powerpc64le-linux-gnu \
45
+        gcc-s390x-linux-gnu         gcc-sparc64-linux-gnu     \
46
+    && rm -rf /var/lib/apt/lists/*
47
+
48
+# Let the scripts know they are in the docker environment
49
+ENV GOLANG_SYS_BUILD docker
50
+WORKDIR /build
51
+ENTRYPOINT ["go", "run", "linux/mkall.go", "/git/linux", "/git/glibc"]

+ 482
- 0
vendor/src/golang.org/x/sys/unix/linux/mkall.go Visa fil

@@ -0,0 +1,482 @@
1
+// Copyright 2017 The Go Authors. All rights reserved.
2
+// Use of this source code is governed by a BSD-style
3
+// license that can be found in the LICENSE file.
4
+
5
+// linux/mkall.go - Generates all Linux zsysnum, zsyscall, zerror, and ztype
6
+// files for all 11 linux architectures supported by the go compiler. See
7
+// README.md for more information about the build system.
8
+
9
+// To run it you must have a git checkout of the Linux kernel and glibc. Once
10
+// the appropriate sources are ready, the program is run as:
11
+//     go run linux/mkall.go <linux_dir> <glibc_dir>
12
+
13
+// +build ignore
14
+
15
+package main
16
+
17
+import (
18
+	"bufio"
19
+	"bytes"
20
+	"fmt"
21
+	"io"
22
+	"io/ioutil"
23
+	"os"
24
+	"os/exec"
25
+	"path/filepath"
26
+	"runtime"
27
+	"strings"
28
+	"unicode"
29
+)
30
+
31
+// These will be paths to the appropriate source directories.
32
+var LinuxDir string
33
+var GlibcDir string
34
+
35
+const TempDir = "/tmp"
36
+const IncludeDir = TempDir + "/include" // To hold our C headers
37
+const BuildDir = TempDir + "/build"     // To hold intermediate build files
38
+
39
+const GOOS = "linux"       // Only for Linux targets
40
+const BuildArch = "amd64"  // Must be built on this architecture
41
+const MinKernel = "2.6.23" // https://golang.org/doc/install#requirements
42
+
43
+type target struct {
44
+	GoArch     string // Architecture name according to Go
45
+	LinuxArch  string // Architecture name according to the Linux Kernel
46
+	GNUArch    string // Architecture name according to GNU tools (https://wiki.debian.org/Multiarch/Tuples)
47
+	BigEndian  bool   // Default Little Endian
48
+	SignedChar bool   // Is -fsigned-char needed (default no)
49
+	Bits       int
50
+}
51
+
52
+// List of the 11 Linux targets supported by the go compiler. sparc64 is not
53
+// currently supported, though a port is in progress.
54
+var targets = []target{
55
+	{
56
+		GoArch:    "386",
57
+		LinuxArch: "x86",
58
+		GNUArch:   "i686-linux-gnu", // Note "i686" not "i386"
59
+		Bits:      32,
60
+	},
61
+	{
62
+		GoArch:    "amd64",
63
+		LinuxArch: "x86",
64
+		GNUArch:   "x86_64-linux-gnu",
65
+		Bits:      64,
66
+	},
67
+	{
68
+		GoArch:     "arm64",
69
+		LinuxArch:  "arm64",
70
+		GNUArch:    "aarch64-linux-gnu",
71
+		SignedChar: true,
72
+		Bits:       64,
73
+	},
74
+	{
75
+		GoArch:    "arm",
76
+		LinuxArch: "arm",
77
+		GNUArch:   "arm-linux-gnueabi",
78
+		Bits:      32,
79
+	},
80
+	{
81
+		GoArch:    "mips",
82
+		LinuxArch: "mips",
83
+		GNUArch:   "mips-linux-gnu",
84
+		BigEndian: true,
85
+		Bits:      32,
86
+	},
87
+	{
88
+		GoArch:    "mipsle",
89
+		LinuxArch: "mips",
90
+		GNUArch:   "mipsel-linux-gnu",
91
+		Bits:      32,
92
+	},
93
+	{
94
+		GoArch:    "mips64",
95
+		LinuxArch: "mips",
96
+		GNUArch:   "mips64-linux-gnuabi64",
97
+		BigEndian: true,
98
+		Bits:      64,
99
+	},
100
+	{
101
+		GoArch:    "mips64le",
102
+		LinuxArch: "mips",
103
+		GNUArch:   "mips64el-linux-gnuabi64",
104
+		Bits:      64,
105
+	},
106
+	{
107
+		GoArch:    "ppc64",
108
+		LinuxArch: "powerpc",
109
+		GNUArch:   "powerpc64-linux-gnu",
110
+		BigEndian: true,
111
+		Bits:      64,
112
+	},
113
+	{
114
+		GoArch:    "ppc64le",
115
+		LinuxArch: "powerpc",
116
+		GNUArch:   "powerpc64le-linux-gnu",
117
+		Bits:      64,
118
+	},
119
+	{
120
+		GoArch:     "s390x",
121
+		LinuxArch:  "s390",
122
+		GNUArch:    "s390x-linux-gnu",
123
+		BigEndian:  true,
124
+		SignedChar: true,
125
+		Bits:       64,
126
+	},
127
+	// {
128
+	// 	GoArch:    "sparc64",
129
+	// 	LinuxArch: "sparc",
130
+	// 	GNUArch:   "sparc64-linux-gnu",
131
+	// 	BigEndian: true,
132
+	// 	Bits:      64,
133
+	// },
134
+}
135
+
136
+// ptracePairs is a list of pairs of targets that can, in some cases,
137
+// run each other's binaries.
138
+var ptracePairs = []struct{ a1, a2 string }{
139
+	{"386", "amd64"},
140
+	{"arm", "arm64"},
141
+	{"mips", "mips64"},
142
+	{"mipsle", "mips64le"},
143
+}
144
+
145
+func main() {
146
+	if runtime.GOOS != GOOS || runtime.GOARCH != BuildArch {
147
+		fmt.Printf("Build system has GOOS_GOARCH = %s_%s, need %s_%s\n",
148
+			runtime.GOOS, runtime.GOARCH, GOOS, BuildArch)
149
+		return
150
+	}
151
+
152
+	// Check that we are using the new build system if we should
153
+	if os.Getenv("GOLANG_SYS_BUILD") != "docker" {
154
+		fmt.Println("In the new build system, mkall.go should not be called directly.")
155
+		fmt.Println("See README.md")
156
+		return
157
+	}
158
+
159
+	// Parse the command line options
160
+	if len(os.Args) != 3 {
161
+		fmt.Println("USAGE: go run linux/mkall.go <linux_dir> <glibc_dir>")
162
+		return
163
+	}
164
+	LinuxDir = os.Args[1]
165
+	GlibcDir = os.Args[2]
166
+
167
+	for _, t := range targets {
168
+		fmt.Printf("----- GENERATING: %s -----\n", t.GoArch)
169
+		if err := t.generateFiles(); err != nil {
170
+			fmt.Printf("%v\n***** FAILURE:    %s *****\n\n", err, t.GoArch)
171
+		} else {
172
+			fmt.Printf("----- SUCCESS:    %s -----\n\n", t.GoArch)
173
+		}
174
+	}
175
+
176
+	fmt.Printf("----- GENERATING ptrace pairs -----\n")
177
+	ok := true
178
+	for _, p := range ptracePairs {
179
+		if err := generatePtracePair(p.a1, p.a2); err != nil {
180
+			fmt.Printf("%v\n***** FAILURE: %s/%s *****\n\n", err, p.a1, p.a2)
181
+			ok = false
182
+		}
183
+	}
184
+	if ok {
185
+		fmt.Printf("----- SUCCESS ptrace pairs    -----\n\n")
186
+	}
187
+}
188
+
189
+// Makes an exec.Cmd with Stderr attached to os.Stderr
190
+func makeCommand(name string, args ...string) *exec.Cmd {
191
+	cmd := exec.Command(name, args...)
192
+	cmd.Stderr = os.Stderr
193
+	return cmd
194
+}
195
+
196
+// Runs the command, pipes output to a formatter, pipes that to an output file.
197
+func (t *target) commandFormatOutput(formatter string, outputFile string,
198
+	name string, args ...string) (err error) {
199
+	mainCmd := makeCommand(name, args...)
200
+
201
+	fmtCmd := makeCommand(formatter)
202
+	if formatter == "mkpost" {
203
+		fmtCmd = makeCommand("go", "run", "mkpost.go")
204
+		// Set GOARCH_TARGET so mkpost knows what GOARCH is..
205
+		fmtCmd.Env = append(os.Environ(), "GOARCH_TARGET="+t.GoArch)
206
+		// Set GOARCH to host arch for mkpost, so it can run natively.
207
+		for i, s := range fmtCmd.Env {
208
+			if strings.HasPrefix(s, "GOARCH=") {
209
+				fmtCmd.Env[i] = "GOARCH=" + BuildArch
210
+			}
211
+		}
212
+	}
213
+
214
+	// mainCmd | fmtCmd > outputFile
215
+	if fmtCmd.Stdin, err = mainCmd.StdoutPipe(); err != nil {
216
+		return
217
+	}
218
+	if fmtCmd.Stdout, err = os.Create(outputFile); err != nil {
219
+		return
220
+	}
221
+
222
+	// Make sure the formatter eventually closes
223
+	if err = fmtCmd.Start(); err != nil {
224
+		return
225
+	}
226
+	defer func() {
227
+		fmtErr := fmtCmd.Wait()
228
+		if err == nil {
229
+			err = fmtErr
230
+		}
231
+	}()
232
+
233
+	return mainCmd.Run()
234
+}
235
+
236
+// Generates all the files for a Linux target
237
+func (t *target) generateFiles() error {
238
+	// Setup environment variables
239
+	os.Setenv("GOOS", GOOS)
240
+	os.Setenv("GOARCH", t.GoArch)
241
+
242
+	// Get appropriate compiler and emulator (unless on x86)
243
+	if t.LinuxArch != "x86" {
244
+		// Check/Setup cross compiler
245
+		compiler := t.GNUArch + "-gcc"
246
+		if _, err := exec.LookPath(compiler); err != nil {
247
+			return err
248
+		}
249
+		os.Setenv("CC", compiler)
250
+
251
+		// Check/Setup emulator (usually first component of GNUArch)
252
+		qemuArchName := t.GNUArch[:strings.Index(t.GNUArch, "-")]
253
+		if t.LinuxArch == "powerpc" {
254
+			qemuArchName = t.GoArch
255
+		}
256
+		os.Setenv("GORUN", "qemu-"+qemuArchName)
257
+	} else {
258
+		os.Setenv("CC", "gcc")
259
+	}
260
+
261
+	// Make the include directory and fill it with headers
262
+	if err := os.MkdirAll(IncludeDir, os.ModePerm); err != nil {
263
+		return err
264
+	}
265
+	defer os.RemoveAll(IncludeDir)
266
+	if err := t.makeHeaders(); err != nil {
267
+		return fmt.Errorf("could not make header files: %v", err)
268
+	}
269
+	fmt.Println("header files generated")
270
+
271
+	// Make each of the four files
272
+	if err := t.makeZSysnumFile(); err != nil {
273
+		return fmt.Errorf("could not make zsysnum file: %v", err)
274
+	}
275
+	fmt.Println("zsysnum file generated")
276
+
277
+	if err := t.makeZSyscallFile(); err != nil {
278
+		return fmt.Errorf("could not make zsyscall file: %v", err)
279
+	}
280
+	fmt.Println("zsyscall file generated")
281
+
282
+	if err := t.makeZTypesFile(); err != nil {
283
+		return fmt.Errorf("could not make ztypes file: %v", err)
284
+	}
285
+	fmt.Println("ztypes file generated")
286
+
287
+	if err := t.makeZErrorsFile(); err != nil {
288
+		return fmt.Errorf("could not make zerrors file: %v", err)
289
+	}
290
+	fmt.Println("zerrors file generated")
291
+
292
+	return nil
293
+}
294
+
295
+// Create the Linux and glibc headers in the include directory.
296
+func (t *target) makeHeaders() error {
297
+	// Make the Linux headers we need for this architecture
298
+	linuxMake := makeCommand("make", "headers_install", "ARCH="+t.LinuxArch, "INSTALL_HDR_PATH="+TempDir)
299
+	linuxMake.Dir = LinuxDir
300
+	if err := linuxMake.Run(); err != nil {
301
+		return err
302
+	}
303
+
304
+	// A Temporary build directory for glibc
305
+	if err := os.MkdirAll(BuildDir, os.ModePerm); err != nil {
306
+		return err
307
+	}
308
+	defer os.RemoveAll(BuildDir)
309
+
310
+	// Make the glibc headers we need for this architecture
311
+	confScript := filepath.Join(GlibcDir, "configure")
312
+	glibcConf := makeCommand(confScript, "--prefix="+TempDir, "--host="+t.GNUArch, "--enable-kernel="+MinKernel)
313
+	glibcConf.Dir = BuildDir
314
+	if err := glibcConf.Run(); err != nil {
315
+		return err
316
+	}
317
+	glibcMake := makeCommand("make", "install-headers")
318
+	glibcMake.Dir = BuildDir
319
+	if err := glibcMake.Run(); err != nil {
320
+		return err
321
+	}
322
+	// We only need an empty stubs file
323
+	stubsFile := filepath.Join(IncludeDir, "gnu/stubs.h")
324
+	if file, err := os.Create(stubsFile); err != nil {
325
+		return err
326
+	} else {
327
+		file.Close()
328
+	}
329
+
330
+	return nil
331
+}
332
+
333
+// makes the zsysnum_linux_$GOARCH.go file
334
+func (t *target) makeZSysnumFile() error {
335
+	zsysnumFile := fmt.Sprintf("zsysnum_linux_%s.go", t.GoArch)
336
+	unistdFile := filepath.Join(IncludeDir, "asm/unistd.h")
337
+
338
+	args := append(t.cFlags(), unistdFile)
339
+	return t.commandFormatOutput("gofmt", zsysnumFile, "linux/mksysnum.pl", args...)
340
+}
341
+
342
+// makes the zsyscall_linux_$GOARCH.go file
343
+func (t *target) makeZSyscallFile() error {
344
+	zsyscallFile := fmt.Sprintf("zsyscall_linux_%s.go", t.GoArch)
345
+	// Find the correct architecture syscall file (might end with x.go)
346
+	archSyscallFile := fmt.Sprintf("syscall_linux_%s.go", t.GoArch)
347
+	if _, err := os.Stat(archSyscallFile); os.IsNotExist(err) {
348
+		shortArch := strings.TrimSuffix(t.GoArch, "le")
349
+		archSyscallFile = fmt.Sprintf("syscall_linux_%sx.go", shortArch)
350
+	}
351
+
352
+	args := append(t.mksyscallFlags(), "-tags", "linux,"+t.GoArch,
353
+		"syscall_linux.go", archSyscallFile)
354
+	return t.commandFormatOutput("gofmt", zsyscallFile, "./mksyscall.pl", args...)
355
+}
356
+
357
+// makes the zerrors_linux_$GOARCH.go file
358
+func (t *target) makeZErrorsFile() error {
359
+	zerrorsFile := fmt.Sprintf("zerrors_linux_%s.go", t.GoArch)
360
+
361
+	return t.commandFormatOutput("gofmt", zerrorsFile, "./mkerrors.sh", t.cFlags()...)
362
+}
363
+
364
+// makes the ztypes_linux_$GOARCH.go file
365
+func (t *target) makeZTypesFile() error {
366
+	ztypesFile := fmt.Sprintf("ztypes_linux_%s.go", t.GoArch)
367
+
368
+	args := []string{"tool", "cgo", "-godefs", "--"}
369
+	args = append(args, t.cFlags()...)
370
+	args = append(args, "linux/types.go")
371
+	return t.commandFormatOutput("mkpost", ztypesFile, "go", args...)
372
+}
373
+
374
+// Flags that should be given to gcc and cgo for this target
375
+func (t *target) cFlags() []string {
376
+	// Compile statically to avoid cross-architecture dynamic linking.
377
+	flags := []string{"-Wall", "-Werror", "-static", "-I" + IncludeDir}
378
+
379
+	// Architecture-specific flags
380
+	if t.SignedChar {
381
+		flags = append(flags, "-fsigned-char")
382
+	}
383
+	if t.LinuxArch == "x86" {
384
+		flags = append(flags, fmt.Sprintf("-m%d", t.Bits))
385
+	}
386
+
387
+	return flags
388
+}
389
+
390
+// Flags that should be given to mksyscall for this target
391
+func (t *target) mksyscallFlags() (flags []string) {
392
+	if t.Bits == 32 {
393
+		if t.BigEndian {
394
+			flags = append(flags, "-b32")
395
+		} else {
396
+			flags = append(flags, "-l32")
397
+		}
398
+	}
399
+
400
+	// This flag menas a 64-bit value should use (even, odd)-pair.
401
+	if t.GoArch == "arm" || (t.LinuxArch == "mips" && t.Bits == 32) {
402
+		flags = append(flags, "-arm")
403
+	}
404
+	return
405
+}
406
+
407
+// generatePtracePair takes a pair of GOARCH values that can run each
408
+// other's binaries, such as 386 and amd64. It extracts the PtraceRegs
409
+// type for each one. It writes a new file defining the types
410
+// PtraceRegsArch1 and PtraceRegsArch2 and the corresponding functions
411
+// Ptrace{Get,Set}Regs{arch1,arch2}. This permits debugging the other
412
+// binary on a native system.
413
+func generatePtracePair(arch1, arch2 string) error {
414
+	def1, err := ptraceDef(arch1)
415
+	if err != nil {
416
+		return err
417
+	}
418
+	def2, err := ptraceDef(arch2)
419
+	if err != nil {
420
+		return err
421
+	}
422
+	f, err := os.Create(fmt.Sprintf("zptrace%s_linux.go", arch1))
423
+	if err != nil {
424
+		return err
425
+	}
426
+	buf := bufio.NewWriter(f)
427
+	fmt.Fprintf(buf, "// Code generated by linux/mkall.go generatePtracePair(%s, %s). DO NOT EDIT.\n", arch1, arch2)
428
+	fmt.Fprintf(buf, "\n")
429
+	fmt.Fprintf(buf, "// +build linux\n")
430
+	fmt.Fprintf(buf, "// +build %s %s\n", arch1, arch2)
431
+	fmt.Fprintf(buf, "\n")
432
+	fmt.Fprintf(buf, "package unix\n")
433
+	fmt.Fprintf(buf, "\n")
434
+	fmt.Fprintf(buf, "%s\n", `import "unsafe"`)
435
+	fmt.Fprintf(buf, "\n")
436
+	writeOnePtrace(buf, arch1, def1)
437
+	fmt.Fprintf(buf, "\n")
438
+	writeOnePtrace(buf, arch2, def2)
439
+	if err := buf.Flush(); err != nil {
440
+		return err
441
+	}
442
+	if err := f.Close(); err != nil {
443
+		return err
444
+	}
445
+	return nil
446
+}
447
+
448
+// ptraceDef returns the definition of PtraceRegs for arch.
449
+func ptraceDef(arch string) (string, error) {
450
+	filename := fmt.Sprintf("ztypes_linux_%s.go", arch)
451
+	data, err := ioutil.ReadFile(filename)
452
+	if err != nil {
453
+		return "", fmt.Errorf("reading %s: %v", filename, err)
454
+	}
455
+	start := bytes.Index(data, []byte("type PtraceRegs struct"))
456
+	if start < 0 {
457
+		return "", fmt.Errorf("%s: no definition of PtraceRegs", filename)
458
+	}
459
+	data = data[start:]
460
+	end := bytes.Index(data, []byte("\n}\n"))
461
+	if end < 0 {
462
+		return "", fmt.Errorf("%s: can't find end of PtraceRegs definition", filename)
463
+	}
464
+	return string(data[:end+2]), nil
465
+}
466
+
467
+// writeOnePtrace writes out the ptrace definitions for arch.
468
+func writeOnePtrace(w io.Writer, arch, def string) {
469
+	uarch := string(unicode.ToUpper(rune(arch[0]))) + arch[1:]
470
+	fmt.Fprintf(w, "// PtraceRegs%s is the registers used by %s binaries.\n", uarch, arch)
471
+	fmt.Fprintf(w, "%s\n", strings.Replace(def, "PtraceRegs", "PtraceRegs"+uarch, 1))
472
+	fmt.Fprintf(w, "\n")
473
+	fmt.Fprintf(w, "// PtraceGetRegs%s fetches the registers used by %s binaries.\n", uarch, arch)
474
+	fmt.Fprintf(w, "func PtraceGetRegs%s(pid int, regsout *PtraceRegs%s) error {\n", uarch, uarch)
475
+	fmt.Fprintf(w, "\treturn ptrace(PTRACE_GETREGS, pid, 0, uintptr(unsafe.Pointer(regsout)))\n")
476
+	fmt.Fprintf(w, "}\n")
477
+	fmt.Fprintf(w, "\n")
478
+	fmt.Fprintf(w, "// PtraceSetRegs%s sets the registers used by %s binaries.\n", uarch, arch)
479
+	fmt.Fprintf(w, "func PtraceSetRegs%s(pid int, regs *PtraceRegs%s) error {\n", uarch, uarch)
480
+	fmt.Fprintf(w, "\treturn ptrace(PTRACE_SETREGS, pid, 0, uintptr(unsafe.Pointer(regs)))\n")
481
+	fmt.Fprintf(w, "}\n")
482
+}

+ 0
- 0
vendor/src/golang.org/x/sys/unix/linux/mksysnum.pl Visa fil


Vissa filer visades inte eftersom för många filer har ändrats