From fa2bac276ead6d165b2f5829b583dc5baa7c0534 Mon Sep 17 00:00:00 2001 From: William Perron Date: Tue, 24 Sep 2024 10:44:31 -0400 Subject: [PATCH] initial commit --- .gitignore | 1 + Dockerfile | 8 ++++++++ go.mod | 3 +++ main.go | 26 ++++++++++++++++++++++++++ 4 files changed, 38 insertions(+) create mode 100644 .gitignore create mode 100644 Dockerfile create mode 100644 go.mod create mode 100644 main.go diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..e660fd9 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +bin/ diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..22dc461 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,8 @@ +from golang:1.23-bookworm as build +workdir /app +copy . . +run CGO_ENABLED=0 go build -o oombomb ./main.go + +from scratch +copy --from=build /app/oombomb /oombomb +cmd ["/oombomb"] diff --git a/go.mod b/go.mod new file mode 100644 index 0000000..efc968c --- /dev/null +++ b/go.mod @@ -0,0 +1,3 @@ +module go.wperron.io/oombomb + +go 1.22.1 diff --git a/main.go b/main.go new file mode 100644 index 0000000..079a016 --- /dev/null +++ b/main.go @@ -0,0 +1,26 @@ +package main + +import ( + "context" + "os/signal" + "strings" + "syscall" + "time" +) + +func main() { + ctx, cancel := signal.NotifyContext(context.Background(), syscall.SIGTERM, syscall.SIGKILL, syscall.SIGINT) + defer cancel() + init := "Hello, World!" + ticker := time.NewTicker(time.Second) + +mainloop: + for { + select { + case <-ctx.Done(): + break mainloop + case <-ticker.C: + init = strings.Repeat(init, 10) + } + } +}