This is a starter kit for building a Go-based portfolio website. It uses the Gin web framework and Viper for configuration management. The project is structured to promote clean code and scalability.
go-starter-kit/
├── cmd/
│ └── myapp/
│ └── main.go
├── pkg/
│ ├── config/
│ │ └── config.go
│ ├── logger/
│ │ └── logger.go
│ ├── server/
│ │ └── server.go
├── templates/
│ ├── base.html
│ ├── home.html
│ ├── about.html
│ ├── education.html
│ ├── skills.html
│ ├── experience.html
│ ├── contact.html
├── assets/
│ ├── css/
│ │ └── style.css
│ └── js/
│ └── script.js
├── .gitignore
├── README.md
├── LICENSE
├── go.mod
├── go.sum
└── config.yaml
- Clone the repository:
git clone https://github.com/jmrashed/go-starter-kit.git
cd go-starter-kit
- Install dependencies:
go mod tidy
Ensure you have a config.yaml
file in the root directory of the project with the following content:
server_address: ":8080"
Navigate to the project root directory and run:
go run cmd/myapp/main.go
The application will start, and you can access it at http://localhost:8080
.
The entry point of the application. It initializes the configuration, logger, and server.
Handles the configuration using Viper. Loads settings from config.yaml
.
Sets up logging for the application.
Configures the Gin router, sets up routes, and serves static files and templates.
Contains HTML templates for the application. The default template is index.html
.
Contains static assets like CSS and JavaScript files.
An example HTML file located in the templates
directory:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>{{ .title }}</title>
<link rel="stylesheet" href="/assets/css/tailwind.css">
</head>
<body>
<h1>{{ .title }}</h1>
<p>Welcome to my portfolio!</p>
</body>
</html>
An example configuration file located in the root directory:
server_address: ":8080"
To run the application in development mode:
- Ensure Go is installed and your environment is set up.
- Navigate to the root directory of the project.
- Run the application using
go run cmd/myapp/main.go
.
To build the application for production:
- Build the binary:
go build -o bin/myapp cmd/myapp/main.go
- Run the binary:
./bin/myapp
Contributions are welcome! Please submit a pull request or open an issue for any changes or additions.
This project is licensed under the MIT License. See the LICENSE file for details.
- Overview: A brief introduction to the project.
- Project Structure: A visual representation of the directory structure.
- Getting Started: Instructions for cloning the repository, installing dependencies, and running the application.
- Configuration: Details on how to set up the configuration file.
- Running the Application: Step-by-step instructions on running the project.
- Project Details: Information about the key directories and files in the project.
- Development: Instructions for running the application in development mode.
- Deployment: Steps to build and run the application for production.
- Contributing: Guidelines for contributing to the project.
- License: Licensing information.
- Acknowledgements: Credits to the libraries and frameworks used in the project.