Contributing to GoMFT
Thank you for your interest in contributing to GoMFT! This guide will help you get started with contributing to the project.
Code of Conduct
By participating in this project, you agree to abide by our Code of Conduct. Please read it before contributing.
Getting Started
Prerequisites
Before you begin, ensure you have the following installed:
- Go (version 1.20 or later)
- Node.js (version 18 or later)
- Git
- Docker (optional, for container-based development)
Setting Up the Development Environment
-
Fork the repository on GitHub.
-
Clone your forked repository:
git clone https://github.com/YOUR_USERNAME/GoMFT.git
cd GoMFT
- Add the original repository as an upstream remote:
git remote add upstream https://github.com/StarFleetCPTN/GoMFT.git
- Install Go dependencies:
go mod download
- Install Node.js dependencies:
npm install
- Install the Templ compiler:
go install github.com/a-h/templ/cmd/templ@latest
- Install Air for live reloading during development:
go install github.com/cosmtrek/air@latest
Development Workflow
- Create a new branch for your feature or bug fix:
git checkout -b feature/your-feature-name
-
Make your changes to the codebase.
-
Compile the Templ templates:
templ generate
- Run the development server with Air:
air
This will start the application with hot reloading enabled, so changes to Go files will trigger a rebuild.
- For frontend development, compile the Tailwind CSS and watch for changes:
npm run dev
- Access the application at
http://localhost:8080
.
Project Structure
See the Project Structure page for a detailed overview of the codebase organization.
Coding Guidelines
Go Code
- Follow the Go Code Review Comments and Effective Go guidelines.
- Format your code with
gofmt
orgo fmt
. - Ensure your code passes
golint
andgo vet
. - Write tests for your functionality.
- Add comments to exported functions, types, and packages.
Frontend Code
- Follow the Airbnb JavaScript Style Guide for JavaScript code.
- Use Tailwind CSS for styling.
- Ensure your UI components are responsive.
- Test your UI changes in different browsers.
Commit Messages
- Use clear and meaningful commit messages.
- Follow the Conventional Commits specification:
feat
: A new featurefix
: A bug fixdocs
: Documentation only changesstyle
: Changes that do not affect the meaning of the coderefactor
: A code change that neither fixes a bug nor adds a featuretest
: Adding missing tests or correcting existing testschore
: Changes to the build process or auxiliary toolsperf
: Performance improvements
Example: feat: add email notification for failed transfers
Testing
Running Tests
Run the Go tests:
go test ./...
Run specific tests:
go test ./internal/api/...
Writing Tests
- Write unit tests for your functions and methods.
- Write integration tests for API endpoints.
- Aim for high test coverage, especially for critical functionality.
- Use table-driven tests where appropriate.
Pull Request Process
- Update your branch with the latest changes from upstream:
git fetch upstream
git rebase upstream/main
- Push your branch to your forked repository:
git push origin feature/your-feature-name
-
Create a pull request from your branch to the main repository.
-
Ensure your PR description clearly describes the changes you've made.
-
Link any relevant issues in your PR description.
-
Wait for code review and address any feedback.
PR Review Checklist
Before submitting your PR, please ensure:
- Your code builds without errors or warnings
- You've added tests for your changes
- All tests pass
- Your code follows the project's coding guidelines
- You've updated documentation as needed
- You've added appropriate logging
- You've considered security implications
- Your changes don't introduce performance regressions
Development Tips
Working with Templ
Templ is used for HTML templating in GoMFT. After making changes to .templ
files, you need to regenerate the Go code:
templ generate
Working with HTMX
HTMX is used for dynamic UI updates. Familiarize yourself with its concepts before making UI changes.
Working with SQLite
GoMFT uses SQLite for data storage. The database file is located at data/gomft.db
by default. You can use a tool like SQLite Browser to inspect the database.
Debugging
For debugging Go code, you can use:
fmt.Printf()
statements for simple debugging- Delve for more complex debugging scenarios
- VSCode's integrated Go debugger
Documentation
Updating Documentation
Documentation is written in Markdown and stored in the docs/
directory. To update the documentation:
- Edit the relevant Markdown files.
- If you're adding new pages, update the sidebar configuration in
sidebars.ts
. - Preview your changes using the documentation development server:
cd documentation
npm install
npm start
- Access the documentation at
http://localhost:3000
.
API Documentation
API documentation is generated from Go comments using Swaggo. To update the API documentation:
- Update the API comments following the Swagger/OpenAPI format.
- Regenerate the API documentation:
swag init -g cmd/api/main.go
Release Process
GoMFT follows Semantic Versioning.
Creating a Release
-
Update the version number in relevant files:
VERSION
filepackage.json
internal/version/version.go
-
Update the CHANGELOG.md file with the new version and its changes.
-
Create a new tag:
git tag -a v1.2.3 -m "Release v1.2.3"
git push origin v1.2.3
- The CI/CD pipeline will build and publish the release artifacts.
Getting Help
If you need help with contributing to GoMFT, you can:
- Open an issue on GitHub with questions
- Discuss in the GitHub Discussions section
- Reach out to the maintainers
Thank you for contributing to GoMFT!