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

61
tools/vendor/github.com/tmthrgd/go-bindata/name.go generated vendored Normal file
View File

@@ -0,0 +1,61 @@
// 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 (
"encoding/base64"
"encoding/hex"
"path"
"strings"
)
// Name applies name hashing if required. It returns the original
// name for NoHash and NameUnchanged and returns the mangledName
// otherwise.
func (asset *binAsset) Name() string {
if asset.Hash == nil || asset.opts.HashFormat == NameUnchanged {
return asset.File.Name()
} else if asset.mangledName != "" {
return asset.mangledName
}
var enc string
switch asset.opts.HashEncoding {
case HexHash:
enc = hex.EncodeToString(asset.Hash)
case Base32Hash:
enc = base32Enc.EncodeToString(asset.Hash)
case Base64Hash:
enc = base64.RawURLEncoding.EncodeToString(asset.Hash)
default:
panic("unreachable")
}
l := asset.opts.HashLength
if l == 0 {
l = 16
}
if l < uint(len(enc)) {
enc = enc[:l]
}
dir, file := path.Split(asset.File.Name())
ext := path.Ext(file)
switch asset.opts.HashFormat {
case DirHash:
asset.mangledName = path.Join(dir, enc, file)
case NameHashSuffix:
file = strings.TrimSuffix(file, ext)
asset.mangledName = path.Join(dir, file+"-"+enc+ext)
case HashWithExt:
asset.mangledName = path.Join(dir, enc+ext)
default:
panic("unreachable")
}
return asset.mangledName
}