Skip to content

Build scalable web apps with the Go Boilerplate. This monorepo features a Go backend, TypeScript frontend, and modern tools for efficient development. πŸš€πŸŒ

Notifications You must be signed in to change notification settings

devdevalex/go-boilerplate

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

1 Commit
Β 
Β 

Repository files navigation

Go Boilerplate: A Production-Grade Template for Go Applications πŸš€

Latest Release License


Table of Contents


Features

  • Production-Ready: This boilerplate is designed for production environments.
  • Modular Structure: Organize your code into modules for better maintainability.
  • Configuration Management: Easily manage your configurations with environment variables.
  • Testing Framework: Built-in support for unit tests to ensure code quality.
  • Logging: Integrated logging for better debugging and monitoring.
  • Docker Support: Ready-to-use Docker configuration for containerization.

Getting Started

To get started with this boilerplate, you can download the latest release from the Releases section.

After downloading, follow these steps to set up your environment:

  1. Install Go: Ensure you have Go installed on your machine. You can download it from golang.org.
  2. Clone the Repository: Use the following command to clone the repository:
    git clone https://github.com/devdevalex/go-boilerplate.git
  3. Navigate to the Project Directory:
    cd go-boilerplate
  4. Run the Application: You can run the application using:
    go run main.go

Project Structure

The project structure is designed to be clean and easy to navigate. Here’s a breakdown:

go-boilerplate/
β”œβ”€β”€ cmd/                # Command line applications
β”œβ”€β”€ internal/           # Private application and library code
β”œβ”€β”€ pkg/               # Public library code
β”œβ”€β”€ configs/           # Configuration files
β”œβ”€β”€ scripts/           # Scripts for automation
β”œβ”€β”€ tests/             # Unit and integration tests
└── README.md          # Project documentation

Directory Descriptions

  • cmd/: Contains the entry points for your application.
  • internal/: Holds code that is not meant to be used by other applications.
  • pkg/: Contains code that can be used by other applications.
  • configs/: Store configuration files in this directory.
  • scripts/: Useful scripts for automation tasks.
  • tests/: All tests for your application.

Configuration

This boilerplate supports configuration through environment variables. You can create a .env file in the root directory to manage your configurations easily.

Example .env File

DATABASE_URL=your_database_url
PORT=8080
LOG_LEVEL=info

Make sure to load these environment variables in your application using a package like godotenv.


Testing

Testing is crucial for maintaining code quality. This boilerplate includes a testing framework using Go’s built-in testing package.

Running Tests

To run tests, use the following command:

go test ./...

You can also run tests with coverage:

go test -cover ./...

Writing Tests

Tests should be placed in the same directory as the code they test, with the filename ending in _test.go.

package yourpackage

import "testing"

func TestYourFunction(t *testing.T) {
    // Your test logic here
}

Deployment

For deployment, this boilerplate includes a Dockerfile to help you containerize your application.

Building the Docker Image

To build the Docker image, run:

docker build -t your-image-name .

Running the Docker Container

You can run your Docker container using:

docker run -p 8080:8080 your-image-name

Contributing

We welcome contributions to this project. If you would like to contribute, please follow these steps:

  1. Fork the repository.
  2. Create a new branch (git checkout -b feature/YourFeature).
  3. Make your changes and commit them (git commit -m 'Add new feature').
  4. Push to the branch (git push origin feature/YourFeature).
  5. Open a pull request.

Please ensure that your code follows the existing style and includes tests.


License

This project is licensed under the MIT License. See the LICENSE file for details.


Contact

For questions or feedback, feel free to reach out:


For more information and to download the latest release, visit the Releases section.

Make sure to check the Releases section for updates and new features.

About

Build scalable web apps with the Go Boilerplate. This monorepo features a Go backend, TypeScript frontend, and modern tools for efficient development. πŸš€πŸŒ

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published