Update dependencies

This commit is contained in:
Ed Robinson 2017-04-07 10:09:57 +01:00
parent 51e4dcbb1f
commit 65284441fa
No known key found for this signature in database
GPG key ID: EC501FCA6421CCF0
98 changed files with 25265 additions and 1992 deletions

View file

@ -17,7 +17,6 @@ package swag
import (
"bytes"
"encoding/json"
"log"
"reflect"
"strings"
"sync"
@ -111,40 +110,28 @@ func ConcatJSON(blobs ...[]byte) []byte {
if len(b) < 3 { // yep empty but also the last one, so closing this thing
if i == last && a > 0 {
if err := buf.WriteByte(closing); err != nil {
log.Println(err)
}
buf.WriteByte(closing)
}
continue
}
idx = 0
if a > 0 { // we need to join with a comma for everything beyond the first non-empty item
if err := buf.WriteByte(comma); err != nil {
log.Println(err)
}
buf.WriteByte(comma)
idx = 1 // this is not the first or the last so we want to drop the leading bracket
}
if i != last { // not the last one, strip brackets
if _, err := buf.Write(b[idx : len(b)-1]); err != nil {
log.Println(err)
}
buf.Write(b[idx : len(b)-1])
} else { // last one, strip only the leading bracket
if _, err := buf.Write(b[idx:]); err != nil {
log.Println(err)
}
buf.Write(b[idx:])
}
a++
}
// somehow it ended up being empty, so provide a default value
if buf.Len() == 0 {
if err := buf.WriteByte(opening); err != nil {
log.Println(err)
}
if err := buf.WriteByte(closing); err != nil {
log.Println(err)
}
buf.WriteByte(opening)
buf.WriteByte(closing)
}
return buf.Bytes()
}
@ -152,23 +139,15 @@ func ConcatJSON(blobs ...[]byte) []byte {
// ToDynamicJSON turns an object into a properly JSON typed structure
func ToDynamicJSON(data interface{}) interface{} {
// TODO: convert straight to a json typed map (mergo + iterate?)
b, err := json.Marshal(data)
if err != nil {
log.Println(err)
}
b, _ := json.Marshal(data)
var res interface{}
if err := json.Unmarshal(b, &res); err != nil {
log.Println(err)
}
json.Unmarshal(b, &res)
return res
}
// FromDynamicJSON turns an object into a properly JSON typed structure
func FromDynamicJSON(data, target interface{}) error {
b, err := json.Marshal(data)
if err != nil {
log.Println(err)
}
b, _ := json.Marshal(data)
return json.Unmarshal(b, target)
}