A skeleton repository for starting new Go applications with recommended structure and tooling.
-
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" ] }
-
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
├── 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
- 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
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.
- Fork the repository
- Create your feature branch
- Commit your changes
- Push to the branch
- Create a Pull Request
Refer to CONTRIBUTING for more information.
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.