mirror of
https://github.com/gin-gonic/gin.git
synced 2025-10-16 21:32:11 +08:00
Merge remote-tracking branch 'upstream/master'
This commit is contained in:
commit
5c4c256d13
2
.github/PULL_REQUEST_TEMPLATE.md
vendored
2
.github/PULL_REQUEST_TEMPLATE.md
vendored
@ -1,7 +1,7 @@
|
|||||||
- With pull requests:
|
- With pull requests:
|
||||||
- Open your pull request against `master`
|
- Open your pull request against `master`
|
||||||
- Your pull request should have no more than two commits, if not you should squash them.
|
- Your pull request should have no more than two commits, if not you should squash them.
|
||||||
- It should pass all tests in the available continuous integration systems such as TravisCI.
|
- It should pass all tests in the available continuous integration systems such as GitHub Actions.
|
||||||
- You should add/modify tests to cover your proposed code changes.
|
- You should add/modify tests to cover your proposed code changes.
|
||||||
- If your pull request contains a new feature, please document it on the README.
|
- If your pull request contains a new feature, please document it on the README.
|
||||||
|
|
||||||
|
62
.github/workflows/gin.yml
vendored
Normal file
62
.github/workflows/gin.yml
vendored
Normal file
@ -0,0 +1,62 @@
|
|||||||
|
name: Run Tests
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- master
|
||||||
|
pull_request:
|
||||||
|
branches:
|
||||||
|
- master
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
test:
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
os: [ubuntu-latest, macos-latest]
|
||||||
|
go: [1.13, 1.14, 1.15, 1.16]
|
||||||
|
test-tags: ['', nomsgpack]
|
||||||
|
name: ${{ matrix.os }} @ Go ${{ matrix.go }} ${{ matrix.test-tags }}
|
||||||
|
runs-on: ${{ matrix.os }}
|
||||||
|
env:
|
||||||
|
GO111MODULE: on
|
||||||
|
TESTTAGS: ${{ matrix.test-tags }}
|
||||||
|
GOPROXY: https://proxy.golang.org
|
||||||
|
steps:
|
||||||
|
- name: Set up Go ${{ matrix.go }}
|
||||||
|
uses: actions/setup-go@v2
|
||||||
|
with:
|
||||||
|
go-version: ${{ matrix.go }}
|
||||||
|
|
||||||
|
- name: Checkout Code
|
||||||
|
uses: actions/checkout@v2
|
||||||
|
with:
|
||||||
|
ref: ${{ github.ref }}
|
||||||
|
|
||||||
|
- name: Install Dependencies
|
||||||
|
run: make tools
|
||||||
|
|
||||||
|
- name: Run Check
|
||||||
|
run: |
|
||||||
|
make vet
|
||||||
|
make fmt-check
|
||||||
|
make misspell-check
|
||||||
|
|
||||||
|
- name: Run Tests
|
||||||
|
run: make test
|
||||||
|
|
||||||
|
- name: Upload coverage to Codecov
|
||||||
|
uses: codecov/codecov-action@v1
|
||||||
|
notification-gitter:
|
||||||
|
needs: test
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Notification failure message
|
||||||
|
if: failure()
|
||||||
|
run: |
|
||||||
|
PR_OR_COMPARE="$(if [ "${{ github.event.pull_request }}" != "" ]; then echo "${{ github.event.pull_request.html_url }}"; else echo "${{ github.event.compare }}"; fi)"
|
||||||
|
curl -d message="GitHub Actions [$GITHUB_REPOSITORY]($PR_OR_COMPARE) ($GITHUB_REF) [normal]($GITHUB_API_URL/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID) ($GITHUB_RUN_NUMBER)" -d level=error https://webhooks.gitter.im/e/7f95bf605c4d356372f4
|
||||||
|
- name: Notification success message
|
||||||
|
if: success()
|
||||||
|
run: |
|
||||||
|
PR_OR_COMPARE="$(if [ "${{ github.event.pull_request }}" != "" ]; then echo "${{ github.event.pull_request.html_url }}"; else echo "${{ github.event.compare }}"; fi)"
|
||||||
|
curl -d message="GitHub Actions [$GITHUB_REPOSITORY]($PR_OR_COMPARE) ($GITHUB_REF) [normal]($GITHUB_API_URL/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID) ($GITHUB_RUN_NUMBER)" https://webhooks.gitter.im/e/7f95bf605c4d356372f4
|
52
.travis.yml
52
.travis.yml
@ -1,52 +0,0 @@
|
|||||||
language: go
|
|
||||||
|
|
||||||
matrix:
|
|
||||||
fast_finish: true
|
|
||||||
include:
|
|
||||||
- go: 1.13.x
|
|
||||||
- go: 1.13.x
|
|
||||||
env:
|
|
||||||
- TESTTAGS=nomsgpack
|
|
||||||
- go: 1.14.x
|
|
||||||
- go: 1.14.x
|
|
||||||
env:
|
|
||||||
- TESTTAGS=nomsgpack
|
|
||||||
- go: 1.15.x
|
|
||||||
- go: 1.15.x
|
|
||||||
env:
|
|
||||||
- TESTTAGS=nomsgpack
|
|
||||||
- go: 1.16.x
|
|
||||||
- go: 1.16.x
|
|
||||||
env:
|
|
||||||
- TESTTAGS=nomsgpack
|
|
||||||
- go: master
|
|
||||||
|
|
||||||
git:
|
|
||||||
depth: 10
|
|
||||||
|
|
||||||
before_install:
|
|
||||||
- if [[ "${GO111MODULE}" = "on" ]]; then mkdir "${HOME}/go"; export GOPATH="${HOME}/go"; fi
|
|
||||||
|
|
||||||
install:
|
|
||||||
- if [[ "${GO111MODULE}" = "on" ]]; then go mod download; fi
|
|
||||||
- if [[ "${GO111MODULE}" = "on" ]]; then export PATH="${GOPATH}/bin:${GOROOT}/bin:${PATH}"; fi
|
|
||||||
- if [[ "${GO111MODULE}" = "on" ]]; then make tools; fi
|
|
||||||
|
|
||||||
go_import_path: github.com/gin-gonic/gin
|
|
||||||
|
|
||||||
script:
|
|
||||||
- make vet
|
|
||||||
- make fmt-check
|
|
||||||
- make misspell-check
|
|
||||||
- make test
|
|
||||||
|
|
||||||
after_success:
|
|
||||||
- bash <(curl -s https://codecov.io/bash)
|
|
||||||
|
|
||||||
notifications:
|
|
||||||
webhooks:
|
|
||||||
urls:
|
|
||||||
- https://webhooks.gitter.im/e/7f95bf605c4d356372f4
|
|
||||||
on_success: change # options: [always|never|change] default: always
|
|
||||||
on_failure: always # options: [always|never|change] default: always
|
|
||||||
on_start: false # default: false
|
|
@ -8,6 +8,6 @@
|
|||||||
- With pull requests:
|
- With pull requests:
|
||||||
- Open your pull request against `master`
|
- Open your pull request against `master`
|
||||||
- Your pull request should have no more than two commits, if not you should squash them.
|
- Your pull request should have no more than two commits, if not you should squash them.
|
||||||
- It should pass all tests in the available continuous integration systems such as TravisCI.
|
- It should pass all tests in the available continuous integration systems such as GitHub Actions.
|
||||||
- You should add/modify tests to cover your proposed code changes.
|
- You should add/modify tests to cover your proposed code changes.
|
||||||
- If your pull request contains a new feature, please document it on the README.
|
- If your pull request contains a new feature, please document it on the README.
|
||||||
|
10
Makefile
10
Makefile
@ -1,5 +1,6 @@
|
|||||||
GO ?= go
|
GO ?= go
|
||||||
GOFMT ?= gofmt "-s"
|
GOFMT ?= gofmt "-s"
|
||||||
|
GO_VERSION=$(shell $(GO) version | cut -c 14- | cut -d' ' -f1 | cut -d'.' -f2)
|
||||||
PACKAGES ?= $(shell $(GO) list ./...)
|
PACKAGES ?= $(shell $(GO) list ./...)
|
||||||
VETPACKAGES ?= $(shell $(GO) list ./... | grep -v /examples/)
|
VETPACKAGES ?= $(shell $(GO) list ./... | grep -v /examples/)
|
||||||
GOFILES := $(shell find . -name "*.go")
|
GOFILES := $(shell find . -name "*.go")
|
||||||
@ -67,5 +68,10 @@ misspell:
|
|||||||
|
|
||||||
.PHONY: tools
|
.PHONY: tools
|
||||||
tools:
|
tools:
|
||||||
go install golang.org/x/lint/golint; \
|
@if [ $(GO_VERSION) -gt 15 ]; then \
|
||||||
go install github.com/client9/misspell/cmd/misspell;
|
$(GO) install golang.org/x/lint/golint@latest; \
|
||||||
|
$(GO) install github.com/client9/misspell/cmd/misspell@latest; \
|
||||||
|
elif [ $(GO_VERSION) -lt 16 ]; then \
|
||||||
|
$(GO) install golang.org/x/lint/golint; \
|
||||||
|
$(GO) install github.com/client9/misspell/cmd/misspell; \
|
||||||
|
fi
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
<img align="right" width="159px" src="https://raw.githubusercontent.com/gin-gonic/logo/master/color.png">
|
<img align="right" width="159px" src="https://raw.githubusercontent.com/gin-gonic/logo/master/color.png">
|
||||||
|
|
||||||
[](https://travis-ci.org/gin-gonic/gin)
|
[](https://github.com/gin-gonic/gin/actions?query=branch%3Amaster)
|
||||||
[](https://codecov.io/gh/gin-gonic/gin)
|
[](https://codecov.io/gh/gin-gonic/gin)
|
||||||
[](https://goreportcard.com/report/github.com/gin-gonic/gin)
|
[](https://goreportcard.com/report/github.com/gin-gonic/gin)
|
||||||
[](https://pkg.go.dev/github.com/gin-gonic/gin?tab=doc)
|
[](https://pkg.go.dev/github.com/gin-gonic/gin?tab=doc)
|
||||||
|
8
tree.go
8
tree.go
@ -30,8 +30,8 @@ type Param struct {
|
|||||||
// It is therefore safe to read values by the index.
|
// It is therefore safe to read values by the index.
|
||||||
type Params []Param
|
type Params []Param
|
||||||
|
|
||||||
// Get returns the value of the first Param which key matches the given name.
|
// Get returns the value of the first Param which key matches the given name and a boolean true.
|
||||||
// If no matching Param is found, an empty string is returned.
|
// If no matching Param is found, an empty string is returned and a boolean false .
|
||||||
func (ps Params) Get(name string) (string, bool) {
|
func (ps Params) Get(name string) (string, bool) {
|
||||||
for _, entry := range ps {
|
for _, entry := range ps {
|
||||||
if entry.Key == name {
|
if entry.Key == name {
|
||||||
@ -487,7 +487,7 @@ walk: // Outer loop for walking the tree
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ... but we can't
|
// ... but we can't
|
||||||
value.tsr = (len(path) == end+1)
|
value.tsr = len(path) == end+1
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -499,7 +499,7 @@ walk: // Outer loop for walking the tree
|
|||||||
// No handle found. Check if a handle for this path + a
|
// No handle found. Check if a handle for this path + a
|
||||||
// trailing slash exists for TSR recommendation
|
// trailing slash exists for TSR recommendation
|
||||||
n = n.children[0]
|
n = n.children[0]
|
||||||
value.tsr = (n.path == "/" && n.handlers != nil)
|
value.tsr = n.path == "/" && n.handlers != nil
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user