aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjackyzha0 <[email protected]>2020-05-09 15:51:00 -0700
committerjackyzha0 <[email protected]>2020-05-09 15:51:00 -0700
commitaf0031eadbfe88fe8125c0add97d71f1c7fcc801 (patch)
tree4ff9693cecd149ad91d6f0465746104a22378c08
parentfix dockerfile envs (diff)
downloadctrl-v-af0031eadbfe88fe8125c0add97d71f1c7fcc801.tar.xz
ctrl-v-af0031eadbfe88fe8125c0add97d71f1c7fcc801.zip
fix port bug
-rw-r--r--Dockerfile1
-rw-r--r--cache/cache.go9
2 files changed, 7 insertions, 3 deletions
diff --git a/Dockerfile b/Dockerfile
index 41a3dcc..b533070 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -15,6 +15,7 @@ RUN CGO_ENABLED=0 GOOS=linux go build -o /go/bin/app
FROM scratch
# Copy app
+COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
COPY --from=builder /go/bin/app ./
COPY .env ./
diff --git a/cache/cache.go b/cache/cache.go
index da27939..b311efa 100644
--- a/cache/cache.go
+++ b/cache/cache.go
@@ -19,10 +19,12 @@ func New() *Cache {
func (c *Cache) Get(hash string) (db.Paste, error) {
c.lock.RLock()
- defer c.lock.RUnlock()
// check if hash in cache
- if v, ok := c.m[hash]; ok {
+ v, ok := c.m[hash]
+ c.lock.RUnlock()
+
+ if ok {
return v, nil
}
@@ -34,6 +36,7 @@ func (c *Cache) Get(hash string) (db.Paste, error) {
func (c *Cache) add(p db.Paste) {
c.lock.Lock()
+ defer c.lock.Unlock()
+
c.m[p.Hash] = p
- c.lock.Unlock()
}