Skip to content

Commit 06b8ffc

Browse files
committed
fix(memorystore): fix outdated Memorystore golang samples
1 parent e18ca2d commit 06b8ffc

File tree

7 files changed

+33
-218
lines changed

7 files changed

+33
-218
lines changed

memorystore/go.mod

Lines changed: 0 additions & 62 deletions
This file was deleted.

memorystore/go.sum

Lines changed: 0 additions & 146 deletions
This file was deleted.

memorystore/redis/gke_deployment/Dockerfile

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,18 +12,23 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
FROM golang:1.24-alpine
15+
FROM golang:1.24-bookworm AS builder
1616

17-
RUN apk update && apk add git
17+
WORKDIR /app
1818

19-
RUN go get github.com/gomodule/redigo/redis
19+
COPY go.mod go.sum ./
20+
RUN go mod download
21+
COPY *.go ./
22+
RUN CGO_ENABLED=0 go build -o app .
2023

21-
ADD . /go/src/visit-counter
22-
RUN go install visit-counter
24+
FROM scratch
2325

24-
ENV REDISHOST redis
25-
ENV REDISPORT 6379
26+
WORKDIR /app
2627

27-
ENTRYPOINT /go/bin/visit-counter
28+
COPY --from=builder /app/app .
2829

30+
ENV REDISHOST=redis
31+
ENV REDISPORT=6379
32+
33+
ENTRYPOINT ["/app/app"]
2934
EXPOSE 8080

memorystore/redis/gke_deployment/visit-counter.yaml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,17 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
apiVersion: extensions/v1beta1
15+
apiVersion: apps/v1
1616
kind: Deployment
1717
metadata:
1818
name: visit-counter
1919
labels:
2020
app: visit-counter
2121
spec:
2222
replicas: 1
23+
selector:
24+
matchLabels:
25+
app: visit-counter
2326
template:
2427
metadata:
2528
labels:

memorystore/redis/go.mod

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
module visit-counter
2+
3+
go 1.24.8
4+
5+
require github.com/gomodule/redigo v1.9.3

memorystore/redis/go.sum

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
2+
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
3+
github.com/gomodule/redigo v1.9.3 h1:dNPSXeXv6HCq2jdyWfjgmhBdqnR6PRO3m/G05nvpPC8=
4+
github.com/gomodule/redigo v1.9.3/go.mod h1:KsU3hiK/Ay8U42qpaJk+kuNa3C+spxapWpM+ywhcgtw=
5+
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
6+
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
7+
github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk=
8+
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
9+
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
10+
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=

memorystore/redis/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
// [START memorystore_main_go]
1616

17-
// Command redis is a basic app that connects to a managed Redis instance.
17+
// Package main is a basic app that connects to a managed Redis instance.
1818
package main
1919

2020
import (

0 commit comments

Comments
 (0)