1
0
mirror of https://github.com/go-kratos/kratos.git synced 2026-05-22 10:15:24 +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
6 changed files with 32 additions and 18 deletions
+13 -3
View File
@@ -5,6 +5,7 @@ on:
branches: [ main ] branches: [ main ]
pull_request: pull_request:
branches: [ main ] branches: [ main ]
workflow_dispatch:
jobs: jobs:
@@ -42,7 +43,16 @@ jobs:
go build ./... go build ./...
go test ./... go test ./...
lint:
name: lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Lint - name: Lint
run: | uses: golangci/golangci-lint-action@v2
go get golang.org/x/lint/golint with:
golint ./... version: v1.41
args: --disable-all
skip-go-installation: true
skip-pkg-cache: true
only-new-issues: true
+11
View File
@@ -0,0 +1,11 @@
run:
timeout: 5m
modules-download-mode: readonly
skip-files:
- ".*_test\\.go$"
linters:
enable:
- revive
- staticcheck
- govet
+2 -1
View File
@@ -68,7 +68,8 @@ func (v *atomicValue) Float() (float64, error) {
case int64: case int64:
return float64(val), nil return float64(val), nil
case string: 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())) return 0.0, fmt.Errorf("type assert to %v failed", reflect.TypeOf(v.Load()))
} }
+1 -4
View File
@@ -67,10 +67,7 @@ func (c codec) Unmarshal(data []byte, v interface{}) error {
return MapProto(m, vs) return MapProto(m, vs)
} }
if err := c.decoder.Decode(v, vs); err != nil { return c.decoder.Decode(v, vs)
return err
}
return nil
} }
func (codec) Name() string { func (codec) Name() string {
+2 -1
View File
@@ -96,7 +96,8 @@ func dial(ctx context.Context, insecure bool, opts ...ClientOption) (*grpc.Clien
ints = append(ints, options.ints...) ints = append(ints, options.ints...)
} }
var grpcOpts = []grpc.DialOption{ var grpcOpts = []grpc.DialOption{
grpc.WithBalancerName(roundrobin.Name), //todo: grpc.WithBalancerName is deprecated.
grpc.WithBalancerName(roundrobin.Name), //nolint:staticcheck
grpc.WithChainUnaryInterceptor(ints...), grpc.WithChainUnaryInterceptor(ints...),
} }
if options.discovery != nil { if options.discovery != nil {
+2 -8
View File
@@ -97,18 +97,12 @@ func (c *wrapper) Returns(v interface{}, err error) error {
if err != nil { if err != nil {
return err return err
} }
if err := c.router.srv.enc(&c.w, c.req, v); err != nil { return c.router.srv.enc(&c.w, c.req, v)
return err
}
return nil
} }
func (c *wrapper) Result(code int, v interface{}) error { func (c *wrapper) Result(code int, v interface{}) error {
c.w.WriteHeader(code) c.w.WriteHeader(code)
if err := c.router.srv.enc(&c.w, c.req, v); err != nil { return c.router.srv.enc(&c.w, c.req, v)
return err
}
return nil
} }
func (c *wrapper) JSON(code int, v interface{}) error { func (c *wrapper) JSON(code int, v interface{}) error {