From af0031eadbfe88fe8125c0add97d71f1c7fcc801 Mon Sep 17 00:00:00 2001 From: jackyzha0 Date: Sat, 9 May 2020 15:51:00 -0700 Subject: fix port bug --- Dockerfile | 1 + cache/cache.go | 9 ++++++--- 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() } -- cgit v1.2.3