commit fa2bac276ead6d165b2f5829b583dc5baa7c0534 Author: William Perron Date: Tue Sep 24 10:44:31 2024 -0400 initial commit 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) + } + } +}