Base Golang App Repository

A skeleton repository for starting new Go applications with recommended structure and tooling.
Getting Started
-
Clone this repository:
git clone https://github.com/hyp3rd/go-base-app-skel.git your-new-project
-
Remove the existing .git folder and initialize a new repository and your go module:
cd your-new-project
rm -rf .git
git init
go mod init github.com/your-org/your-new-project
-
Install VS Code Extensions Recommended (optional):
{
"recommendations": [
"github.vscode-github-actions",
"golang.go",
"ms-vscode.makefile-tools",
"esbenp.prettier-vscode",
"pbkit.vscode-pbkit",
"trunk.io",
"streetsidesoftware.code-spell-checker",
"ms-azuretools.vscode-docker",
"eamodio.gitlens"
]
}
Development Setup
-
Install Golang.
-
Install Docker.
-
Install GitVersion.
-
Install Make, follow the procedure for your OS.
-
Set up the toolchain:
make prepare-toolchain
-
Initialize pre-commit (strongly recommended to create a virtual env, using for instance PyEnv) and its hooks:
pip install pre-commit
pre-commit install
pre-commit install-hooks
Project Structure
├── cmd/ # Main applications
│ └── app/ # Your application
│ └── main.go # Application entry point
├── internal/ # Private code
│ ├── pkg/ # Internal packages
│ └── app/ # Application specific code
├── pkg/ # Public libraries
├── api/ # API contracts (proto files, OpenAPI specs)
├── configs/ # Configuration files
├── scripts/ # Scripts for development
├── test/ # Additional test files
└── docs/ # Documentation
Best Practices
- Follow the Go Code Review Comments
- Run
golangci-lint before committing code
- Ensure the pre-commit hooks pass
- Write tests for new functionality
- Keep packages small and focused
- Use meaningful package names
- Document exported functions and types
Available Make Commands
make test: Run tests.
make update-deps: Update all dependencies in the project.
make prepare-toolchain: Install all tools required to build the project.
make lint: Run the staticcheck and golangci-lint static analysis tools on all packages in the project.
make run: Build and run the application in Docker.
License
MIT License
Contributing
- Fork the repository
- Create your feature branch
- Commit your changes
- Push to the branch
- Create a Pull Request
Refer to CONTRIBUTING for more information.
Author
I'm a surfer, and a software architect with 15 years of experience designing highly available distributed production systems and developing cloud-native apps in public and private clouds. Feel free to connect with me on LinkedIn.
