Created
June 16, 2024 18:16
-
-
Save madflow/e7f9a6d920ee5a0eaff4847998eee8ab to your computer and use it in GitHub Desktop.
Makefile for a Go project
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Makefile for a Go project | |
# Binary output name | |
BINARY_NAME=hallo-welt | |
# Default make command | |
all: help | |
# Build the binary | |
build: | |
@echo "Building..." | |
go build -o $(BINARY_NAME) ./main.go | |
# Run the server | |
run: build | |
@echo "Running..." | |
./$(BINARY_NAME) | |
# Test your application | |
test: | |
@echo "Testing..." | |
go test ./... | |
# Clean up binaries | |
clean: | |
@echo "Cleaning..." | |
go clean | |
rm -f $(BINARY_NAME) | |
# Help command to display available commands | |
help: | |
@echo "Makefile commands:" | |
@echo "all - Build the application" | |
@echo "build - Build the binary" | |
@echo "run - Build and run the application" | |
@echo "test - Run tests" | |
@echo "clean - Remove binaries" | |
@echo "help - Display this help" | |
# Mark commands that don't correspond to files as .PHONY | |
.PHONY: all build run test clean help |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment