1
0
mirror of https://github.com/prometheus-community/postgres_exporter.git synced 2025-08-08 04:42:07 +03:00

Refactor repository layout and convert build system to Mage.

This commit implements a massive refactor of the repository, and
moves the build system over to use Mage (magefile.org) which should
allow seamless building across multiple platforms.
This commit is contained in:
Will Rouesnel
2018-02-23 01:55:49 +11:00
parent 3e6cf08dc5
commit 989489096e
269 changed files with 35309 additions and 2017 deletions

View File

@@ -0,0 +1,71 @@
// Copyright 2017 Tom Thorogood. All rights reserved.
// Use of this source code is governed by a Modified
// BSD License that can be found in the LICENSE file.
package bindata
import "io"
var (
stringWriterLinePrefix = []byte(`"`)
stringWriterLineSuffix = []byte("\" +\n")
stringWriterParensLineSuffix = []byte("\") + (\"\" +\n")
)
type stringWriter struct {
io.Writer
Indent string
WrapAt int
c, l int
}
func (w *stringWriter) Write(p []byte) (n int, err error) {
buf := [4]byte{'\\', 'x', 0, 0}
for _, b := range p {
const lowerHex = "0123456789abcdef"
buf[2] = lowerHex[b/16]
buf[3] = lowerHex[b%16]
if _, err = w.Writer.Write(buf[:]); err != nil {
return
}
n++
w.c++
if w.WrapAt == 0 || w.c%w.WrapAt != 0 {
continue
}
w.l++
suffix := stringWriterLineSuffix
if w.l%500 == 0 {
// As per https://golang.org/issue/18078, the compiler has trouble
// compiling the concatenation of many strings, s0 + s1 + s2 + ... + sN,
// for large N. We insert redundant, explicit parentheses to work around
// that, lowering the N at any given step: (s0 + s1 + ... + s499) + (s500 +
// ... + s1999) + etc + (etc + ... + sN).
//
// This fix was taken from the fix applied to x/text in
// https://github.com/golang/text/commit/5c6cf4f9a2.
suffix = stringWriterParensLineSuffix
}
if _, err = w.Writer.Write(suffix); err != nil {
return
}
if _, err = io.WriteString(w.Writer, w.Indent); err != nil {
return
}
if _, err = w.Writer.Write(stringWriterLinePrefix); err != nil {
return
}
}
return
}