1
0
mirror of https://github.com/go-kratos/kratos.git synced 2025-01-28 03:57:02 +02:00

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>
This commit is contained in:
喵喵大人 2021-07-12 18:09:38 +08:00 committed by GitHub
parent a7b1af764f
commit 4780b6e1fd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 32 additions and 18 deletions

View File

@ -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

11
.golangci.yml Normal file
View File

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

View File

@ -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()))
}

View File

@ -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 {

View File

@ -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 {

View File

@ -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 {