This guide explains the available targets and options defined in the Makefile to build, test, format, and install the NodeShare application.
Performs the complete development cycle:
- Generates Go files from Protobuf definitions (
make proto). - Compiles the binary for the current host system (
make build). - Runs all package-level unit tests (
make test).
Compiles the application entrypoint ./cmd/nodeshare into the target directory dist/nodeshare (or dist/nodeshare.exe on Windows).
- Automatically triggers a rebuild of the protobuf code if necessary.
- Compiles with optimized linker flags (
-s -w) to produce a smaller binary footprint.
Regenerates the Go struct definitions from the protobuf schemas in the proto/ directory.
- Requires both
protocandprotoc-gen-goto be installed and available in the system path. - Resolves code-generation paths relative to the source structure.
Cross-compiles static binaries for all supported target platforms:
- OS/Architectures:
linux/amd64,linux/arm64,windows/amd64,darwin/amd64,darwin/arm64. - Outputs binaries into the
dist/directory labeled by platform (e.g.,nodeshare-linux-amd64).
Installs NodeShare system-wide for everyday command-line use.
- Environment Setup: Checks for an existing
.envfile. If not found, it clones.env.exampleto.envto prompt configuration. - Build: Recompiles the executable for the current platform.
- Installation: Attempts to install the binary to
/usr/local/bin/nodeshareor falls back to user local binaries at~/.local/bin/nodeshare. If permissions are missing, it retries usingsudo.
Builds the binary and immediately launches the NodeShare daemon in provider mode.
Runs the official go fmt utility to format all Go source files according to Go standards.
Performs static analysis checks using go vet to catch common compiler-level errors or mistakes (like incorrect format verbs).
Runs the golangci-lint runner on all codebase packages.
- Requires
golangci-lintto be installed on the local system.
Tidies dependencies in go.mod and go.sum, removing unused dependencies and adding missing ones.
Removes generated build artifacts:
- Deletes the
dist/directory. - Cleans up generated
.pb.gofiles from thegen/directory.
Executes all unit tests in the repository using the Go race detector (-race) to prevent synchronization bugs.
Runs unit tests in verbose mode, showing detailed outputs for each test case.