This commit is contained in:
Dawid Wysokiński 2022-05-26 06:28:59 +02:00
commit a6425232ec
Signed by: Kichiyaki
GPG Key ID: 1ECC5DE481BE5184
7 changed files with 170 additions and 0 deletions

54
.github/workflows/pr.yml vendored Normal file
View File

@ -0,0 +1,54 @@
name: PR checks
on:
push:
branches:
- master
pull_request:
env:
GO_VERSION: 1.18.x
jobs:
go-mod:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Install Go
uses: actions/setup-go@v3
with:
go-version: ${{ env.GO_VERSION }}
- name: Check go mod
run: |
go mod tidy
git diff --exit-code go.mod
golangci-lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Install Go
uses: actions/setup-go@v3
with:
go-version: ${{ env.GO_VERSION }}
- name: Run golangci-lint
uses: golangci/golangci-lint-action@v3
with:
version: v1.46
tests:
strategy:
matrix:
go: [ 1.18.x ]
platform: [ ubuntu-latest ]
runs-on: ${{ matrix.platform }}
steps:
- uses: actions/checkout@v3
- name: Install Go
uses: actions/setup-go@v3
with:
go-version: ${{ matrix.go }}
- name: Run go vet
run: go vet ./...
- name: Run go build
run: go build
- name: Run tests
run: go test -race -coverprofile=coverage.txt -covermode=atomic ./...

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
.idea

44
.golangci.yml Normal file
View File

@ -0,0 +1,44 @@
run:
tests: true
linters:
disable-all: true
enable:
- bodyclose
- deadcode
- depguard
- dupl
- errcheck
- gocritic
- gofmt
- goimports
- gosimple
- govet
- ineffassign
- misspell
- nakedret
- prealloc
- staticcheck
- structcheck
- typecheck
- unconvert
- unused
- varcheck
- lll
- nestif
- thelper
- nonamedreturns
linters-settings:
lll:
line-length: 150
issues:
exclude-rules:
# Exclude some linters from running on tests files.
- path: _test\.go
linters:
- dupl
- linters:
- lll
source: "^//go:generate "

21
LICENSE Normal file
View File

@ -0,0 +1,21 @@
The MIT License (MIT)
Copyright (c) 2022 Dawid Wysokiński
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

3
go.mod Normal file
View File

@ -0,0 +1,3 @@
module github.com/Kichiyaki/lubimyczytacrss
go 1.18

40
main.go Normal file
View File

@ -0,0 +1,40 @@
package main
import (
"context"
"log"
"net/http"
"os"
"os/signal"
"time"
)
func main() {
httpSrv := &http.Server{
Addr: ":9234",
Handler: nil,
ReadTimeout: 2 * time.Second,
ReadHeaderTimeout: 2 * time.Second,
WriteTimeout: 2 * time.Second,
IdleTimeout: 2 * time.Second,
}
go func(httpSrv *http.Server) {
if err := httpSrv.ListenAndServe(); err != nil && err != http.ErrServerClosed {
log.Fatalln("httpSrv.ListenAndServe:", err)
}
}(httpSrv)
log.Println("Server is listening on the port 9234")
ctxSignal, stop := signal.NotifyContext(context.Background(), os.Interrupt)
defer stop()
<-ctxSignal.Done()
ctxShutdown, cancelCtxShutdown := context.WithTimeout(context.Background(), 10*time.Second)
defer cancelCtxShutdown()
if err := httpSrv.Shutdown(ctxShutdown); err != nil {
log.Fatalln("httpSrv.Shutdown:", err)
}
}

7
renovate.json Normal file
View File

@ -0,0 +1,7 @@
{
"extends": [
"config:base",
":semanticCommits",
":semanticCommitTypeAll(chore)"
]
}