Skip to content
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
58 changes: 58 additions & 0 deletions .github/workflows/golangci-lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
name: golangci-lint

on:
push:
tags:
- v*
branches:
- main
pull_request:

permissions:
contents: read
# Optional: allow read access to pull request. Use with `only-new-issues` option.
# pull-requests: read

jobs:
golangci:
name: lint
runs-on: ubuntu-latest
strategy:
matrix:
go: ['1.19', '1.20']
steps:
- uses: actions/setup-go@v3
with:
go-version: ${{ matrix.go }}
- uses: actions/checkout@v3

- name: Format
run: go fmt

- name: Vet
run: go vet

- name: lint
uses: golangci/golangci-lint-action@v3
#with:
# Optional: version of golangci-lint to use in form of v1.2 or v1.2.3 or `latest` to use the latest version
#version: v1.29

# Optional: working directory, useful for monorepos
# working-directory: somedir

# Optional: golangci-lint command line arguments.
# args: --issues-exit-code=0

# Optional: show only new issues if it's a pull request. The default value is `false`.
# only-new-issues: true

# Optional: if set to true then the all caching functionality will be complete disabled,
# takes precedence over all other caching options.
# skip-cache: true

# Optional: if set to true then the action don't cache or restore ~/go/pkg.
# skip-pkg-cache: true

# Optional: if set to true then the action don't cache or restore ~/.cache/go-build.
# skip-build-cache: true
15 changes: 15 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: release

on:
push:
tags:
- "v*.*.*"

jobs:
release:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Release
uses: softprops/action-gh-release@v1
34 changes: 18 additions & 16 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,37 +5,39 @@ on:
push:

jobs:
build:
name: Build
test:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
go: ['1.19', '1.20']
steps:
- uses: actions/checkout@v2
- name: Set up Go
uses: actions/setup-go@v2
- uses: actions/setup-go@v3
with:
go-version: ${{ matrix.go }}

- name: Check out code into the Go module directory
uses: actions/checkout@v1
- uses: actions/checkout@v3

- name: Get dependencies
run: |
go get golang.org/x/tools/cmd/cover
go get github.com/mattn/goveralls

- name: Format
run: go fmt

- name: Vet
run: go vet

- name: Test
run: go test -race -v -covermode=atomic -coverprofile=coverage.out

- name: actions-goveralls
uses: shogo82148/actions-goveralls@v1.2.2
- name: Send coverage
uses: shogo82148/actions-goveralls@v1
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
path-to-profile: coverage.out
flag-name: Go-${{ matrix.go }}
parallel: true

# notifies that all test jobs are finished.
finish:
needs: test
runs-on: ubuntu-latest
steps:
- uses: shogo82148/actions-goveralls@v1
with:
parallel-finished: true
8 changes: 6 additions & 2 deletions protocol.go
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,9 @@ func (p *Conn) readHeader() error {
// run on the connection, as we don't want to override the previous
// read deadline the user may have used.
if p.readHeaderTimeout > 0 {
p.conn.SetReadDeadline(time.Now().Add(p.readHeaderTimeout))
if err := p.conn.SetReadDeadline(time.Now().Add(p.readHeaderTimeout)); err != nil {
return err
}
}

header, err := Read(p.bufReader)
Expand All @@ -259,7 +261,9 @@ func (p *Conn) readHeader() error {
if t == nil {
t = time.Time{}
}
p.conn.SetReadDeadline(t.(time.Time))
if err := p.conn.SetReadDeadline(t.(time.Time)); err != nil {
return err
}
if netErr, ok := err.(net.Error); ok && netErr.Timeout() {
err = ErrNoProxyProtocol
}
Expand Down
Loading