From 3687f2739978d0e095a6b00338a68e3de148c2d1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lilian=20J=C3=B3nsd=C3=B3ttir?= Date: Wed, 6 Mar 2024 15:09:26 -0800 Subject: [PATCH] mage -> just --- go.mod | 1 - justfile | 35 +++++++++++++++++++++++++++++++++++ magefile.go | 38 -------------------------------------- 3 files changed, 35 insertions(+), 39 deletions(-) create mode 100644 justfile delete mode 100644 magefile.go diff --git a/go.mod b/go.mod index 5600402..c5b5b79 100644 --- a/go.mod +++ b/go.mod @@ -7,7 +7,6 @@ require ( github.com/go-chi/chi/v5 v5.0.11 github.com/ilyakaznacheev/cleanenv v1.5.0 github.com/madflojo/tasks v1.1.0 - github.com/magefile/mage v1.15.0 ) require ( diff --git a/justfile b/justfile new file mode 100644 index 0000000..bdcdfe5 --- /dev/null +++ b/justfile @@ -0,0 +1,35 @@ +binary := "burningmoe" +build_dir := "bin" +cmd := "./cmd/web" +output := "." / build_dir / binary + +# do the thing +default: run + +# build binary +build: + go build -o {{output}} {{cmd}} + +# run from source +run: + go run {{cmd}} + +# build 'n run +run-binary: build + exec {{output}} + +# run with args +run-args args: + go run {{cmd}} {{args}} + +# install binary into $GOPATH +install: + go install {{cmd}} + +# clean up after yourself +clean: + rm {{output}} + +# run go tests +test: + go test ./... diff --git a/magefile.go b/magefile.go deleted file mode 100644 index 5bf9480..0000000 --- a/magefile.go +++ /dev/null @@ -1,38 +0,0 @@ -//go:build mage - -package main - -import ( - "fmt" - "os" - - "github.com/magefile/mage/sh" -) - -var ( - binaryName string = "burningmoe" - buildDir string = "bin" - cmd string = fmt.Sprintf(".%[1]ccmd%[1]cweb", os.PathSeparator) - output string = fmt.Sprintf(".%[1]c%[2]s%[1]c%[3]s", os.PathSeparator, buildDir, binaryName) -) - -func Build() error { - fmt.Println("Building...") - return sh.Run("go", "build", "-o", output, cmd) -} - -func Run() error { - fmt.Println("Running...") - return sh.Run("go", "run", cmd) -} - -func RunBinary() error { - Build() - fmt.Println("Running binary...") - return sh.Run(output) -} - -func Clean() error { - fmt.Println("Cleaning...") - return os.Remove(output) -}