aboutsummaryrefslogtreecommitdiff
path: root/vendor/github.com/pelletier
diff options
context:
space:
mode:
authorNiall Sheridan <nsheridan@gmail.com>2017-02-12 22:24:33 +0000
committerNiall Sheridan <nsheridan@gmail.com>2017-02-12 22:24:33 +0000
commitba4840c52becf73c2749c9ef0f2f09ed0b9d5c7f (patch)
tree61b839884d66c9dd8269e26117aa4e4c995ad119 /vendor/github.com/pelletier
parent6e00d0000e54f21a4a393e67fd914bda4d394f4a (diff)
Update dependencies
Diffstat (limited to 'vendor/github.com/pelletier')
-rw-r--r--vendor/github.com/pelletier/go-toml/LICENSE3
-rw-r--r--vendor/github.com/pelletier/go-toml/README.md4
-rw-r--r--vendor/github.com/pelletier/go-toml/doc.go8
-rw-r--r--vendor/github.com/pelletier/go-toml/lexer.go20
-rw-r--r--vendor/github.com/pelletier/go-toml/tomltree_conversions.go32
5 files changed, 44 insertions, 23 deletions
diff --git a/vendor/github.com/pelletier/go-toml/LICENSE b/vendor/github.com/pelletier/go-toml/LICENSE
index 5f9f53d..583bdae 100644
--- a/vendor/github.com/pelletier/go-toml/LICENSE
+++ b/vendor/github.com/pelletier/go-toml/LICENSE
@@ -1,6 +1,6 @@
The MIT License (MIT)
-Copyright (c) 2013 - 2016 Thomas Pelletier, Eric Anderton
+Copyright (c) 2013 - 2017 Thomas Pelletier, Eric Anderton
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
@@ -19,4 +19,3 @@ 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.
-
diff --git a/vendor/github.com/pelletier/go-toml/README.md b/vendor/github.com/pelletier/go-toml/README.md
index b511f39..b8137e0 100644
--- a/vendor/github.com/pelletier/go-toml/README.md
+++ b/vendor/github.com/pelletier/go-toml/README.md
@@ -6,7 +6,7 @@ This library supports TOML version
[v0.4.0](https://github.com/toml-lang/toml/blob/master/versions/en/toml-v0.4.0.md)
[![GoDoc](https://godoc.org/github.com/pelletier/go-toml?status.svg)](http://godoc.org/github.com/pelletier/go-toml)
-[![License](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/goadesign/goa/blob/master/LICENSE)
+[![license](https://img.shields.io/github/license/pelletier/go-toml.svg)](https://github.com/pelletier/go-toml/blob/master/LICENSE)
[![Build Status](https://travis-ci.org/pelletier/go-toml.svg?branch=master)](https://travis-ci.org/pelletier/go-toml)
[![Coverage Status](https://coveralls.io/repos/github/pelletier/go-toml/badge.svg?branch=master)](https://coveralls.io/github/pelletier/go-toml?branch=master)
[![Go Report Card](https://goreportcard.com/badge/github.com/pelletier/go-toml)](https://goreportcard.com/report/github.com/pelletier/go-toml)
@@ -96,7 +96,7 @@ Go-toml provides two handy command line tools:
* `tomljson`: Reads a TOML file and outputs its JSON representation.
```
- go install github.com/pelletier/go-toml/cmd/tomjson
+ go install github.com/pelletier/go-toml/cmd/tomljson
tomljson --help
```
diff --git a/vendor/github.com/pelletier/go-toml/doc.go b/vendor/github.com/pelletier/go-toml/doc.go
index c8c9add..9156b73 100644
--- a/vendor/github.com/pelletier/go-toml/doc.go
+++ b/vendor/github.com/pelletier/go-toml/doc.go
@@ -22,8 +22,8 @@
// After parsing TOML data with Load() or LoadFile(), use the Has() and Get()
// methods on the returned TomlTree, to find your way through the document data.
//
-// if tree.Has('foo') {
-// fmt.Prinln("foo is: %v", tree.Get('foo'))
+// if tree.Has("foo") {
+// fmt.Println("foo is:", tree.Get("foo"))
// }
//
// Working with Paths
@@ -44,10 +44,10 @@
// it avoids having to parse the passed key for '.' delimiters.
//
// // looks for a key named 'baz', within struct 'bar', within struct 'foo'
-// tree.HasPath(string{}{"foo","bar","baz"})
+// tree.HasPath([]string{"foo","bar","baz"})
//
// // returns the key at this path, if it is there
-// tree.GetPath(string{}{"foo","bar","baz"})
+// tree.GetPath([]string{"foo","bar","baz"})
//
// Note that this is distinct from the heavyweight query syntax supported by
// TomlTree.Query() and the Query() struct (see below).
diff --git a/vendor/github.com/pelletier/go-toml/lexer.go b/vendor/github.com/pelletier/go-toml/lexer.go
index 4b378d4..4ba134c 100644
--- a/vendor/github.com/pelletier/go-toml/lexer.go
+++ b/vendor/github.com/pelletier/go-toml/lexer.go
@@ -131,7 +131,7 @@ func (l *tomlLexer) lexVoid() tomlLexStateFn {
case '[':
return l.lexTableKey
case '#':
- return l.lexComment
+ return l.lexComment(l.lexVoid)
case '=':
return l.lexEqual
case '\r':
@@ -182,7 +182,7 @@ func (l *tomlLexer) lexRvalue() tomlLexStateFn {
case '}':
return l.lexRightCurlyBrace
case '#':
- return l.lexComment
+ return l.lexComment(l.lexRvalue)
case '"':
return l.lexString
case '\'':
@@ -309,15 +309,17 @@ func (l *tomlLexer) lexKey() tomlLexStateFn {
return l.lexVoid
}
-func (l *tomlLexer) lexComment() tomlLexStateFn {
- for next := l.peek(); next != '\n' && next != eof; next = l.peek() {
- if next == '\r' && l.follow("\r\n") {
- break
+func (l *tomlLexer) lexComment(previousState tomlLexStateFn) tomlLexStateFn {
+ return func() tomlLexStateFn {
+ for next := l.peek(); next != '\n' && next != eof; next = l.peek() {
+ if next == '\r' && l.follow("\r\n") {
+ break
+ }
+ l.next()
}
- l.next()
+ l.ignore()
+ return previousState
}
- l.ignore()
- return l.lexVoid
}
func (l *tomlLexer) lexLeftBracket() tomlLexStateFn {
diff --git a/vendor/github.com/pelletier/go-toml/tomltree_conversions.go b/vendor/github.com/pelletier/go-toml/tomltree_conversions.go
index db3da0d..fc8f22b 100644
--- a/vendor/github.com/pelletier/go-toml/tomltree_conversions.go
+++ b/vendor/github.com/pelletier/go-toml/tomltree_conversions.go
@@ -87,7 +87,7 @@ func toTomlValue(item interface{}, indent int) string {
case nil:
return ""
default:
- panic(fmt.Sprintf("unsupported value type %T: %v", value, value))
+ panic(fmt.Errorf("unsupported value type %T: %v", value, value))
}
}
@@ -154,6 +154,23 @@ func (t *TomlTree) toToml(indent, keyspace string) string {
return strings.Join(resultChunks, "")
}
+// Same as ToToml(), but does not panic and returns an error
+func (t *TomlTree) toTomlSafe(indent, keyspace string) (result string, err error) {
+ defer func() {
+ if r := recover(); r != nil {
+ result = ""
+ switch x := r.(type) {
+ case error:
+ err = x
+ default:
+ err = fmt.Errorf("unknown panic: %s", r)
+ }
+ }
+ }()
+ result = t.toToml(indent, keyspace)
+ return
+}
+
func convertMapStringString(in map[string]string) map[string]interface{} {
result := make(map[string]interface{}, len(in))
for k, v := range in {
@@ -170,15 +187,18 @@ func convertMapInterfaceInterface(in map[interface{}]interface{}) map[string]int
return result
}
-// ToString is an alias for String
-func (t *TomlTree) ToString() string {
- return t.String()
+// ToString generates a human-readable representation of the current tree.
+// Output spans multiple lines, and is suitable for ingest by a TOML parser.
+// If the conversion cannot be performed, ToString returns a non-nil error.
+func (t *TomlTree) ToString() (string, error) {
+ return t.toTomlSafe("", "")
}
// String generates a human-readable representation of the current tree.
-// Output spans multiple lines, and is suitable for ingest by a TOML parser
+// Alias of ToString.
func (t *TomlTree) String() string {
- return t.toToml("", "")
+ result, _ := t.ToString()
+ return result
}
// ToMap recursively generates a representation of the current tree using map[string]interface{}.