#!/usr/bin/env bash name=day-"$1" if [ -d day-"$name" ]; then echo "program $name already exists" exit 1 fi mkdir -p "$name"/cmd/cli/testdata \ "$name"/testdata "$name"/internal/one/testdata "$name"/internal/two/testdata touch "$name"/makefile cat <> "$name"/makefile program = $name GO = go SRC_DIR := src BIN_DIR := bin EXE := \$(BIN_DIR)/\$(program) .DEFAULT_GOAL := build .PHONY: fmt vet build bench clean fmt: \$(GO) fmt ./... vet: fmt \$(GO) vet ./... build: vet | \$(BIN_DIR) \$(GO) build -o \$(EXE) ./\$(SRC_DIR) bench: \$(GO) test ./internal/one/ -bench=. > internal/one/benchmark \$(GO) test ./internal/two/ -bench=. > internal/two/benchmark \$(GO) test . -count=10 -bench=. > benchmark \$(BIN_DIR): @mkdir -p \$@ clean: @rm -rv \$(BIN_DIR) EOT cat <> "$name"/cmd/cli/main.go /******************************************************************************** Advent of Code 2024 - $name ********************************************************************************/ package main func main() { } EOT cd "$name" || exit go mod init github.com/onyx-and-iris/aoc2024/"$name"