aboutsummaryrefslogtreecommitdiff
path: root/vendor/github.com/go-openapi/swag/json.go
diff options
context:
space:
mode:
authorGravatar Miek Gieben <miek@miek.nl> 2017-08-28 17:49:28 +0200
committerGravatar Yong Tang <yong.tang.github@outlook.com> 2017-08-28 08:49:28 -0700
commit7e63bdbee8340d3ce2d2488f93d0fb1d4d16a201 (patch)
tree2734029ca19d1a21794ffc65299c0d57254f5352 /vendor/github.com/go-openapi/swag/json.go
parent558f4bea41e0493dd4b0e6d0f73b0220a39d1e67 (diff)
downloadcoredns-7e63bdbee8340d3ce2d2488f93d0fb1d4d16a201.tar.gz
coredns-7e63bdbee8340d3ce2d2488f93d0fb1d4d16a201.tar.zst
coredns-7e63bdbee8340d3ce2d2488f93d0fb1d4d16a201.zip
dep ensure -update (#1001)
* dep ensure -update Run "dep ensure -update` to update all dependencies. No code changes; just the dependencies. * dep prune * add new venderod
Diffstat (limited to 'vendor/github.com/go-openapi/swag/json.go')
-rw-r--r--vendor/github.com/go-openapi/swag/json.go8
1 files changed, 6 insertions, 2 deletions
diff --git a/vendor/github.com/go-openapi/swag/json.go b/vendor/github.com/go-openapi/swag/json.go
index 0eb374467..cb20a6a0f 100644
--- a/vendor/github.com/go-openapi/swag/json.go
+++ b/vendor/github.com/go-openapi/swag/json.go
@@ -237,6 +237,8 @@ func newNameIndex(tpe reflect.Type) nameIndex {
// GetJSONNames gets all the json property names for a type
func (n *NameProvider) GetJSONNames(subject interface{}) []string {
+ n.lock.Lock()
+ defer n.lock.Unlock()
tpe := reflect.Indirect(reflect.ValueOf(subject)).Type()
names, ok := n.index[tpe]
if !ok {
@@ -258,6 +260,8 @@ func (n *NameProvider) GetJSONName(subject interface{}, name string) (string, bo
// GetJSONNameForType gets the json name for a go property name on a given type
func (n *NameProvider) GetJSONNameForType(tpe reflect.Type, name string) (string, bool) {
+ n.lock.Lock()
+ defer n.lock.Unlock()
names, ok := n.index[tpe]
if !ok {
names = n.makeNameIndex(tpe)
@@ -267,8 +271,6 @@ func (n *NameProvider) GetJSONNameForType(tpe reflect.Type, name string) (string
}
func (n *NameProvider) makeNameIndex(tpe reflect.Type) nameIndex {
- n.lock.Lock()
- defer n.lock.Unlock()
names := newNameIndex(tpe)
n.index[tpe] = names
return names
@@ -282,6 +284,8 @@ func (n *NameProvider) GetGoName(subject interface{}, name string) (string, bool
// GetGoNameForType gets the go name for a given type for a json property name
func (n *NameProvider) GetGoNameForType(tpe reflect.Type, name string) (string, bool) {
+ n.lock.Lock()
+ defer n.lock.Unlock()
names, ok := n.index[tpe]
if !ok {
names = n.makeNameIndex(tpe)