-
-
Notifications
You must be signed in to change notification settings - Fork 82
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* fix issue #84 in v1.x.x * rename * update
- Loading branch information
Showing
7 changed files
with
106 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,16 @@ | ||
module github.com/clivern/beaver | ||
|
||
go 1.14 | ||
go 1.15 | ||
|
||
require ( | ||
github.com/dgrijalva/jwt-go v3.2.0+incompatible | ||
github.com/gin-gonic/gin v1.6.3 | ||
github.com/go-redis/redis v6.15.8+incompatible | ||
github.com/go-redis/redis/v7 v7.4.0 | ||
github.com/go-redis/redis v6.15.9+incompatible | ||
github.com/google/logger v1.1.0 | ||
github.com/gorilla/websocket v1.4.2 | ||
github.com/nbio/st v0.0.0-20140626010706-e9e8d9816f32 | ||
github.com/onsi/ginkgo v1.12.1 // indirect | ||
github.com/onsi/gomega v1.10.0 // indirect | ||
github.com/onsi/ginkgo v1.14.2 // indirect | ||
github.com/onsi/gomega v1.10.4 // indirect | ||
github.com/satori/go.uuid v1.2.0 | ||
github.com/spf13/viper v1.7.1 | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
// Copyright 2018 Clivern. All rights reserved. | ||
// Use of this source code is governed by the MIT | ||
// license that can be found in the LICENSE file. | ||
|
||
package utils | ||
|
||
import ( | ||
"sync" | ||
) | ||
|
||
// Map type | ||
type Map struct { | ||
sync.RWMutex | ||
items map[string]interface{} | ||
} | ||
|
||
// NewMap creates a new instance of Map | ||
func NewMap() Map { | ||
return Map{items: make(map[string]interface{})} | ||
} | ||
|
||
// Gets a key from a concurrent map | ||
func (cm *Map) Get(key string) (interface{}, bool) { | ||
cm.Lock() | ||
defer cm.Unlock() | ||
|
||
value, ok := cm.items[key] | ||
|
||
return value, ok | ||
} | ||
|
||
// Sets a key in a concurrent map | ||
func (cm *Map) Set(key string, value interface{}) { | ||
cm.Lock() | ||
defer cm.Unlock() | ||
|
||
cm.items[key] = value | ||
} | ||
|
||
// Delete deletes a key | ||
func (cm *Map) Delete(key string) { | ||
cm.Lock() | ||
defer cm.Unlock() | ||
|
||
delete(cm.items, key) | ||
} |