Skip to content

Commit 8659386

Browse files
committed
feat: add go template
1 parent 9730ac4 commit 8659386

12 files changed

+195
-84
lines changed

.github/workflows/build.yml

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
name: Build template
2+
3+
on: [push]
4+
5+
jobs:
6+
build:
7+
runs-on: ubuntu-latest
8+
steps:
9+
- uses: actions/checkout@v4
10+
11+
- name: Build docker image
12+
run: docker compose build
13+
14+
- name: Run docker container
15+
run: docker compose up -d
16+
17+
- name: Test if service is reachable
18+
run: |
19+
sleep 30
20+
curl -v -s --retry 10 --retry-connrefused http://localhost:8000/
21+
22+
- name: Report error to Sentry
23+
if: failure()
24+
run: |
25+
curl -sL https://sentry.io/get-cli/ | bash
26+
export SENTRY_DSN=${{ secrets.SENTRY_DSN }}
27+
MESSAGE_HEAD='Template: "${{ github.workflow }}" failed in ${{ github.repository }}.'
28+
MESSAGE_BODY='Check <https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}> for more details.'
29+
sentry-cli send-event -m "$MESSAGE_HEAD" -m "$MESSAGE_BODY" --log-level=error

.github/workflows/deploy.yml

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
name: Deploy template
2+
3+
on:
4+
push:
5+
schedule:
6+
- cron: "50 16 * * *"
7+
8+
jobs:
9+
build:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- uses: actions/checkout@v4
13+
14+
- name: Set up Python
15+
uses: actions/setup-python@v5
16+
with:
17+
python-version: "3.12"
18+
19+
- name: Install dependencies
20+
run: |
21+
python -m pip install --upgrade pip
22+
pip install divio-cli
23+
24+
- name: Deploy to Divio
25+
run: |
26+
divio login ${{ secrets.DIVIO_TOKEN }}
27+
divio app deploy test --remote-id ${{ secrets.DIVIO_WEBSITE_ID }} --build-mode FORCE
28+
29+
- name: Test if website is reachable
30+
run: |
31+
curl -v -s --retry 10 --retry-connrefused ${{ secrets.WEBSITE_URL }}
32+
33+
- name: Report error to Sentry
34+
if: failure()
35+
run: |
36+
curl -sL https://sentry.io/get-cli/ | bash
37+
export SENTRY_DSN=${{ secrets.SENTRY_DSN }}
38+
MESSAGE_HEAD='Template: "${{ github.workflow }}" failed in ${{ github.repository }}.'
39+
MESSAGE_BODY='Check <https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}> for more details.'
40+
sentry-cli send-event -m "$MESSAGE_HEAD" -m "$MESSAGE_BODY" --log-level=error

CODE_OF_CONDUCT.md

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# Code of Conduct
2+
3+
## Welcome to Our Open-Source Community
4+
5+
This collaborative project strives to create an inclusive and welcoming environment. We value all contributors' and participants' interactions that reflect courtesy, respect, and kindness.
6+
7+
We have a zero-tolerance policy for any form of abuse or harassment.
8+
9+
If you have concerns about behaviour, please reach out to Divio at [email protected].
10+
11+
Reports will be treated confidentially and taken seriously. The project maintainers may take appropriate action, including exclusion from participation in this and other projects, if necessary.
12+
13+
## Guidelines for Code Review
14+
15+
Code review is a crucial but sometimes challenging process for contributors and reviewers. It involves constructive critique, and improvements are often needed before accepting contributions.
16+
17+
We expect contributors to recognize that all aspects of their submissions, including code and underlying ideas, will be carefully reviewed.
18+
19+
Reviewers are encouraged to provide feedback sensitively and respectfully, aligning with our shared goal for the project's success.

CONTRIBUTING.md

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# Contributing to the Project
2+
3+
Thank you for contributing! We appreciate your involvement in making this project better. Before you start, please familiarize yourself with our [Code of Conduct](./CODE_OF_CONDUCT.md).
4+
5+
## Submitting Proposals
6+
7+
Proposals can be submitted through:
8+
9+
- [Pull Requests](https://github.com/divio/getting-started-with-go/pulls)
10+
- [Issues](https://github.com/divio/getting-started-with-go/issues)
11+
12+
## Pull Requests and Branches
13+
14+
When making pull requests, adhere to the following:
15+
16+
- Submit from a properly named new branch.
17+
- Target the `main` branch.
18+
19+
Learn more:
20+
21+
- [How to make pull requests](https://help.github.com/articles/using-pull-requests/)
22+
- [Managing branches](https://help.github.com/articles/creating-and-deleting-branches-within-your-repository/)
23+
24+
### Whitespace
25+
26+
Avoid trailing whitespace (spaces or tabs at the end of a line). They might be invisible and lead to silent issues or unexpected changes. Some editors may silently delete them by default.

Dockerfile

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
FROM golang:1.22.2
2+
3+
WORKDIR /app
4+
5+
COPY go.mod go.sum /app/
6+
RUN go mod download
7+
8+
COPY . /app
9+
10+
RUN CGO_ENABLED=0 GOOS=linux go build main.go
11+
12+
EXPOSE 80
13+
14+
CMD ["./main"]

LICENSE

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
Copyright (c) 2024, Divio AG
2+
All rights reserved.
3+
4+
Redistribution and use in source and binary forms, with or without
5+
modification, are permitted provided that the following conditions are met:
6+
* Redistributions of source code must retain the above copyright
7+
notice, this list of conditions and the following disclaimer.
8+
* Redistributions in binary form must reproduce the above copyright
9+
notice, this list of conditions and the following disclaimer in the
10+
documentation and/or other materials provided with the distribution.
11+
* Neither the name of Divio AG nor the
12+
names of its contributors may be used to endorse or promote products
13+
derived from this software without specific prior written permission.
14+
15+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
16+
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
17+
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
18+
DISCLAIMED. IN NO EVENT SHALL DIVIO AG BE LIABLE FOR ANY DIRECT, INDIRECT,
19+
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
20+
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
21+
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
22+
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
23+
OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
24+
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

README.md

+14-84
Original file line numberDiff line numberDiff line change
@@ -1,93 +1,23 @@
1-
# getting-started-with-go
1+
# Getting Started with Go
22

3+
[![Deploy to Divio](https://img.shields.io/badge/DEPLOY-TO%20DIVIO-DFFF67?logo=docker&logoColor=white&labelColor=333333)](https://control.divio.com/app/new/?template_url=https://github.com/divio/getting-started-with-go/archive/refs/heads/main.zip)
34

5+
Welcome to our QuickStart template – your portal to swift application development and seamless local testing. Whether you're delving into Go for the first time or optimizing your workflow, our template, based on Go's [Writing Web Applications Guide](https://go.dev/doc/articles/wiki/), has got you covered.
46

5-
## Getting started
7+
## Cloud Setup
68

7-
To make it easy for you to get started with GitLab, here's a list of recommended next steps.
9+
Create a [Divio Account](https://control.divio.com/) and choose **Go** from the template selection when creating a new application. Alternatively, click the `Deploy to Divio` button above and follow the app creation wizard. Finally, deploy your app to the `test` or `live` environment.
810

9-
Already a pro? Just edit this README.md and make it your own. Want to make it easy? [Use the template at the bottom](#editing-this-readme)!
11+
For in-depth details about Divio Cloud, refer to the [Divio documentation](https://docs.divio.com/introduction/).
1012

11-
## Add your files
13+
## Local Setup
1214

13-
- [ ] [Create](https://docs.gitlab.com/ee/user/project/repository/web_editor.html#create-a-file) or [upload](https://docs.gitlab.com/ee/user/project/repository/web_editor.html#upload-a-file) files
14-
- [ ] [Add files using the command line](https://docs.gitlab.com/ee/gitlab-basics/add-file.html#add-a-file-using-the-command-line) or push an existing Git repository with the following command:
15+
Install the [Divio CLI](https://github.com/divio/divio-cli) to set up your app locally.
1516

16-
```
17-
cd existing_repo
18-
git remote add origin https://gitlab.com/divio/templates/getting-started-with-go.git
19-
git branch -M main
20-
git push -uf origin main
21-
```
17+
Alternatively, build this app locally using Docker:
2218

23-
## Integrate with your tools
24-
25-
- [ ] [Set up project integrations](https://gitlab.com/divio/templates/getting-started-with-go/-/settings/integrations)
26-
27-
## Collaborate with your team
28-
29-
- [ ] [Invite team members and collaborators](https://docs.gitlab.com/ee/user/project/members/)
30-
- [ ] [Create a new merge request](https://docs.gitlab.com/ee/user/project/merge_requests/creating_merge_requests.html)
31-
- [ ] [Automatically close issues from merge requests](https://docs.gitlab.com/ee/user/project/issues/managing_issues.html#closing-issues-automatically)
32-
- [ ] [Enable merge request approvals](https://docs.gitlab.com/ee/user/project/merge_requests/approvals/)
33-
- [ ] [Set auto-merge](https://docs.gitlab.com/ee/user/project/merge_requests/merge_when_pipeline_succeeds.html)
34-
35-
## Test and Deploy
36-
37-
Use the built-in continuous integration in GitLab.
38-
39-
- [ ] [Get started with GitLab CI/CD](https://docs.gitlab.com/ee/ci/quick_start/index.html)
40-
- [ ] [Analyze your code for known vulnerabilities with Static Application Security Testing (SAST)](https://docs.gitlab.com/ee/user/application_security/sast/)
41-
- [ ] [Deploy to Kubernetes, Amazon EC2, or Amazon ECS using Auto Deploy](https://docs.gitlab.com/ee/topics/autodevops/requirements.html)
42-
- [ ] [Use pull-based deployments for improved Kubernetes management](https://docs.gitlab.com/ee/user/clusters/agent/)
43-
- [ ] [Set up protected environments](https://docs.gitlab.com/ee/ci/environments/protected_environments.html)
44-
45-
***
46-
47-
# Editing this README
48-
49-
When you're ready to make this README your own, just edit this file and use the handy template below (or feel free to structure it however you want - this is just a starting point!). Thanks to [makeareadme.com](https://www.makeareadme.com/) for this template.
50-
51-
## Suggestions for a good README
52-
53-
Every project is different, so consider which of these sections apply to yours. The sections used in the template are suggestions for most open source projects. Also keep in mind that while a README can be too long and detailed, too long is better than too short. If you think your README is too long, consider utilizing another form of documentation rather than cutting out information.
54-
55-
## Name
56-
Choose a self-explaining name for your project.
57-
58-
## Description
59-
Let people know what your project can do specifically. Provide context and add a link to any reference visitors might be unfamiliar with. A list of Features or a Background subsection can also be added here. If there are alternatives to your project, this is a good place to list differentiating factors.
60-
61-
## Badges
62-
On some READMEs, you may see small images that convey metadata, such as whether or not all the tests are passing for the project. You can use Shields to add some to your README. Many services also have instructions for adding a badge.
63-
64-
## Visuals
65-
Depending on what you are making, it can be a good idea to include screenshots or even a video (you'll frequently see GIFs rather than actual videos). Tools like ttygif can help, but check out Asciinema for a more sophisticated method.
66-
67-
## Installation
68-
Within a particular ecosystem, there may be a common way of installing things, such as using Yarn, NuGet, or Homebrew. However, consider the possibility that whoever is reading your README is a novice and would like more guidance. Listing specific steps helps remove ambiguity and gets people to using your project as quickly as possible. If it only runs in a specific context like a particular programming language version or operating system or has dependencies that have to be installed manually, also add a Requirements subsection.
69-
70-
## Usage
71-
Use examples liberally, and show the expected output if you can. It's helpful to have inline the smallest example of usage that you can demonstrate, while providing links to more sophisticated examples if they are too long to reasonably include in the README.
72-
73-
## Support
74-
Tell people where they can go to for help. It can be any combination of an issue tracker, a chat room, an email address, etc.
75-
76-
## Roadmap
77-
If you have ideas for releases in the future, it is a good idea to list them in the README.
78-
79-
## Contributing
80-
State if you are open to contributions and what your requirements are for accepting them.
81-
82-
For people who want to make changes to your project, it's helpful to have some documentation on how to get started. Perhaps there is a script that they should run or some environment variables that they need to set. Make these steps explicit. These instructions could also be useful to your future self.
83-
84-
You can also document commands to lint the code or run tests. These steps help to ensure high code quality and reduce the likelihood that the changes inadvertently break something. Having instructions for running tests is especially helpful if it requires external setup, such as starting a Selenium server for testing in a browser.
85-
86-
## Authors and acknowledgment
87-
Show your appreciation to those who have contributed to the project.
88-
89-
## License
90-
For open source projects, say how it is licensed.
91-
92-
## Project status
93-
If you have run out of energy or time for your project, put a note at the top of the README saying that development has slowed down or stopped completely. Someone may choose to fork your project or volunteer to step in as a maintainer or owner, allowing your project to keep going. You can also make an explicit request for maintainers.
19+
1. Ensure [Docker](https://docs.docker.com/get-docker/) is installed and running.
20+
2. Clone this repository locally.
21+
3. Build the app with `docker compose build`.
22+
4. Run the app using `docker compose up`.
23+
5. Open [http://localhost:8000]() to view your app.

docker-compose.yml

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
version: "3"
2+
3+
services:
4+
web:
5+
build: .
6+
ports:
7+
- "8000:80"
8+
volumes:
9+
- ".:/app:rw"
10+
- "./data:/data:rw"

go.mod

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
module getting-started-with-go
2+
3+
go 1.22.2

go.sum

Whitespace-only changes.

main

6.56 MB
Binary file not shown.

main.go

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
package main
2+
3+
import (
4+
"fmt"
5+
"log"
6+
"net/http"
7+
)
8+
9+
func handler(w http.ResponseWriter, r *http.Request) {
10+
fmt.Fprintf(w, "Hi there, I love %s!", r.URL.Path[1:])
11+
}
12+
13+
func main() {
14+
http.HandleFunc("/", handler)
15+
log.Fatal(http.ListenAndServe(":80", nil))
16+
}

0 commit comments

Comments
 (0)