Use mod vendor for vendored directory (backwards compatible)
This commit is contained in:
27
vendor/gopkg.in/airbrake/gobrake.v2/LICENSE
generated
vendored
27
vendor/gopkg.in/airbrake/gobrake.v2/LICENSE
generated
vendored
@@ -1,27 +0,0 @@
|
||||
Copyright (c) 2014 The Gobrake Authors. All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are
|
||||
met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above
|
||||
copyright notice, this list of conditions and the following disclaimer
|
||||
in the documentation and/or other materials provided with the
|
||||
distribution.
|
||||
* Neither the name of Google Inc. nor the names of its
|
||||
contributors may be used to endorse or promote products derived from
|
||||
this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
16
vendor/gopkg.in/airbrake/gobrake.v2/gobrake.go
generated
vendored
16
vendor/gopkg.in/airbrake/gobrake.v2/gobrake.go
generated
vendored
@@ -1,16 +0,0 @@
|
||||
package gobrake
|
||||
|
||||
import (
|
||||
"log"
|
||||
"os"
|
||||
)
|
||||
|
||||
var logger *log.Logger
|
||||
|
||||
func init() {
|
||||
SetLogger(log.New(os.Stderr, "gobrake: ", log.LstdFlags))
|
||||
}
|
||||
|
||||
func SetLogger(l *log.Logger) {
|
||||
logger = l
|
||||
}
|
||||
105
vendor/gopkg.in/airbrake/gobrake.v2/notice.go
generated
vendored
105
vendor/gopkg.in/airbrake/gobrake.v2/notice.go
generated
vendored
@@ -1,105 +0,0 @@
|
||||
package gobrake
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net/http"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"runtime"
|
||||
)
|
||||
|
||||
var defaultContext map[string]interface{}
|
||||
|
||||
func getDefaultContext() map[string]interface{} {
|
||||
if defaultContext != nil {
|
||||
return defaultContext
|
||||
}
|
||||
|
||||
defaultContext = map[string]interface{}{
|
||||
"notifier": map[string]interface{}{
|
||||
"name": "gobrake",
|
||||
"version": "2.0.4",
|
||||
"url": "https://github.com/airbrake/gobrake",
|
||||
},
|
||||
|
||||
"language": runtime.Version(),
|
||||
"os": runtime.GOOS,
|
||||
"architecture": runtime.GOARCH,
|
||||
}
|
||||
if s, err := os.Hostname(); err == nil {
|
||||
defaultContext["hostname"] = s
|
||||
}
|
||||
if s := os.Getenv("GOPATH"); s != "" {
|
||||
list := filepath.SplitList(s)
|
||||
// TODO: multiple root dirs?
|
||||
defaultContext["rootDirectory"] = list[0]
|
||||
}
|
||||
return defaultContext
|
||||
}
|
||||
|
||||
type Error struct {
|
||||
Type string `json:"type"`
|
||||
Message string `json:"message"`
|
||||
Backtrace []StackFrame `json:"backtrace"`
|
||||
}
|
||||
|
||||
type Notice struct {
|
||||
Errors []Error `json:"errors"`
|
||||
Context map[string]interface{} `json:"context"`
|
||||
Env map[string]interface{} `json:"environment"`
|
||||
Session map[string]interface{} `json:"session"`
|
||||
Params map[string]interface{} `json:"params"`
|
||||
}
|
||||
|
||||
func (n *Notice) String() string {
|
||||
if len(n.Errors) == 0 {
|
||||
return "Notice<no errors>"
|
||||
}
|
||||
e := n.Errors[0]
|
||||
return fmt.Sprintf("Notice<%s: %s>", e.Type, e.Message)
|
||||
}
|
||||
|
||||
func NewNotice(e interface{}, req *http.Request, depth int) *Notice {
|
||||
notice := &Notice{
|
||||
Errors: []Error{{
|
||||
Type: fmt.Sprintf("%T", e),
|
||||
Message: fmt.Sprint(e),
|
||||
Backtrace: stack(depth),
|
||||
}},
|
||||
Context: map[string]interface{}{},
|
||||
Env: map[string]interface{}{},
|
||||
Session: map[string]interface{}{},
|
||||
Params: map[string]interface{}{},
|
||||
}
|
||||
|
||||
for k, v := range getDefaultContext() {
|
||||
notice.Context[k] = v
|
||||
}
|
||||
|
||||
if req != nil {
|
||||
notice.Context["url"] = req.URL.String()
|
||||
if ua := req.Header.Get("User-Agent"); ua != "" {
|
||||
notice.Context["userAgent"] = ua
|
||||
}
|
||||
|
||||
for k, v := range req.Header {
|
||||
if len(v) == 1 {
|
||||
notice.Env[k] = v[0]
|
||||
} else {
|
||||
notice.Env[k] = v
|
||||
}
|
||||
}
|
||||
|
||||
if err := req.ParseForm(); err == nil {
|
||||
for k, v := range req.Form {
|
||||
if len(v) == 1 {
|
||||
notice.Params[k] = v[0]
|
||||
} else {
|
||||
notice.Params[k] = v
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return notice
|
||||
}
|
||||
280
vendor/gopkg.in/airbrake/gobrake.v2/notifier.go
generated
vendored
280
vendor/gopkg.in/airbrake/gobrake.v2/notifier.go
generated
vendored
@@ -1,280 +0,0 @@
|
||||
package gobrake // import "gopkg.in/airbrake/gobrake.v2"
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"crypto/tls"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"net"
|
||||
"net/http"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"sync"
|
||||
"time"
|
||||
)
|
||||
|
||||
const defaultAirbrakeHost = "https://airbrake.io"
|
||||
const waitTimeout = 5 * time.Second
|
||||
const httpStatusTooManyRequests = 429
|
||||
|
||||
var (
|
||||
errClosed = errors.New("gobrake: notifier is closed")
|
||||
errRateLimited = errors.New("gobrake: rate limited")
|
||||
)
|
||||
|
||||
var httpClient = &http.Client{
|
||||
Transport: &http.Transport{
|
||||
Proxy: http.ProxyFromEnvironment,
|
||||
Dial: (&net.Dialer{
|
||||
Timeout: 15 * time.Second,
|
||||
KeepAlive: 30 * time.Second,
|
||||
}).Dial,
|
||||
TLSHandshakeTimeout: 10 * time.Second,
|
||||
TLSClientConfig: &tls.Config{
|
||||
ClientSessionCache: tls.NewLRUClientSessionCache(1024),
|
||||
},
|
||||
MaxIdleConnsPerHost: 10,
|
||||
ResponseHeaderTimeout: 10 * time.Second,
|
||||
},
|
||||
Timeout: 10 * time.Second,
|
||||
}
|
||||
|
||||
var buffers = sync.Pool{
|
||||
New: func() interface{} {
|
||||
return new(bytes.Buffer)
|
||||
},
|
||||
}
|
||||
|
||||
type filter func(*Notice) *Notice
|
||||
|
||||
type Notifier struct {
|
||||
// http.Client that is used to interact with Airbrake API.
|
||||
Client *http.Client
|
||||
|
||||
projectId int64
|
||||
projectKey string
|
||||
createNoticeURL string
|
||||
|
||||
filters []filter
|
||||
|
||||
wg sync.WaitGroup
|
||||
noticeCh chan *Notice
|
||||
closed chan struct{}
|
||||
}
|
||||
|
||||
func NewNotifier(projectId int64, projectKey string) *Notifier {
|
||||
n := &Notifier{
|
||||
Client: httpClient,
|
||||
|
||||
projectId: projectId,
|
||||
projectKey: projectKey,
|
||||
createNoticeURL: getCreateNoticeURL(defaultAirbrakeHost, projectId, projectKey),
|
||||
|
||||
filters: []filter{noticeBacktraceFilter},
|
||||
|
||||
noticeCh: make(chan *Notice, 1000),
|
||||
closed: make(chan struct{}),
|
||||
}
|
||||
for i := 0; i < 10; i++ {
|
||||
go n.worker()
|
||||
}
|
||||
return n
|
||||
}
|
||||
|
||||
// Sets Airbrake host name. Default is https://airbrake.io.
|
||||
func (n *Notifier) SetHost(h string) {
|
||||
n.createNoticeURL = getCreateNoticeURL(h, n.projectId, n.projectKey)
|
||||
}
|
||||
|
||||
// AddFilter adds filter that can modify or ignore notice.
|
||||
func (n *Notifier) AddFilter(fn filter) {
|
||||
n.filters = append(n.filters, fn)
|
||||
}
|
||||
|
||||
// Notify notifies Airbrake about the error.
|
||||
func (n *Notifier) Notify(e interface{}, req *http.Request) {
|
||||
notice := n.Notice(e, req, 1)
|
||||
n.SendNoticeAsync(notice)
|
||||
}
|
||||
|
||||
// Notice returns Aibrake notice created from error and request. depth
|
||||
// determines which call frame to use when constructing backtrace.
|
||||
func (n *Notifier) Notice(err interface{}, req *http.Request, depth int) *Notice {
|
||||
return NewNotice(err, req, depth+3)
|
||||
}
|
||||
|
||||
type sendResponse struct {
|
||||
Id string `json:"id"`
|
||||
}
|
||||
|
||||
// SendNotice sends notice to Airbrake.
|
||||
func (n *Notifier) SendNotice(notice *Notice) (string, error) {
|
||||
for _, fn := range n.filters {
|
||||
notice = fn(notice)
|
||||
if notice == nil {
|
||||
// Notice is ignored.
|
||||
return "", nil
|
||||
}
|
||||
}
|
||||
|
||||
buf := buffers.Get().(*bytes.Buffer)
|
||||
defer buffers.Put(buf)
|
||||
|
||||
buf.Reset()
|
||||
if err := json.NewEncoder(buf).Encode(notice); err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
resp, err := n.Client.Post(n.createNoticeURL, "application/json", buf)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
|
||||
buf.Reset()
|
||||
_, err = buf.ReadFrom(resp.Body)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
if resp.StatusCode != http.StatusCreated {
|
||||
if resp.StatusCode == httpStatusTooManyRequests {
|
||||
return "", errRateLimited
|
||||
}
|
||||
err := fmt.Errorf("gobrake: got response status=%q, wanted 201 CREATED", resp.Status)
|
||||
return "", err
|
||||
}
|
||||
|
||||
var sendResp sendResponse
|
||||
err = json.NewDecoder(buf).Decode(&sendResp)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
return sendResp.Id, nil
|
||||
}
|
||||
|
||||
func (n *Notifier) sendNotice(notice *Notice) {
|
||||
if _, err := n.SendNotice(notice); err != nil && err != errRateLimited {
|
||||
logger.Printf("gobrake failed reporting notice=%q: %s", notice, err)
|
||||
}
|
||||
n.wg.Done()
|
||||
}
|
||||
|
||||
// SendNoticeAsync acts as SendNotice, but sends notice asynchronously
|
||||
// and pending notices can be flushed with Flush.
|
||||
func (n *Notifier) SendNoticeAsync(notice *Notice) {
|
||||
select {
|
||||
case <-n.closed:
|
||||
return
|
||||
default:
|
||||
}
|
||||
|
||||
n.wg.Add(1)
|
||||
select {
|
||||
case n.noticeCh <- notice:
|
||||
default:
|
||||
n.wg.Done()
|
||||
logger.Printf(
|
||||
"notice=%q is ignored, because queue is full (len=%d)",
|
||||
notice, len(n.noticeCh),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
func (n *Notifier) worker() {
|
||||
for {
|
||||
select {
|
||||
case notice := <-n.noticeCh:
|
||||
n.sendNotice(notice)
|
||||
case <-n.closed:
|
||||
select {
|
||||
case notice := <-n.noticeCh:
|
||||
n.sendNotice(notice)
|
||||
default:
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// NotifyOnPanic notifies Airbrake about the panic and should be used
|
||||
// with defer statement.
|
||||
func (n *Notifier) NotifyOnPanic() {
|
||||
if v := recover(); v != nil {
|
||||
notice := n.Notice(v, nil, 3)
|
||||
n.SendNotice(notice)
|
||||
panic(v)
|
||||
}
|
||||
}
|
||||
|
||||
// Flush waits for pending requests to finish.
|
||||
func (n *Notifier) Flush() {
|
||||
n.waitTimeout(waitTimeout)
|
||||
}
|
||||
|
||||
// Deprecated. Use CloseTimeout instead.
|
||||
func (n *Notifier) WaitAndClose(timeout time.Duration) error {
|
||||
return n.CloseTimeout(timeout)
|
||||
}
|
||||
|
||||
// CloseTimeout waits for pending requests to finish and then closes the notifier.
|
||||
func (n *Notifier) CloseTimeout(timeout time.Duration) error {
|
||||
select {
|
||||
case <-n.closed:
|
||||
default:
|
||||
close(n.closed)
|
||||
}
|
||||
return n.waitTimeout(timeout)
|
||||
}
|
||||
|
||||
func (n *Notifier) waitTimeout(timeout time.Duration) error {
|
||||
done := make(chan struct{})
|
||||
go func() {
|
||||
n.wg.Wait()
|
||||
close(done)
|
||||
}()
|
||||
|
||||
select {
|
||||
case <-done:
|
||||
return nil
|
||||
case <-time.After(timeout):
|
||||
return fmt.Errorf("Wait timed out after %s", timeout)
|
||||
}
|
||||
}
|
||||
|
||||
func (n *Notifier) Close() error {
|
||||
return n.CloseTimeout(waitTimeout)
|
||||
}
|
||||
|
||||
func getCreateNoticeURL(host string, projectId int64, key string) string {
|
||||
return fmt.Sprintf(
|
||||
"%s/api/v3/projects/%d/notices?key=%s",
|
||||
host, projectId, key,
|
||||
)
|
||||
}
|
||||
|
||||
func noticeBacktraceFilter(notice *Notice) *Notice {
|
||||
v, ok := notice.Context["rootDirectory"]
|
||||
if !ok {
|
||||
return notice
|
||||
}
|
||||
|
||||
dir, ok := v.(string)
|
||||
if !ok {
|
||||
return notice
|
||||
}
|
||||
|
||||
dir = filepath.Join(dir, "src")
|
||||
for i := range notice.Errors {
|
||||
replaceRootDirectory(notice.Errors[i].Backtrace, dir)
|
||||
}
|
||||
return notice
|
||||
}
|
||||
|
||||
func replaceRootDirectory(backtrace []StackFrame, rootDir string) {
|
||||
for i := range backtrace {
|
||||
backtrace[i].File = strings.Replace(backtrace[i].File, rootDir, "[PROJECT_ROOT]", 1)
|
||||
}
|
||||
}
|
||||
59
vendor/gopkg.in/airbrake/gobrake.v2/util.go
generated
vendored
59
vendor/gopkg.in/airbrake/gobrake.v2/util.go
generated
vendored
@@ -1,59 +0,0 @@
|
||||
package gobrake
|
||||
|
||||
import (
|
||||
"runtime"
|
||||
"strings"
|
||||
)
|
||||
|
||||
func stackFilter(packageName, funcName string, file string, line int) bool {
|
||||
return packageName == "runtime" && funcName == "panic"
|
||||
}
|
||||
|
||||
type StackFrame struct {
|
||||
File string `json:"file"`
|
||||
Line int `json:"line"`
|
||||
Func string `json:"function"`
|
||||
}
|
||||
|
||||
func stack(depth int) []StackFrame {
|
||||
stack := []StackFrame{}
|
||||
for i := depth; ; i++ {
|
||||
pc, file, line, ok := runtime.Caller(i)
|
||||
if !ok {
|
||||
break
|
||||
}
|
||||
packageName, funcName := packageFuncName(pc)
|
||||
if stackFilter(packageName, funcName, file, line) {
|
||||
stack = stack[:0]
|
||||
continue
|
||||
}
|
||||
stack = append(stack, StackFrame{
|
||||
File: file,
|
||||
Line: line,
|
||||
Func: funcName,
|
||||
})
|
||||
}
|
||||
|
||||
return stack
|
||||
}
|
||||
|
||||
func packageFuncName(pc uintptr) (string, string) {
|
||||
f := runtime.FuncForPC(pc)
|
||||
if f == nil {
|
||||
return "", ""
|
||||
}
|
||||
|
||||
packageName := ""
|
||||
funcName := f.Name()
|
||||
|
||||
if ind := strings.LastIndex(funcName, "/"); ind > 0 {
|
||||
packageName += funcName[:ind+1]
|
||||
funcName = funcName[ind+1:]
|
||||
}
|
||||
if ind := strings.Index(funcName, "."); ind > 0 {
|
||||
packageName += funcName[:ind]
|
||||
funcName = funcName[ind+1:]
|
||||
}
|
||||
|
||||
return packageName, funcName
|
||||
}
|
||||
21
vendor/gopkg.in/gemnasium/logrus-airbrake-hook.v2/LICENSE
generated
vendored
21
vendor/gopkg.in/gemnasium/logrus-airbrake-hook.v2/LICENSE
generated
vendored
@@ -1,21 +0,0 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2015 Gemnasium
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
71
vendor/gopkg.in/gemnasium/logrus-airbrake-hook.v2/airbrake.go
generated
vendored
71
vendor/gopkg.in/gemnasium/logrus-airbrake-hook.v2/airbrake.go
generated
vendored
@@ -1,71 +0,0 @@
|
||||
package airbrake // import "gopkg.in/gemnasium/logrus-airbrake-hook.v2"
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"os"
|
||||
|
||||
"github.com/Sirupsen/logrus"
|
||||
"gopkg.in/airbrake/gobrake.v2"
|
||||
)
|
||||
|
||||
// AirbrakeHook to send exceptions to an exception-tracking service compatible
|
||||
// with the Airbrake API.
|
||||
type airbrakeHook struct {
|
||||
Airbrake *gobrake.Notifier
|
||||
}
|
||||
|
||||
func NewHook(projectID int64, apiKey, env string) *airbrakeHook {
|
||||
airbrake := gobrake.NewNotifier(projectID, apiKey)
|
||||
airbrake.AddFilter(func(notice *gobrake.Notice) *gobrake.Notice {
|
||||
if env == "development" {
|
||||
return nil
|
||||
}
|
||||
notice.Context["environment"] = env
|
||||
return notice
|
||||
})
|
||||
hook := &airbrakeHook{
|
||||
Airbrake: airbrake,
|
||||
}
|
||||
return hook
|
||||
}
|
||||
|
||||
func (hook *airbrakeHook) Fire(entry *logrus.Entry) error {
|
||||
var notifyErr error
|
||||
err, ok := entry.Data["error"].(error)
|
||||
if ok {
|
||||
notifyErr = err
|
||||
} else {
|
||||
notifyErr = errors.New(entry.Message)
|
||||
}
|
||||
var req *http.Request
|
||||
for k, v := range entry.Data {
|
||||
if r, ok := v.(*http.Request); ok {
|
||||
req = r
|
||||
delete(entry.Data, k)
|
||||
break
|
||||
}
|
||||
}
|
||||
notice := hook.Airbrake.Notice(notifyErr, req, 3)
|
||||
for k, v := range entry.Data {
|
||||
notice.Context[k] = fmt.Sprintf("%s", v)
|
||||
}
|
||||
|
||||
hook.sendNotice(notice)
|
||||
return nil
|
||||
}
|
||||
|
||||
func (hook *airbrakeHook) sendNotice(notice *gobrake.Notice) {
|
||||
if _, err := hook.Airbrake.SendNotice(notice); err != nil {
|
||||
fmt.Fprintf(os.Stderr, "Failed to send error to Airbrake: %v\n", err)
|
||||
}
|
||||
}
|
||||
|
||||
func (hook *airbrakeHook) Levels() []logrus.Level {
|
||||
return []logrus.Level{
|
||||
logrus.ErrorLevel,
|
||||
logrus.FatalLevel,
|
||||
logrus.PanicLevel,
|
||||
}
|
||||
}
|
||||
9
vendor/gopkg.in/yaml.v2/.travis.yml
generated
vendored
Normal file
9
vendor/gopkg.in/yaml.v2/.travis.yml
generated
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
language: go
|
||||
|
||||
go:
|
||||
- 1.4
|
||||
- 1.5
|
||||
- 1.6
|
||||
- tip
|
||||
|
||||
go_import_path: gopkg.in/yaml.v2
|
||||
31
vendor/gopkg.in/yaml.v2/LICENSE.libyaml
generated
vendored
Normal file
31
vendor/gopkg.in/yaml.v2/LICENSE.libyaml
generated
vendored
Normal file
@@ -0,0 +1,31 @@
|
||||
The following files were ported to Go from C files of libyaml, and thus
|
||||
are still covered by their original copyright and license:
|
||||
|
||||
apic.go
|
||||
emitterc.go
|
||||
parserc.go
|
||||
readerc.go
|
||||
scannerc.go
|
||||
writerc.go
|
||||
yamlh.go
|
||||
yamlprivateh.go
|
||||
|
||||
Copyright (c) 2006 Kirill Simonov
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
this software and associated documentation files (the "Software"), to deal in
|
||||
the Software without restriction, including without limitation the rights to
|
||||
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
||||
of the Software, and to permit persons to whom the Software is furnished to do
|
||||
so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
131
vendor/gopkg.in/yaml.v2/README.md
generated
vendored
Normal file
131
vendor/gopkg.in/yaml.v2/README.md
generated
vendored
Normal file
@@ -0,0 +1,131 @@
|
||||
# YAML support for the Go language
|
||||
|
||||
Introduction
|
||||
------------
|
||||
|
||||
The yaml package enables Go programs to comfortably encode and decode YAML
|
||||
values. It was developed within [Canonical](https://www.canonical.com) as
|
||||
part of the [juju](https://juju.ubuntu.com) project, and is based on a
|
||||
pure Go port of the well-known [libyaml](http://pyyaml.org/wiki/LibYAML)
|
||||
C library to parse and generate YAML data quickly and reliably.
|
||||
|
||||
Compatibility
|
||||
-------------
|
||||
|
||||
The yaml package supports most of YAML 1.1 and 1.2, including support for
|
||||
anchors, tags, map merging, etc. Multi-document unmarshalling is not yet
|
||||
implemented, and base-60 floats from YAML 1.1 are purposefully not
|
||||
supported since they're a poor design and are gone in YAML 1.2.
|
||||
|
||||
Installation and usage
|
||||
----------------------
|
||||
|
||||
The import path for the package is *gopkg.in/yaml.v2*.
|
||||
|
||||
To install it, run:
|
||||
|
||||
go get gopkg.in/yaml.v2
|
||||
|
||||
API documentation
|
||||
-----------------
|
||||
|
||||
If opened in a browser, the import path itself leads to the API documentation:
|
||||
|
||||
* [https://gopkg.in/yaml.v2](https://gopkg.in/yaml.v2)
|
||||
|
||||
API stability
|
||||
-------------
|
||||
|
||||
The package API for yaml v2 will remain stable as described in [gopkg.in](https://gopkg.in).
|
||||
|
||||
|
||||
License
|
||||
-------
|
||||
|
||||
The yaml package is licensed under the LGPL with an exception that allows it to be linked statically. Please see the LICENSE file for details.
|
||||
|
||||
|
||||
Example
|
||||
-------
|
||||
|
||||
```Go
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"log"
|
||||
|
||||
"gopkg.in/yaml.v2"
|
||||
)
|
||||
|
||||
var data = `
|
||||
a: Easy!
|
||||
b:
|
||||
c: 2
|
||||
d: [3, 4]
|
||||
`
|
||||
|
||||
type T struct {
|
||||
A string
|
||||
B struct {
|
||||
RenamedC int `yaml:"c"`
|
||||
D []int `yaml:",flow"`
|
||||
}
|
||||
}
|
||||
|
||||
func main() {
|
||||
t := T{}
|
||||
|
||||
err := yaml.Unmarshal([]byte(data), &t)
|
||||
if err != nil {
|
||||
log.Fatalf("error: %v", err)
|
||||
}
|
||||
fmt.Printf("--- t:\n%v\n\n", t)
|
||||
|
||||
d, err := yaml.Marshal(&t)
|
||||
if err != nil {
|
||||
log.Fatalf("error: %v", err)
|
||||
}
|
||||
fmt.Printf("--- t dump:\n%s\n\n", string(d))
|
||||
|
||||
m := make(map[interface{}]interface{})
|
||||
|
||||
err = yaml.Unmarshal([]byte(data), &m)
|
||||
if err != nil {
|
||||
log.Fatalf("error: %v", err)
|
||||
}
|
||||
fmt.Printf("--- m:\n%v\n\n", m)
|
||||
|
||||
d, err = yaml.Marshal(&m)
|
||||
if err != nil {
|
||||
log.Fatalf("error: %v", err)
|
||||
}
|
||||
fmt.Printf("--- m dump:\n%s\n\n", string(d))
|
||||
}
|
||||
```
|
||||
|
||||
This example will generate the following output:
|
||||
|
||||
```
|
||||
--- t:
|
||||
{Easy! {2 [3 4]}}
|
||||
|
||||
--- t dump:
|
||||
a: Easy!
|
||||
b:
|
||||
c: 2
|
||||
d: [3, 4]
|
||||
|
||||
|
||||
--- m:
|
||||
map[a:Easy! b:map[c:2 d:[3 4]]]
|
||||
|
||||
--- m dump:
|
||||
a: Easy!
|
||||
b:
|
||||
c: 2
|
||||
d:
|
||||
- 3
|
||||
- 4
|
||||
```
|
||||
|
||||
Reference in New Issue
Block a user