Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: create module and bump to go 1.21 #1

Merged
merged 1 commit into from
Jun 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Default owner
* @MolotovTv/backend
11 changes: 11 additions & 0 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
## Description
> A clear and concise description of what changes you did.

## Jira issue
> Link to the Jira issue.

## Depends on
> Link to other pull requests.

## Jira Story
> Description from Jira
42 changes: 42 additions & 0 deletions .github/workflows/ci_pr_checks.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: PR checks

on:
pull_request:
branches:
- master
types:
- opened
- reopened
- synchronize
- ready_for_review

concurrency:
group: ${{ github.workflow }}-${{ github.head_ref }}
cancel-in-progress: true

jobs:
tests:
name: Tests
runs-on: ubuntu-latest
if: always() && !github.event.pull_request.draft
env:
GOPRIVATE: github.com/molotovtv
GH_ACCESS_TOKEN: ${{ secrets.GH_TOKEN }}

steps:
- name: ⭐️ Checkout
uses: actions/checkout@v4

- name: Setup Go 1.21
uses: actions/setup-go@v5
with:
go-version: 1.21

- run: git config --global url.https://[email protected]/.insteadOf https://github.com/

- name: Install dependencies
run: go get ./...

- name: ✅ Tests
run: |
go test ./...
11 changes: 11 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
module github.com/molotovtv/go-slack

go 1.21

require github.com/stretchr/testify v1.9.0

require (
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
10 changes: 10 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg=
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
10 changes: 5 additions & 5 deletions http.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ package slack
import (
"bytes"
"fmt"
"io/ioutil"
"io"
"net"
"net/http"
"time"
)

// Send sends an http request with a timeout
// Send sends a http request with a timeout
var Send = func(req *http.Request, httpClient *http.Client) (*http.Response, error) {
return httpClient.Do(req)
}
Expand Down Expand Up @@ -53,7 +53,7 @@ func (s *Slack) SendWithMaxRetries(hostname string, pattern string, method strin
// Get body
if resp != nil {
defer resp.Body.Close()
if _, err = ioutil.ReadAll(resp.Body); err != nil {
if _, err = io.ReadAll(resp.Body); err != nil {
return
}
}
Expand All @@ -70,14 +70,14 @@ func (s *Slack) SendWithMaxRetries(hostname string, pattern string, method strin
}

// Max retries limit reached
err = fmt.Errorf("Max retries %d reached for request to %s", s.RetryMax, req.URL)
err = fmt.Errorf("max retries %d reached for request to %s", s.RetryMax, req.URL)
return
}

// ProcessResponse processes an HTTP response
var ProcessResponse = func(req *http.Request, resp *http.Response) error {
if resp.StatusCode < 200 || resp.StatusCode > 299 {
return fmt.Errorf("Invalid status code %v on %v", resp.StatusCode, req.URL)
return fmt.Errorf("invalid status code %v on %v", resp.StatusCode, req.URL)
}
return nil
}