ci(github action): use golangci-lint to replace the deprecated golint (#1175)

* ci: use golangci-lint to replace the deprecated golint

Co-authored-by: ymh199478 <yumenghan@bilibili.com>
pull/1179/head
喵喵大人 3 years ago committed by GitHub
parent a7b1af764f
commit 4780b6e1fd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 18
      .github/workflows/go.yml
  2. 11
      .golangci.yml
  3. 3
      config/value.go
  4. 5
      encoding/form/form.go
  5. 3
      transport/grpc/client.go
  6. 10
      transport/http/context.go

@ -5,6 +5,7 @@ on:
branches: [ main ]
pull_request:
branches: [ main ]
workflow_dispatch:
jobs:
@ -42,7 +43,16 @@ jobs:
go build ./...
go test ./...
- name: Lint
run: |
go get golang.org/x/lint/golint
golint ./...
lint:
name: lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Lint
uses: golangci/golangci-lint-action@v2
with:
version: v1.41
args: --disable-all
skip-go-installation: true
skip-pkg-cache: true
only-new-issues: true

@ -0,0 +1,11 @@
run:
timeout: 5m
modules-download-mode: readonly
skip-files:
- ".*_test\\.go$"
linters:
enable:
- revive
- staticcheck
- govet

@ -68,7 +68,8 @@ func (v *atomicValue) Float() (float64, error) {
case int64:
return float64(val), nil
case string:
return strconv.ParseFloat(val, 10)
//todo: SA1030: 'bitSize' argument is invalid, must be either 32 or 64
return strconv.ParseFloat(val, 10) //nolint: staticcheck
}
return 0.0, fmt.Errorf("type assert to %v failed", reflect.TypeOf(v.Load()))
}

@ -67,10 +67,7 @@ func (c codec) Unmarshal(data []byte, v interface{}) error {
return MapProto(m, vs)
}
if err := c.decoder.Decode(v, vs); err != nil {
return err
}
return nil
return c.decoder.Decode(v, vs)
}
func (codec) Name() string {

@ -96,7 +96,8 @@ func dial(ctx context.Context, insecure bool, opts ...ClientOption) (*grpc.Clien
ints = append(ints, options.ints...)
}
var grpcOpts = []grpc.DialOption{
grpc.WithBalancerName(roundrobin.Name),
//todo: grpc.WithBalancerName is deprecated.
grpc.WithBalancerName(roundrobin.Name), //nolint:staticcheck
grpc.WithChainUnaryInterceptor(ints...),
}
if options.discovery != nil {

@ -97,18 +97,12 @@ func (c *wrapper) Returns(v interface{}, err error) error {
if err != nil {
return err
}
if err := c.router.srv.enc(&c.w, c.req, v); err != nil {
return err
}
return nil
return c.router.srv.enc(&c.w, c.req, v)
}
func (c *wrapper) Result(code int, v interface{}) error {
c.w.WriteHeader(code)
if err := c.router.srv.enc(&c.w, c.req, v); err != nil {
return err
}
return nil
return c.router.srv.enc(&c.w, c.req, v)
}
func (c *wrapper) JSON(code int, v interface{}) error {

Loading…
Cancel
Save