Repository: go-kratos/kratos
Pull request #2713 (2023-03-09 11:24:43)

add http.ResponseController type alias

shenqidebaozi: please merge master
czyt: > please merge master

no master branch was found on kratos
codecov-commenter: ## [Codecov](https://codecov.io/gh/go-kratos/kratos/pull/2713?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=go-kratos) Report
> Merging [#2713](https://codecov.io/gh/go-kratos/kratos/pull/2713?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=go-kratos) (ee6970d) into [main](https://codecov.io/gh/go-kratos/kratos/commit/7eca8f80340563ec1a9d3252becbd1377779f7fe?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=go-kratos) (7eca8f8) will **decrease** coverage by `0.06%`.
> The diff coverage is `n/a`.

> :exclamation: Current head ee6970d differs from pull request most recent head 3630159. Consider uploading reports for the commit 3630159 to get more accurate results

:mega: This organization is not using Codecov’s [GitHub App Integration](https://github.com/apps/codecov). We recommend you install it so Codecov can continue to function properly for your repositories. [Learn more](https://about.codecov.io/blog/codecov-is-updating-its-github-integration/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=go-kratos)

```diff
@@            Coverage Diff             @@
##             main    #2713      +/-   ##
==========================================
- Coverage   84.88%   84.82%   -0.06%     
==========================================
  Files          88       88              
  Lines        3889     3889              
==========================================
- Hits         3301     3299       -2     
- Misses        413      415       +2     
  Partials      175      175              
```


[see 1 file with indirect coverage changes](https://codecov.io/gh/go-kratos/kratos/pull/2713/indirect-changes?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=go-kratos)

Help us with your feedback. Take ten seconds to tell us [how you rate us](https://about.codecov.io/nps?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=go-kratos). Have a feature suggestion? [Share it here.](https://app.codecov.io/gh/feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=go-kratos)


Patch:
diff --git a/.github/stable.yml b/.github/stable.yml
new file mode 100644
index 00000000..e6e976bb
--- /dev/null
+++ b/.github/stable.yml
@@ -0,0 +1,12 @@
+daysUntilStale: 30
+daysUntilClose: 3
+exemptLabels:
+  - pinned
+  - security
+  - bug
+staleLabel: wontfix
+markComment: >
+  This issue has been automatically marked as stale because it has not had
+  recent activity. It will be closed if no further activity occurs. Thank you
+  for your contributions.
+closeComment: true
\ No newline at end of file
diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml
index 9d94238a..83ac2c39 100644
--- a/.github/workflows/go.yml
+++ b/.github/workflows/go.yml
@@ -44,7 +44,7 @@ jobs:
     steps:
       - uses: actions/checkout@v3
       - name: Set up Go
-        uses: actions/setup-go@v3.5.0
+        uses: actions/setup-go@v4.0.0
         with:
           go-version: ${{ matrix.go }}
 
diff --git a/.github/workflows/issue-translator.yml b/.github/workflows/issue-translator.yml
new file mode 100644
index 00000000..9cab6d08
--- /dev/null
+++ b/.github/workflows/issue-translator.yml
@@ -0,0 +1,16 @@
+name: 'issue-translator'
+on:
+  issue_comment:
+    types: [created]
+  issues:
+    types: [opened]
+
+jobs:
+  build:
+    runs-on: ubuntu-latest
+    steps:
+      - uses: usthe/issues-translate-action@v2.7
+        with:
+          IS_MODIFY_TITLE: true
+          CUSTOM_BOT_NOTE: Bot detected the issue body's language is not English, translate it automatically. 👯👭🏻🧑‍🤝‍🧑👫🧑🏿‍🤝‍🧑🏻👩🏾‍🤝‍👨🏿👬🏿
+          BOT_GITHUB_TOKEN: ${{ secrets.BOT_GITHUB_TOKEN }}
diff --git a/Makefile b/Makefile
index 77ee21a8..7825a11c 100644
--- a/Makefile
+++ b/Makefile
@@ -89,7 +89,7 @@ test:
 .PHONY: test-coverage
 test-coverage:
 	@${TOOLS_SHELL} test_coverage
-	@echo "go test with coverage finished"	
+	@echo "go test with coverage finished"
 
 .PHONY: lint
 lint: $(LINTER)
@@ -99,4 +99,4 @@ lint: $(LINTER)
 .PHONY: proto
 proto:
 	protoc --proto_path=./api --proto_path=./third_party --go_out=paths=source_relative:./api --go-grpc_out=paths=source_relative:./api --go-http_out=paths=source_relative:./api metadata/metadata.proto
-	protoc --proto_path=./third_party --go_out=paths=source_relative:./ errors/errors.proto
+	protoc --proto_path=./third_party --go_out=paths=source_relative:./errors/errors.proto
diff --git a/SECURITY.md b/SECURITY.md
index d7fb3ffe..6e28dd41 100644
--- a/SECURITY.md
+++ b/SECURITY.md
@@ -5,10 +5,10 @@
 Use this section to tell people about which versions of your project are
 currently being supported with security updates.
 
-| Version | Supported          |
-| ------- | ------------------ |
-| 2.0.rc1   | :white_check_mark: |
-| < 2.0.beta3  | :x:                |
+| Version     | Supported          |
+|-------------|--------------------|
+| 2.0.rc1     | :white_check_mark: |
+| < 2.0.beta3 | :x:                |
 
 ## Reporting a Vulnerability
 
diff --git a/api/metadata/server.go b/api/metadata/server.go
index b1c4c17b..e3d5e373 100644
--- a/api/metadata/server.go
+++ b/api/metadata/server.go
@@ -98,7 +98,7 @@ func (s *Server) load() error {
 }
 
 // ListServices return all services
-func (s *Server) ListServices(ctx context.Context, in *ListServicesRequest) (*ListServicesReply, error) {
+func (s *Server) ListServices(_ context.Context, _ *ListServicesRequest) (*ListServicesReply, error) {
 	s.lock.Lock()
 	defer s.lock.Unlock()
 	if err := s.load(); err != nil {
@@ -122,7 +122,7 @@ func (s *Server) ListServices(ctx context.Context, in *ListServicesRequest) (*Li
 }
 
 // GetServiceDesc return service meta by name
-func (s *Server) GetServiceDesc(ctx context.Context, in *GetServiceDescRequest) (*GetServiceDescReply, error) {
+func (s *Server) GetServiceDesc(_ context.Context, in *GetServiceDescRequest) (*GetServiceDescReply, error) {
 	s.lock.Lock()
 	defer s.lock.Unlock()
 	if err := s.load(); err != nil {
diff --git a/cmd/kratos/internal/base/path.go b/cmd/kratos/internal/base/path.go
index f0a505ce..d24647fd 100644
--- a/cmd/kratos/internal/base/path.go
+++ b/cmd/kratos/internal/base/path.go
@@ -5,7 +5,6 @@ import (
 	"fmt"
 	"log"
 	"os"
-	"path"
 	"path/filepath"
 	"strings"
 
@@ -17,7 +16,7 @@ func kratosHome() string {
 	if err != nil {
 		log.Fatal(err)
 	}
-	home := path.Join(dir, ".kratos")
+	home := filepath.Join(dir, ".kratos")
 	if _, err := os.Stat(home); os.IsNotExist(err) {
 		if err := os.MkdirAll(home, 0o700); err != nil {
 			log.Fatal(err)
@@ -27,7 +26,7 @@ func kratosHome() string {
 }
 
 func kratosHomeWithDir(dir string) string {
-	home := path.Join(kratosHome(), dir)
+	home := filepath.Join(kratosHome(), dir)
 	if _, err := os.Stat(home); os.IsNotExist(err) {
 		if err := os.MkdirAll(home, 0o700); err != nil {
 			log.Fatal(err)
@@ -37,7 +36,6 @@ func kratosHomeWithDir(dir string) string {
 }
 
 func copyFile(src, dst string, replaces []string) error {
-	var err error
 	srcinfo, err := os.Stat(src)
 	if err != nil {
 		return err
@@ -58,27 +56,26 @@ func copyFile(src, dst string, replaces []string) error {
 }
 
 func copyDir(src, dst string, replaces, ignores []string) error {
-	var err error
-	var fds []os.DirEntry
-	var srcinfo os.FileInfo
-
-	if srcinfo, err = os.Stat(src); err != nil {
+	srcinfo, err := os.Stat(src)
+	if err != nil {
 		return err
 	}
 
-	if err = os.MkdirAll(dst, srcinfo.Mode()); err != nil {
+	err = os.MkdirAll(dst, srcinfo.Mode())
+	if err != nil {
 		return err
 	}
 
-	if fds, err = os.ReadDir(src); err != nil {
+	fds, err := os.ReadDir(src)
+	if err != nil {
 		return err
 	}
 	for _, fd := range fds {
 		if hasSets(fd.Name(), ignores) {
 			continue
 		}
-		srcfp := path.Join(src, fd.Name())
-		dstfp := path.Join(dst, fd.Name())
+		srcfp := filepath.Join(src, fd.Name())
+		dstfp := filepath.Join(dst, fd.Name())
 		var e error
 		if fd.IsDir() {
 			e = copyDir(srcfp, dstfp, replaces, ignores)
diff --git a/cmd/kratos/internal/base/repo.go b/cmd/kratos/internal/base/repo.go
index bdcb3f01..fe1ba18e 100644
--- a/cmd/kratos/internal/base/repo.go
+++ b/cmd/kratos/internal/base/repo.go
@@ -7,6 +7,7 @@ import (
 	"os"
 	"os/exec"
 	"path"
+	"path/filepath"
 	"strings"
 )
 
@@ -68,7 +69,7 @@ func (r *Repo) Pull(ctx context.Context) error {
 	cmd.Dir = r.Path()
 	_, err := cmd.CombinedOutput()
 	if err != nil {
-		return nil
+		return err
 	}
 	cmd = exec.CommandContext(ctx, "git", "pull")
 	cmd.Dir = r.Path()
@@ -104,7 +105,7 @@ func (r *Repo) CopyTo(ctx context.Context, to string, modPath string, ignores []
 	if err := r.Clone(ctx); err != nil {
 		return err
 	}
-	mod, err := ModulePath(path.Join(r.Path(), "go.mod"))
+	mod, err := ModulePath(filepath.Join(r.Path(), "go.mod"))
 	if err != nil {
 		return err
 	}
@@ -116,7 +117,7 @@ func (r *Repo) CopyToV2(ctx context.Context, to string, modPath string, ignores,
 	if err := r.Clone(ctx); err != nil {
 		return err
 	}
-	mod, err := ModulePath(path.Join(r.Path(), "go.mod"))
+	mod, err := ModulePath(filepath.Join(r.Path(), "go.mod"))
 	if err != nil {
 		return err
 	}
diff --git a/cmd/kratos/internal/change/change.go b/cmd/kratos/internal/change/change.go
index 9327a179..2e92bee0 100644
--- a/cmd/kratos/internal/change/change.go
+++ b/cmd/kratos/internal/change/change.go
@@ -28,7 +28,7 @@ func init() {
 	token = os.Getenv("GITHUB_TOKEN")
 }
 
-func run(cmd *cobra.Command, args []string) {
+func run(_ *cobra.Command, args []string) {
 	owner, repo := ParseGithubURL(repoURL)
 	api := GithubAPI{Owner: owner, Repo: repo, Token: token}
 	version := "latest"
diff --git a/cmd/kratos/internal/project/add.go b/cmd/kratos/internal/project/add.go
index 72a89f29..df5eff11 100644
--- a/cmd/kratos/internal/project/add.go
+++ b/cmd/kratos/internal/project/add.go
@@ -4,7 +4,7 @@ import (
 	"context"
 	"fmt"
 	"os"
-	"path"
+	"path/filepath"
 
 	"github.com/AlecAivazis/survey/v2"
 	"github.com/fatih/color"
@@ -17,7 +17,7 @@ var repoAddIgnores = []string{
 }
 
 func (p *Project) Add(ctx context.Context, dir string, layout string, branch string, mod string) error {
-	to := path.Join(dir, p.Name)
+	to := filepath.Join(dir, p.Name)
 
 	if _, err := os.Stat(to); !os.IsNotExist(err) {
 		fmt.Printf("🚫 %s already exists\n", p.Name)
@@ -40,13 +40,13 @@ func (p *Project) Add(ctx context.Context, dir string, layout string, branch str
 
 	repo := base.NewRepo(layout, branch)
 
-	if err := repo.CopyToV2(ctx, to, path.Join(mod, p.Path), repoAddIgnores, []string{path.Join(p.Path, "api"), "api"}); err != nil {
+	if err := repo.CopyToV2(ctx, to, filepath.Join(mod, p.Path), repoAddIgnores, []string{filepath.Join(p.Path, "api"), "api"}); err != nil {
 		return err
 	}
 
 	e := os.Rename(
-		path.Join(to, "cmd", "server"),
-		path.Join(to, "cmd", p.Name),
+		filepath.Join(to, "cmd", "server"),
+		filepath.Join(to, "cmd", p.Name),
 	)
 	if e != nil {
 		return e
diff --git a/cmd/kratos/internal/project/new.go b/cmd/kratos/internal/project/new.go
index f98552b0..73c01986 100644
--- a/cmd/kratos/internal/project/new.go
+++ b/cmd/kratos/internal/project/new.go
@@ -4,12 +4,12 @@ import (
 	"context"
 	"fmt"
 	"os"
-	"path"
-
-	"github.com/go-kratos/kratos/cmd/kratos/v2/internal/base"
+	"path/filepath"
 
 	"github.com/AlecAivazis/survey/v2"
 	"github.com/fatih/color"
+
+	"github.com/go-kratos/kratos/cmd/kratos/v2/internal/base"
 )
 
 // Project is a project template.
@@ -20,14 +20,14 @@ type Project struct {
 
 // New new a project from remote repo.
 func (p *Project) New(ctx context.Context, dir string, layout string, branch string) error {
-	to := path.Join(dir, p.Name)
+	to := filepath.Join(dir, p.Name)
 	if _, err := os.Stat(to); !os.IsNotExist(err) {
 		fmt.Printf("🚫 %s already exists\n", p.Name)
-		override := false
 		prompt := &survey.Confirm{
 			Message: "📂 Do you want to override the folder ?",
 			Help:    "Delete the existing folder and create the project.",
 		}
+		var override bool
 		e := survey.AskOne(prompt, &override)
 		if e != nil {
 			return e
@@ -43,8 +43,8 @@ func (p *Project) New(ctx context.Context, dir string, layout string, branch str
 		return err
 	}
 	e := os.Rename(
-		path.Join(to, "cmd", "server"),
-		path.Join(to, "cmd", p.Name),
+		filepath.Join(to, "cmd", "server"),
+		filepath.Join(to, "cmd", p.Name),
 	)
 	if e != nil {
 		return e
diff --git a/cmd/kratos/internal/project/project.go b/cmd/kratos/internal/project/project.go
index 9abc98b7..fffa0fdc 100644
--- a/cmd/kratos/internal/project/project.go
+++ b/cmd/kratos/internal/project/project.go
@@ -5,7 +5,6 @@ import (
 	"errors"
 	"fmt"
 	"os"
-	"path"
 	"path/filepath"
 	"strings"
 	"time"
@@ -42,7 +41,7 @@ func init() {
 	CmdNew.Flags().BoolVarP(&nomod, "nomod", "", nomod, "retain go mod")
 }
 
-func run(cmd *cobra.Command, args []string) {
+func run(_ *cobra.Command, args []string) {
 	wd, err := os.Getwd()
 	if err != nil {
 		panic(err)
@@ -66,25 +65,25 @@ func run(cmd *cobra.Command, args []string) {
 	} else {
 		name = args[0]
 	}
-	wd = getProjectPlaceDir(name, wd)
-	p := &Project{Name: filepath.Base(name), Path: name}
+	projectName, workingDir := processProjectParams(name, wd)
+	p := &Project{Name: projectName, Path: projectName}
 	done := make(chan error, 1)
 	go func() {
 		if !nomod {
-			done <- p.New(ctx, wd, repoURL, branch)
+			done <- p.New(ctx, workingDir, repoURL, branch)
 			return
 		}
-		projectRoot := getgomodProjectRoot(wd)
+		projectRoot := getgomodProjectRoot(workingDir)
 		if gomodIsNotExistIn(projectRoot) {
 			done <- fmt.Errorf("🚫 go.mod don't exists in %s", projectRoot)
 			return
 		}
 
-		mod, e := base.ModulePath(path.Join(projectRoot, "go.mod"))
+		mod, e := base.ModulePath(filepath.Join(projectRoot, "go.mod"))
 		if e != nil {
 			panic(e)
 		}
-		done <- p.Add(ctx, wd, repoURL, branch, mod)
+		done <- p.Add(ctx, workingDir, repoURL, branch, mod)
 	}()
 	select {
 	case <-ctx.Done():
@@ -100,29 +99,29 @@ func run(cmd *cobra.Command, args []string) {
 	}
 }
 
-func getProjectPlaceDir(projectName string, fallbackPlaceDir string) string {
-	projectFullPath := projectName
-
-	wd := filepath.Dir(projectName)
-	// check for home dir
-	if strings.HasPrefix(wd, "~") {
+func processProjectParams(projectName string, workingDir string) (projectNameResult, workingDirResult string) {
+	_projectDir := projectName
+	_workingDir := workingDir
+	// Process ProjectName with system variable
+	if strings.HasPrefix(projectName, "~") {
 		homeDir, err := os.UserHomeDir()
 		if err != nil {
 			// cannot get user home return fallback place dir
-			return fallbackPlaceDir
+			return _projectDir, _workingDir
 		}
-		projectFullPath = filepath.Join(homeDir, projectName[2:])
+		_projectDir = filepath.Join(homeDir, projectName[2:])
 	}
+
 	// check path is relative
-	if !filepath.IsAbs(projectFullPath) {
-		absPath, err := filepath.Abs(projectFullPath)
+	if !filepath.IsAbs(projectName) {
+		absPath, err := filepath.Abs(projectName)
 		if err != nil {
-			return fallbackPlaceDir
+			return _projectDir, _workingDir
 		}
-		projectFullPath = absPath
+		_projectDir = absPath
 	}
-	// create project logic will check stat,so not check path stat here
-	return filepath.Dir(projectFullPath)
+
+	return filepath.Base(_projectDir), filepath.Dir(_projectDir)
 }
 
 func getgomodProjectRoot(dir string) string {
@@ -136,6 +135,6 @@ func getgomodProjectRoot(dir string) string {
 }
 
 func gomodIsNotExistIn(dir string) bool {
-	_, e := os.Stat(path.Join(dir, "go.mod"))
+	_, e := os.Stat(filepath.Join(dir, "go.mod"))
 	return os.IsNotExist(e)
 }
diff --git a/cmd/kratos/internal/proto/add/add.go b/cmd/kratos/internal/proto/add/add.go
index e770dd5f..2415ab9d 100644
--- a/cmd/kratos/internal/proto/add/add.go
+++ b/cmd/kratos/internal/proto/add/add.go
@@ -19,7 +19,7 @@ var CmdAdd = &cobra.Command{
 	Run:   run,
 }
 
-func run(cmd *cobra.Command, args []string) {
+func run(_ *cobra.Command, args []string) {
 	if len(args) == 0 {
 		fmt.Println("Please enter the proto file or directory")
 		return
diff --git a/cmd/kratos/internal/proto/add/proto.go b/cmd/kratos/internal/proto/add/proto.go
index 8c716dc6..88184a28 100644
--- a/cmd/kratos/internal/proto/add/proto.go
+++ b/cmd/kratos/internal/proto/add/proto.go
@@ -3,7 +3,7 @@ package add
 import (
 	"fmt"
 	"os"
-	"path"
+	"path/filepath"
 )
 
 // Proto is a proto generator.
@@ -26,13 +26,13 @@ func (p *Proto) Generate() error {
 	if err != nil {
 		panic(err)
 	}
-	to := path.Join(wd, p.Path)
+	to := filepath.Join(wd, p.Path)
 	if _, err := os.Stat(to); os.IsNotExist(err) {
 		if err := os.MkdirAll(to, 0o700); err != nil {
 			return err
 		}
 	}
-	name := path.Join(to, p.Name)
+	name := filepath.Join(to, p.Name)
 	if _, err := os.Stat(name); !os.IsNotExist(err) {
 		return fmt.Errorf("%s already exists", p.Name)
 	}
diff --git a/cmd/kratos/internal/proto/client/client.go b/cmd/kratos/internal/proto/client/client.go
index 8bc00633..cb3f4a76 100644
--- a/cmd/kratos/internal/proto/client/client.go
+++ b/cmd/kratos/internal/proto/client/client.go
@@ -8,9 +8,9 @@ import (
 	"regexp"
 	"strings"
 
-	"github.com/go-kratos/kratos/cmd/kratos/v2/internal/base"
-
 	"github.com/spf13/cobra"
+
+	"github.com/go-kratos/kratos/cmd/kratos/v2/internal/base"
 )
 
 // CmdClient represents the source command.
@@ -30,7 +30,7 @@ func init() {
 	CmdClient.Flags().StringVarP(&protoPath, "proto_path", "p", protoPath, "proto path")
 }
 
-func run(cmd *cobra.Command, args []string) {
+func run(_ *cobra.Command, args []string) {
 	if len(args) == 0 {
 		fmt.Println("Please enter the proto file or directory")
 		return
diff --git a/cmd/kratos/internal/proto/proto.go b/cmd/kratos/internal/proto/proto.go
index 4b9c858b..b176d5de 100644
--- a/cmd/kratos/internal/proto/proto.go
+++ b/cmd/kratos/internal/proto/proto.go
@@ -1,11 +1,11 @@
 package proto
 
 import (
+	"github.com/spf13/cobra"
+
 	"github.com/go-kratos/kratos/cmd/kratos/v2/internal/proto/add"
 	"github.com/go-kratos/kratos/cmd/kratos/v2/internal/proto/client"
 	"github.com/go-kratos/kratos/cmd/kratos/v2/internal/proto/server"
-
-	"github.com/spf13/cobra"
 )
 
 // CmdProto represents the proto command.
diff --git a/cmd/kratos/internal/proto/server/server.go b/cmd/kratos/internal/proto/server/server.go
index 3b8a8196..35e8f90c 100644
--- a/cmd/kratos/internal/proto/server/server.go
+++ b/cmd/kratos/internal/proto/server/server.go
@@ -4,7 +4,7 @@ import (
 	"fmt"
 	"log"
 	"os"
-	"path"
+	"path/filepath"
 	"strings"
 
 	"github.com/emicklei/proto"
@@ -17,7 +17,7 @@ import (
 var CmdServer = &cobra.Command{
 	Use:   "server",
 	Short: "Generate the proto Server implementations",
-	Long:  "Generate the proto Server implementations. Example: kratos proto server api/xxx.proto -target-dir=internal/service",
+	Long:  "Generate the proto Server implementations. Example: kratos proto server api/xxx.proto --target-dir=internal/service",
 	Run:   run,
 }
 var targetDir string
@@ -26,7 +26,7 @@ func init() {
 	CmdServer.Flags().StringVarP(&targetDir, "target-dir", "t", "internal/service", "generate target directory")
 }
 
-func run(cmd *cobra.Command, args []string) {
+func run(_ *cobra.Command, args []string) {
 	if len(args) == 0 {
 		fmt.Fprintln(os.Stderr, "Please specify the proto file. Example: kratos proto server api/xxx.proto")
 		return
@@ -76,7 +76,7 @@ func run(cmd *cobra.Command, args []string) {
 		return
 	}
 	for _, s := range res {
-		to := path.Join(targetDir, strings.ToLower(s.Service)+".go")
+		to := filepath.Join(targetDir, strings.ToLower(s.Service)+".go")
 		if _, err := os.Stat(to); !os.IsNotExist(err) {
 			fmt.Fprintf(os.Stderr, "%s already exists: %s\n", s.Service, to)
 			continue
diff --git a/cmd/kratos/internal/run/run.go b/cmd/kratos/internal/run/run.go
index ac229bab..2def97a1 100644
--- a/cmd/kratos/internal/run/run.go
+++ b/cmd/kratos/internal/run/run.go
@@ -4,7 +4,6 @@ import (
 	"fmt"
 	"os"
 	"os/exec"
-	"path"
 	"path/filepath"
 	"strings"
 
@@ -19,6 +18,11 @@ var CmdRun = &cobra.Command{
 	Long:  "Run project. Example: kratos run",
 	Run:   Run,
 }
+var targetDir string
+
+func init() {
+	CmdRun.Flags().StringVarP(&targetDir, "work", "w", "", "target working directory")
+}
 
 // Run run project.
 func Run(cmd *cobra.Command, args []string) {
@@ -64,10 +68,11 @@ func Run(cmd *cobra.Command, args []string) {
 			dir = cmdPath[dir]
 		}
 	}
-	fd := exec.Command("go", append([]string{"run", "."}, programArgs...)...)
+	fd := exec.Command("go", append([]string{"run", dir}, programArgs...)...)
 	fd.Stdout = os.Stdout
 	fd.Stderr = os.Stderr
 	fd.Dir = dir
+	changeWorkingDirectory(fd, targetDir)
 	if err := fd.Run(); err != nil {
 		fmt.Fprintf(os.Stderr, "\033[31mERROR: %s\033[m\n", err.Error())
 		return
@@ -102,7 +107,7 @@ func findCMD(base string) (map[string]string, error) {
 				}
 				for _, fileInfo := range paths {
 					if fileInfo.IsDir() {
-						abs := path.Join(walkPath, fileInfo.Name())
+						abs := filepath.Join(walkPath, fileInfo.Name())
 						cmdPath[strings.TrimPrefix(abs, wd)] = abs
 					}
 				}
@@ -131,3 +136,10 @@ func findCMD(base string) (map[string]string, error) {
 	}
 	return map[string]string{"": base}, nil
 }
+
+func changeWorkingDirectory(cmd *exec.Cmd, targetDir string) {
+	targetDir = strings.TrimSpace(targetDir)
+	if targetDir != "" {
+		cmd.Dir = targetDir
+	}
+}
diff --git a/cmd/kratos/internal/upgrade/upgrade.go b/cmd/kratos/internal/upgrade/upgrade.go
index a8825dcc..20e368da 100644
--- a/cmd/kratos/internal/upgrade/upgrade.go
+++ b/cmd/kratos/internal/upgrade/upgrade.go
@@ -3,9 +3,9 @@ package upgrade
 import (
 	"fmt"
 
-	"github.com/go-kratos/kratos/cmd/kratos/v2/internal/base"
-
 	"github.com/spf13/cobra"
+
+	"github.com/go-kratos/kratos/cmd/kratos/v2/internal/base"
 )
 
 // CmdUpgrade represents the upgrade command.
@@ -17,7 +17,7 @@ var CmdUpgrade = &cobra.Command{
 }
 
 // Run upgrade the kratos tools.
-func Run(cmd *cobra.Command, args []string) {
+func Run(_ *cobra.Command, _ []string) {
 	err := base.GoInstall(
 		"github.com/go-kratos/kratos/cmd/kratos/v2@latest",
 		"github.com/go-kratos/kratos/cmd/protoc-gen-go-http/v2@latest",
diff --git a/cmd/kratos/main.go b/cmd/kratos/main.go
index 2ae05e31..a227a215 100644
--- a/cmd/kratos/main.go
+++ b/cmd/kratos/main.go
@@ -3,13 +3,13 @@ package main
 import (
 	"log"
 
+	"github.com/spf13/cobra"
+
 	"github.com/go-kratos/kratos/cmd/kratos/v2/internal/change"
 	"github.com/go-kratos/kratos/cmd/kratos/v2/internal/project"
 	"github.com/go-kratos/kratos/cmd/kratos/v2/internal/proto"
 	"github.com/go-kratos/kratos/cmd/kratos/v2/internal/run"
 	"github.com/go-kratos/kratos/cmd/kratos/v2/internal/upgrade"
-
-	"github.com/spf13/cobra"
 )
 
 var rootCmd = &cobra.Command{
diff --git a/cmd/protoc-gen-go-errors/errors.go b/cmd/protoc-gen-go-errors/errors.go
index 522c2968..f09c89ea 100644
--- a/cmd/protoc-gen-go-errors/errors.go
+++ b/cmd/protoc-gen-go-errors/errors.go
@@ -59,7 +59,7 @@ func generateFileContent(gen *protogen.Plugin, file *protogen.File, g *protogen.
 	}
 }
 
-func genErrorsReason(gen *protogen.Plugin, file *protogen.File, g *protogen.GeneratedFile, enum *protogen.Enum) bool {
+func genErrorsReason(_ *protogen.Plugin, _ *protogen.File, g *protogen.GeneratedFile, enum *protogen.Enum) bool {
 	defaultCode := proto.GetExtension(enum.Desc.Options(), errors.E_DefaultCode)
 	code := 0
 	if ok := defaultCode.(int32); ok != 0 {
diff --git a/cmd/protoc-gen-go-http/http.go b/cmd/protoc-gen-go-http/http.go
index 7a4ff712..8d799a3b 100644
--- a/cmd/protoc-gen-go-http/http.go
+++ b/cmd/protoc-gen-go-http/http.go
@@ -63,7 +63,7 @@ func generateFileContent(gen *protogen.Plugin, file *protogen.File, g *protogen.
 	}
 }
 
-func genService(gen *protogen.Plugin, file *protogen.File, g *protogen.GeneratedFile, service *protogen.Service, omitempty bool) {
+func genService(_ *protogen.Plugin, file *protogen.File, g *protogen.GeneratedFile, service *protogen.Service, omitempty bool) {
 	if service.Desc.Options().(*descriptorpb.ServiceOptions).GetDeprecated() {
 		g.P("//")
 		g.P(deprecationComment)
diff --git a/config/options.go b/config/options.go
index e89a6fca..443ddaba 100644
--- a/config/options.go
+++ b/config/options.go
@@ -51,7 +51,7 @@ func WithResolver(r Resolver) Option {
 
 // WithLogger with config logger.
 // Deprecated: use global logger instead.
-func WithLogger(l log.Logger) Option {
+func WithLogger(_ log.Logger) Option {
 	return func(o *options) {}
 }
 
diff --git a/contrib/config/apollo/apollo.go b/contrib/config/apollo/apollo.go
index d463df29..1734fdb0 100644
--- a/contrib/config/apollo/apollo.go
+++ b/contrib/config/apollo/apollo.go
@@ -5,7 +5,7 @@ import (
 
 	"github.com/apolloconfig/agollo/v4"
 	"github.com/apolloconfig/agollo/v4/constant"
-	apolloConfig "github.com/apolloconfig/agollo/v4/env/config"
+	apolloconfig "github.com/apolloconfig/agollo/v4/env/config"
 	"github.com/apolloconfig/agollo/v4/extension"
 
 	"github.com/go-kratos/kratos/v2/config"
@@ -112,8 +112,8 @@ func NewSource(opts ...Option) config.Source {
 	for _, o := range opts {
 		o(&op)
 	}
-	client, err := agollo.StartWithConfig(func() (*apolloConfig.AppConfig, error) {
-		return &apolloConfig.AppConfig{
+	client, err := agollo.StartWithConfig(func() (*apolloconfig.AppConfig, error) {
+		return &apolloconfig.AppConfig{
 			AppID:            op.appid,
 			Cluster:          op.cluster,
 			NamespaceName:    op.namespace,
@@ -166,14 +166,13 @@ func (e *apollo) load() []*config.KeyValue {
 			}
 			kvs = append(kvs, kv)
 			continue
-		} else {
-			kv, err := e.getConfig(ns)
-			if err != nil {
-				log.Errorf("apollo get config failed，err:%v", err)
-				continue
-			}
-			kvs = append(kvs, kv)
 		}
+		kv, err := e.getConfig(ns)
+		if err != nil {
+			log.Errorf("apollo get config failed，err:%v", err)
+			continue
+		}
+		kvs = append(kvs, kv)
 	}
 	return kvs
 }
diff --git a/contrib/config/apollo/watcher.go b/contrib/config/apollo/watcher.go
index d59bdd21..ad842420 100644
--- a/contrib/config/apollo/watcher.go
+++ b/contrib/config/apollo/watcher.go
@@ -72,7 +72,7 @@ func (c *customChangeListener) OnChange(changeEvent *storage.ChangeEvent) {
 	c.in <- change
 }
 
-func (c *customChangeListener) OnNewestChange(changeEvent *storage.FullChangeEvent) {}
+func (c *customChangeListener) OnNewestChange(_ *storage.FullChangeEvent) {}
 
 func newWatcher(a *apollo) (config.Watcher, error) {
 	changeCh := make(chan []*config.KeyValue)
diff --git a/contrib/config/consul/watcher.go b/contrib/config/consul/watcher.go
index 5c70d6f8..5562505c 100644
--- a/contrib/config/consul/watcher.go
+++ b/contrib/config/consul/watcher.go
@@ -18,7 +18,7 @@ type watcher struct {
 	cancel context.CancelFunc
 }
 
-func (w *watcher) handle(idx uint64, data interface{}) {
+func (w *watcher) handle(_ uint64, data interface{}) {
 	if data == nil {
 		return
 	}
diff --git a/contrib/config/kubernetes/go.mod b/contrib/config/kubernetes/go.mod
index 5e21577e..6555fc59 100644
--- a/contrib/config/kubernetes/go.mod
+++ b/contrib/config/kubernetes/go.mod
@@ -4,9 +4,9 @@ go 1.16
 
 require (
 	github.com/go-kratos/kratos/v2 v2.4.0
-	k8s.io/api v0.26.2
-	k8s.io/apimachinery v0.26.2
-	k8s.io/client-go v0.26.2
+	k8s.io/api v0.26.3
+	k8s.io/apimachinery v0.26.3
+	k8s.io/client-go v0.26.3
 )
 
 replace github.com/go-kratos/kratos/v2 => ../../../
diff --git a/contrib/config/kubernetes/go.sum b/contrib/config/kubernetes/go.sum
index 3321a9b3..ce9a75be 100644
--- a/contrib/config/kubernetes/go.sum
+++ b/contrib/config/kubernetes/go.sum
@@ -608,12 +608,12 @@ honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWh
 honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg=
 honnef.co/go/tools v0.0.1-2020.1.3/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k=
 honnef.co/go/tools v0.0.1-2020.1.4/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k=
-k8s.io/api v0.26.2 h1:dM3cinp3PGB6asOySalOZxEG4CZ0IAdJsrYZXE/ovGQ=
-k8s.io/api v0.26.2/go.mod h1:1kjMQsFE+QHPfskEcVNgL3+Hp88B80uj0QtSOlj8itU=
-k8s.io/apimachinery v0.26.2 h1:da1u3D5wfR5u2RpLhE/ZtZS2P7QvDgLZTi9wrNZl/tQ=
-k8s.io/apimachinery v0.26.2/go.mod h1:ats7nN1LExKHvJ9TmwootT00Yz05MuYqPXEXaVeOy5I=
-k8s.io/client-go v0.26.2 h1:s1WkVujHX3kTp4Zn4yGNFK+dlDXy1bAAkIl+cFAiuYI=
-k8s.io/client-go v0.26.2/go.mod h1:u5EjOuSyBa09yqqyY7m3abZeovO/7D/WehVVlZ2qcqU=
+k8s.io/api v0.26.3 h1:emf74GIQMTik01Aum9dPP0gAypL8JTLl/lHa4V9RFSU=
+k8s.io/api v0.26.3/go.mod h1:PXsqwPMXBSBcL1lJ9CYDKy7kIReUydukS5JiRlxC3qE=
+k8s.io/apimachinery v0.26.3 h1:dQx6PNETJ7nODU3XPtrwkfuubs6w7sX0M8n61zHIV/k=
+k8s.io/apimachinery v0.26.3/go.mod h1:ats7nN1LExKHvJ9TmwootT00Yz05MuYqPXEXaVeOy5I=
+k8s.io/client-go v0.26.3 h1:k1UY+KXfkxV2ScEL3gilKcF7761xkYsSD6BC9szIu8s=
+k8s.io/client-go v0.26.3/go.mod h1:ZPNu9lm8/dbRIPAgteN30RSXea6vrCpFvq+MateTUuQ=
 k8s.io/gengo v0.0.0-20210813121822-485abfe95c7c/go.mod h1:FiNAH4ZV3gBg2Kwh89tzAEV2be7d5xI0vBa/VySYy3E=
 k8s.io/klog/v2 v2.0.0/go.mod h1:PBfzABfn139FHAV07az/IF9Wp1bkk3vpT2XSJ76fSDE=
 k8s.io/klog/v2 v2.2.0/go.mod h1:Od+F08eJP+W3HUb4pSrPpgp9DGU4GzlpG/TmITuYh/Y=
diff --git a/contrib/metrics/datadog/gauge.go b/contrib/metrics/datadog/gauge.go
index fbff772b..86912f92 100644
--- a/contrib/metrics/datadog/gauge.go
+++ b/contrib/metrics/datadog/gauge.go
@@ -39,8 +39,8 @@ func (d *gauge) Set(value float64) {
 	_ = d.opts.client.Gauge(d.name, value, d.lvs, d.opts.sampleRate)
 }
 
-func (d *gauge) Add(delta float64) {
+func (d *gauge) Add(_ float64) {
 }
 
-func (d *gauge) Sub(delta float64) {
+func (d *gauge) Sub(_ float64) {
 }
diff --git a/contrib/registry/discovery/discovery.go b/contrib/registry/discovery/discovery.go
index f439b0ca..bbacd7bb 100644
--- a/contrib/registry/discovery/discovery.go
+++ b/contrib/registry/discovery/discovery.go
@@ -427,7 +427,7 @@ func (r *Resolve) Watch() <-chan struct{} {
 }
 
 // fetch resolver instance.
-func (r *Resolve) fetch(ctx context.Context) (ins *disInstancesInfo, ok bool) {
+func (r *Resolve) fetch(_ context.Context) (ins *disInstancesInfo, ok bool) {
 	r.d.mutex.RLock()
 	app, ok := r.d.apps[r.id]
 	r.d.mutex.RUnlock()
diff --git a/contrib/registry/discovery/impl_registrar.go b/contrib/registry/discovery/impl_registrar.go
index bb580cc1..c4af66b7 100644
--- a/contrib/registry/discovery/impl_registrar.go
+++ b/contrib/registry/discovery/impl_registrar.go
@@ -122,7 +122,7 @@ func (d *Discovery) register(ctx context.Context, ins *discoveryInstance) (err e
 	return
 }
 
-func (d *Discovery) Deregister(ctx context.Context, service *registry.ServiceInstance) error {
+func (d *Discovery) Deregister(_ context.Context, service *registry.ServiceInstance) error {
 	ins := fromServerInstance(service, d.config)
 	return d.cancel(ins)
 }
diff --git a/contrib/registry/kubernetes/registry.go b/contrib/registry/kubernetes/registry.go
index 987ef1e1..21562dc5 100644
--- a/contrib/registry/kubernetes/registry.go
+++ b/contrib/registry/kubernetes/registry.go
@@ -151,14 +151,14 @@ func (s *Registry) Register(ctx context.Context, service *registry.ServiceInstan
 }
 
 // Deregister the registration.
-func (s *Registry) Deregister(ctx context.Context, service *registry.ServiceInstance) error {
+func (s *Registry) Deregister(ctx context.Context, _ *registry.ServiceInstance) error {
 	return s.Register(ctx, &registry.ServiceInstance{
 		Metadata: map[string]string{},
 	})
 }
 
 // GetService return the service instances in memory according to the service name.
-func (s *Registry) GetService(ctx context.Context, name string) ([]*registry.ServiceInstance, error) {
+func (s *Registry) GetService(_ context.Context, name string) ([]*registry.ServiceInstance, error) {
 	pods, err := s.podLister.List(labels.SelectorFromSet(map[string]string{
 		LabelsKeyServiceName: name,
 	}))
diff --git a/contrib/registry/zookeeper/register.go b/contrib/registry/zookeeper/register.go
index 8f21745d..0e4ff0bb 100644
--- a/contrib/registry/zookeeper/register.go
+++ b/contrib/registry/zookeeper/register.go
@@ -59,7 +59,7 @@ func New(conn *zk.Conn, opts ...Option) *Registry {
 	}
 }
 
-func (r *Registry) Register(ctx context.Context, service *registry.ServiceInstance) error {
+func (r *Registry) Register(_ context.Context, service *registry.ServiceInstance) error {
 	var (
 		data []byte
 		err  error
@@ -100,7 +100,7 @@ func (r *Registry) Deregister(ctx context.Context, service *registry.ServiceInst
 }
 
 // GetService get services from zookeeper
-func (r *Registry) GetService(ctx context.Context, serviceName string) ([]*registry.ServiceInstance, error) {
+func (r *Registry) GetService(_ context.Context, serviceName string) ([]*registry.ServiceInstance, error) {
 	instances, err, _ := r.group.Do(serviceName, func() (interface{}, error) {
 		serviceNamePath := path.Join(r.opts.namespace, serviceName)
 		servicesID, _, err := r.conn.Children(serviceNamePath)
diff --git a/log/log.go b/log/log.go
index bbaf94da..5022ba4b 100644
--- a/log/log.go
+++ b/log/log.go
@@ -27,10 +27,7 @@ func (c *logger) Log(level Level, keyvals ...interface{}) error {
 		bindValues(c.ctx, kvs)
 	}
 	kvs = append(kvs, keyvals...)
-	if err := c.logger.Log(level, kvs...); err != nil {
-		return err
-	}
-	return nil
+	return c.logger.Log(level, kvs...)
 }
 
 // With with logger fields.
diff --git a/middleware/tracing/statsHandler.go b/middleware/tracing/statsHandler.go
index b9ee3fd1..594be9e1 100644
--- a/middleware/tracing/statsHandler.go
+++ b/middleware/tracing/statsHandler.go
@@ -13,12 +13,12 @@ import (
 type ClientHandler struct{}
 
 // HandleConn exists to satisfy gRPC stats.Handler.
-func (c *ClientHandler) HandleConn(ctx context.Context, cs stats.ConnStats) {
+func (c *ClientHandler) HandleConn(_ context.Context, _ stats.ConnStats) {
 	fmt.Println("Handle connection.")
 }
 
 // TagConn exists to satisfy gRPC stats.Handler.
-func (c *ClientHandler) TagConn(ctx context.Context, cti *stats.ConnTagInfo) context.Context {
+func (c *ClientHandler) TagConn(ctx context.Context, _ *stats.ConnTagInfo) context.Context {
 	return ctx
 }
 
@@ -38,6 +38,6 @@ func (c *ClientHandler) HandleRPC(ctx context.Context, rs stats.RPCStats) {
 }
 
 // TagRPC implements per-RPC context management.
-func (c *ClientHandler) TagRPC(ctx context.Context, rti *stats.RPCTagInfo) context.Context {
+func (c *ClientHandler) TagRPC(ctx context.Context, _ *stats.RPCTagInfo) context.Context {
 	return ctx
 }
diff --git a/middleware/tracing/tracer.go b/middleware/tracing/tracer.go
index 798994f8..b4455309 100644
--- a/middleware/tracing/tracer.go
+++ b/middleware/tracing/tracer.go
@@ -60,7 +60,7 @@ func (t *Tracer) Start(ctx context.Context, operation string, carrier propagatio
 }
 
 // End finish tracing span
-func (t *Tracer) End(ctx context.Context, span trace.Span, m interface{}, err error) {
+func (t *Tracer) End(_ context.Context, span trace.Span, m interface{}, err error) {
 	if err != nil {
 		span.RecordError(err)
 		if e := errors.FromError(err); e != nil {
diff --git a/selector/node/ewma/node.go b/selector/node/ewma/node.go
index 3b8d2a02..c718f252 100644
--- a/selector/node/ewma/node.go
+++ b/selector/node/ewma/node.go
@@ -10,7 +10,6 @@ import (
 	"time"
 
 	"github.com/go-kratos/kratos/v2/errors"
-
 	"github.com/go-kratos/kratos/v2/selector"
 )
 
diff --git a/selector/p2c/p2c.go b/selector/p2c/p2c.go
index 5e339b0c..1d0ef8c5 100644
--- a/selector/p2c/p2c.go
+++ b/selector/p2c/p2c.go
@@ -51,7 +51,7 @@ func (s *Balancer) prePick(nodes []selector.WeightedNode) (nodeA selector.Weight
 }
 
 // Pick pick a node.
-func (s *Balancer) Pick(ctx context.Context, nodes []selector.WeightedNode) (selector.WeightedNode, selector.DoneFunc, error) {
+func (s *Balancer) Pick(_ context.Context, nodes []selector.WeightedNode) (selector.WeightedNode, selector.DoneFunc, error) {
 	if len(nodes) == 0 {
 		return nil, nil, selector.ErrNoAvailable
 	}
diff --git a/transport/grpc/client.go b/transport/grpc/client.go
index b2b5c0c2..a7a00910 100644
--- a/transport/grpc/client.go
+++ b/transport/grpc/client.go
@@ -105,23 +105,30 @@ func WithNodeFilter(filters ...selector.NodeFilter) ClientOption {
 
 // WithLogger with logger
 // Deprecated: use global logger instead.
-func WithLogger(log log.Logger) ClientOption {
+func WithLogger(_ log.Logger) ClientOption {
 	return func(o *clientOptions) {}
 }
 
+func WithPrintDiscoveryDebugLog(p bool) ClientOption {
+	return func(o *clientOptions) {
+		o.printDiscoveryDebugLog = p
+	}
+}
+
 // clientOptions is gRPC Client
 type clientOptions struct {
-	endpoint     string
-	subsetSize   int
-	tlsConf      *tls.Config
-	timeout      time.Duration
-	discovery    registry.Discovery
-	middleware   []middleware.Middleware
-	ints         []grpc.UnaryClientInterceptor
-	streamInts   []grpc.StreamClientInterceptor
-	grpcOpts     []grpc.DialOption
-	balancerName string
-	filters      []selector.NodeFilter
+	endpoint               string
+	subsetSize             int
+	tlsConf                *tls.Config
+	timeout                time.Duration
+	discovery              registry.Discovery
+	middleware             []middleware.Middleware
+	ints                   []grpc.UnaryClientInterceptor
+	streamInts             []grpc.StreamClientInterceptor
+	grpcOpts               []grpc.DialOption
+	balancerName           string
+	filters                []selector.NodeFilter
+	printDiscoveryDebugLog bool
 }
 
 // Dial returns a GRPC connection.
@@ -136,9 +143,10 @@ func DialInsecure(ctx context.Context, opts ...ClientOption) (*grpc.ClientConn,
 
 func dial(ctx context.Context, insecure bool, opts ...ClientOption) (*grpc.ClientConn, error) {
 	options := clientOptions{
-		timeout:      2000 * time.Millisecond,
-		balancerName: balancerName,
-		subsetSize:   25,
+		timeout:                2000 * time.Millisecond,
+		balancerName:           balancerName,
+		subsetSize:             25,
+		printDiscoveryDebugLog: true,
 	}
 	for _, o := range opts {
 		o(&options)
@@ -157,7 +165,7 @@ func dial(ctx context.Context, insecure bool, opts ...ClientOption) (*grpc.Clien
 		sints = append(sints, options.streamInts...)
 	}
 	grpcOpts := []grpc.DialOption{
-		grpc.WithDefaultServiceConfig(fmt.Sprintf(`{"loadBalancingConfig": [{"%s":{}}]}`, options.balancerName)),
+		grpc.WithDefaultServiceConfig(fmt.Sprintf(`{"loadBalancingConfig": [{"%s":{}}],"healthCheckConfig":{"serviceName":""}}`, options.balancerName)),
 		grpc.WithChainUnaryInterceptor(ints...),
 		grpc.WithChainStreamInterceptor(sints...),
 	}
@@ -169,6 +177,7 @@ func dial(ctx context.Context, insecure bool, opts ...ClientOption) (*grpc.Clien
 					options.discovery,
 					discovery.WithInsecure(insecure),
 					discovery.WithSubset(options.subsetSize),
+					discovery.PrintDebugLog(options.printDiscoveryDebugLog),
 				)))
 	}
 	if insecure {
diff --git a/transport/grpc/resolver/direct/builder.go b/transport/grpc/resolver/direct/builder.go
index 6035e2d5..ebbd22d7 100644
--- a/transport/grpc/resolver/direct/builder.go
+++ b/transport/grpc/resolver/direct/builder.go
@@ -20,7 +20,7 @@ func NewBuilder() resolver.Builder {
 	return &directBuilder{}
 }
 
-func (d *directBuilder) Build(target resolver.Target, cc resolver.ClientConn, opts resolver.BuildOptions) (resolver.Resolver, error) {
+func (d *directBuilder) Build(target resolver.Target, cc resolver.ClientConn, _ resolver.BuildOptions) (resolver.Resolver, error) {
 	addrs := make([]resolver.Address, 0)
 	for _, addr := range strings.Split(strings.TrimPrefix(target.URL.Path, "/"), ",") {
 		addrs = append(addrs, resolver.Address{Addr: addr})
diff --git a/transport/grpc/resolver/direct/resolver.go b/transport/grpc/resolver/direct/resolver.go
index 7d18228c..e2dce618 100644
--- a/transport/grpc/resolver/direct/resolver.go
+++ b/transport/grpc/resolver/direct/resolver.go
@@ -11,5 +11,5 @@ func newDirectResolver() resolver.Resolver {
 func (r *directResolver) Close() {
 }
 
-func (r *directResolver) ResolveNow(options resolver.ResolveNowOptions) {
+func (r *directResolver) ResolveNow(_ resolver.ResolveNowOptions) {
 }
diff --git a/transport/grpc/resolver/discovery/builder.go b/transport/grpc/resolver/discovery/builder.go
index 6186cdf1..28aff384 100644
--- a/transport/grpc/resolver/discovery/builder.go
+++ b/transport/grpc/resolver/discovery/builder.go
@@ -38,29 +38,37 @@ func WithSubset(size int) Option {
 	}
 }
 
+// Deprecated: please use PrintDebugLog
 // DisableDebugLog disables update instances log.
 func DisableDebugLog() Option {
 	return func(b *builder) {
-		b.debugLogDisabled = true
+		b.debugLog = false
+	}
+}
+
+// PrintDebugLog print grpc resolver watch service log
+func PrintDebugLog(p bool) Option {
+	return func(b *builder) {
+		b.debugLog = p
 	}
 }
 
 type builder struct {
-	discoverer       registry.Discovery
-	timeout          time.Duration
-	insecure         bool
-	subsetSize       int
-	debugLogDisabled bool
+	discoverer registry.Discovery
+	timeout    time.Duration
+	insecure   bool
+	subsetSize int
+	debugLog   bool
 }
 
 // NewBuilder creates a builder which is used to factory registry resolvers.
 func NewBuilder(d registry.Discovery, opts ...Option) resolver.Builder {
 	b := &builder{
-		discoverer:       d,
-		timeout:          time.Second * 10,
-		insecure:         false,
-		debugLogDisabled: false,
-		subsetSize:       25,
+		discoverer: d,
+		timeout:    time.Second * 10,
+		insecure:   false,
+		debugLog:   true,
+		subsetSize: 25,
 	}
 	for _, o := range opts {
 		o(b)
@@ -68,7 +76,7 @@ func NewBuilder(d registry.Discovery, opts ...Option) resolver.Builder {
 	return b
 }
 
-func (b *builder) Build(target resolver.Target, cc resolver.ClientConn, opts resolver.BuildOptions) (resolver.Resolver, error) {
+func (b *builder) Build(target resolver.Target, cc resolver.ClientConn, _ resolver.BuildOptions) (resolver.Resolver, error) {
 	watchRes := &struct {
 		err error
 		w   registry.Watcher
@@ -96,14 +104,14 @@ func (b *builder) Build(target resolver.Target, cc resolver.ClientConn, opts res
 	}
 
 	r := &discoveryResolver{
-		w:                watchRes.w,
-		cc:               cc,
-		ctx:              ctx,
-		cancel:           cancel,
-		insecure:         b.insecure,
-		debugLogDisabled: b.debugLogDisabled,
-		subsetSize:       b.subsetSize,
-		selecterKey:      uuid.New().String(),
+		w:           watchRes.w,
+		cc:          cc,
+		ctx:         ctx,
+		cancel:      cancel,
+		insecure:    b.insecure,
+		debugLog:    b.debugLog,
+		subsetSize:  b.subsetSize,
+		selecterKey: uuid.New().String(),
 	}
 	go r.watch()
 	return r, nil
diff --git a/transport/grpc/resolver/discovery/resolver.go b/transport/grpc/resolver/discovery/resolver.go
index a66a9b4e..03c76664 100644
--- a/transport/grpc/resolver/discovery/resolver.go
+++ b/transport/grpc/resolver/discovery/resolver.go
@@ -22,10 +22,10 @@ type discoveryResolver struct {
 	ctx    context.Context
 	cancel context.CancelFunc
 
-	insecure         bool
-	debugLogDisabled bool
-	selecterKey      string
-	subsetSize       int
+	insecure    bool
+	debugLog    bool
+	selecterKey string
+	subsetSize  int
 }
 
 func (r *discoveryResolver) watch() {
@@ -90,7 +90,7 @@ func (r *discoveryResolver) update(ins []*registry.ServiceInstance) {
 		log.Errorf("[resolver] failed to update state: %s", err)
 	}
 
-	if !r.debugLogDisabled {
+	if r.debugLog {
 		b, _ := json.Marshal(filtered)
 		log.Infof("[resolver] update instances: %s", b)
 	}
@@ -104,16 +104,11 @@ func (r *discoveryResolver) Close() {
 	}
 }
 
-func (r *discoveryResolver) ResolveNow(options resolver.ResolveNowOptions) {}
+func (r *discoveryResolver) ResolveNow(_ resolver.ResolveNowOptions) {}
 
-func parseAttributes(md map[string]string) *attributes.Attributes {
-	var a *attributes.Attributes
+func parseAttributes(md map[string]string) (a *attributes.Attributes) {
 	for k, v := range md {
-		if a == nil {
-			a = attributes.New(k, v)
-		} else {
-			a = a.WithValue(k, v)
-		}
+		a = a.WithValue(k, v)
 	}
 	return a
 }
diff --git a/transport/grpc/server.go b/transport/grpc/server.go
index 4c3deccf..9a8344bf 100644
--- a/transport/grpc/server.go
+++ b/transport/grpc/server.go
@@ -56,7 +56,7 @@ func Timeout(timeout time.Duration) ServerOption {
 
 // Logger with server logger.
 // Deprecated: use global logger instead.
-func Logger(logger log.Logger) ServerOption {
+func Logger(_ log.Logger) ServerOption {
 	return func(s *Server) {}
 }
 
@@ -210,7 +210,7 @@ func (s *Server) Start(ctx context.Context) error {
 }
 
 // Stop stop the gRPC server.
-func (s *Server) Stop(ctx context.Context) error {
+func (s *Server) Stop(_ context.Context) error {
 	if s.adminClean != nil {
 		s.adminClean()
 	}
diff --git a/transport/http/calloption.go b/transport/http/calloption.go
index 7b0ed82d..e8329410 100644
--- a/transport/http/calloption.go
+++ b/transport/http/calloption.go
@@ -102,7 +102,7 @@ type HeaderCallOption struct {
 	header *http.Header
 }
 
-func (o HeaderCallOption) after(c *callInfo, cs *csAttempt) {
+func (o HeaderCallOption) after(_ *callInfo, cs *csAttempt) {
 	if cs.res != nil && cs.res.Header != nil {
 		*o.header = cs.res.Header
 	}
diff --git a/transport/http/client.go b/transport/http/client.go
index 52ee1350..2d2a352c 100644
--- a/transport/http/client.go
+++ b/transport/http/client.go
@@ -327,7 +327,7 @@ func (client *Client) Close() error {
 }
 
 // DefaultRequestEncoder is an HTTP request encoder.
-func DefaultRequestEncoder(ctx context.Context, contentType string, in interface{}) ([]byte, error) {
+func DefaultRequestEncoder(_ context.Context, contentType string, in interface{}) ([]byte, error) {
 	name := httputil.ContentSubtype(contentType)
 	body, err := encoding.GetCodec(name).Marshal(in)
 	if err != nil {
@@ -337,7 +337,7 @@ func DefaultRequestEncoder(ctx context.Context, contentType string, in interface
 }
 
 // DefaultResponseDecoder is an HTTP response decoder.
-func DefaultResponseDecoder(ctx context.Context, res *http.Response, v interface{}) error {
+func DefaultResponseDecoder(_ context.Context, res *http.Response, v interface{}) error {
 	defer res.Body.Close()
 	data, err := io.ReadAll(res.Body)
 	if err != nil {
@@ -347,7 +347,7 @@ func DefaultResponseDecoder(ctx context.Context, res *http.Response, v interface
 }
 
 // DefaultErrorDecoder is an HTTP error decoder.
-func DefaultErrorDecoder(ctx context.Context, res *http.Response) error {
+func DefaultErrorDecoder(_ context.Context, res *http.Response) error {
 	if res.StatusCode >= 200 && res.StatusCode <= 299 {
 		return nil
 	}
diff --git a/transport/http/codec_go1.20.go b/transport/http/codec_go1.20.go
new file mode 100644
index 00000000..2df5ec92
--- /dev/null
+++ b/transport/http/codec_go1.20.go
@@ -0,0 +1,10 @@
+//go:build go1.20
+// +build go1.20
+
+package http
+
+import "net/http"
+
+// ResponseController is type net/http.ResponseController which was added in Go 1.20.
+
+type ResponseController = http.ResponseController
diff --git a/transport/http/server.go b/transport/http/server.go
index 165bb99b..7b27d326 100644
--- a/transport/http/server.go
+++ b/transport/http/server.go
@@ -52,7 +52,7 @@ func Timeout(timeout time.Duration) ServerOption {
 
 // Logger with server logger.
 // Deprecated: use global logger instead.
-func Logger(logger log.Logger) ServerOption {
+func Logger(_ log.Logger) ServerOption {
 	return func(s *Server) {}
 }
 


Test patch:
diff --git a/app_test.go b/app_test.go
index 92a2ca29..05e10134 100644
--- a/app_test.go
+++ b/app_test.go
@@ -19,7 +19,7 @@ type mockRegistry struct {
 	service map[string]*registry.ServiceInstance
 }
 
-func (r *mockRegistry) Register(ctx context.Context, service *registry.ServiceInstance) error {
+func (r *mockRegistry) Register(_ context.Context, service *registry.ServiceInstance) error {
 	if service == nil || service.ID == "" {
 		return errors.New("no service id")
 	}
@@ -30,7 +30,7 @@ func (r *mockRegistry) Register(ctx context.Context, service *registry.ServiceIn
 }
 
 // Deregister the registration.
-func (r *mockRegistry) Deregister(ctx context.Context, service *registry.ServiceInstance) error {
+func (r *mockRegistry) Deregister(_ context.Context, service *registry.ServiceInstance) error {
 	r.lk.Lock()
 	defer r.lk.Unlock()
 	if r.service[service.ID] == nil {
diff --git a/cmd/kratos/internal/project/project_linux_test.go b/cmd/kratos/internal/project/project_linux_test.go
index 271e1353..868cdf02 100644
--- a/cmd/kratos/internal/project/project_linux_test.go
+++ b/cmd/kratos/internal/project/project_linux_test.go
@@ -7,7 +7,7 @@ import (
 	"testing"
 )
 
-func Test_getProjectPlaceDir(t *testing.T) {
+func Test_processProjectParams(t *testing.T) {
 	type args struct {
 		projectName      string
 		fallbackPlaceDir string
@@ -21,8 +21,8 @@ func Test_getProjectPlaceDir(t *testing.T) {
 	}
 	for _, tt := range tests {
 		t.Run(tt.name, func(t *testing.T) {
-			if got := getProjectPlaceDir(tt.args.projectName, tt.args.fallbackPlaceDir); got != tt.want {
-				t.Errorf("getProjectPlaceDir() = %v, want %v", got, tt.want)
+			if _, got := processProjectParams(tt.args.projectName, tt.args.fallbackPlaceDir); got != tt.want {
+				t.Errorf("processProjectParams() = %v, want %v", got, tt.want)
 			}
 		})
 	}
diff --git a/cmd/kratos/internal/project/project_windows_test.go b/cmd/kratos/internal/project/project_windows_test.go
index ea60473a..c86baf37 100644
--- a/cmd/kratos/internal/project/project_windows_test.go
+++ b/cmd/kratos/internal/project/project_windows_test.go
@@ -7,7 +7,7 @@ import (
 	"testing"
 )
 
-func Test_getProjectPlaceDir(t *testing.T) {
+func Test_processProjectParams(t *testing.T) {
 	type args struct {
 		projectName      string
 		fallbackPlaceDir string
@@ -22,7 +22,7 @@ func Test_getProjectPlaceDir(t *testing.T) {
 	}
 	for _, tt := range tests {
 		t.Run(tt.name, func(t *testing.T) {
-			if got := getProjectPlaceDir(tt.args.projectName, tt.args.fallbackPlaceDir); got != tt.want {
+			if _, got := processProjectParams(tt.args.projectName, tt.args.fallbackPlaceDir); got != tt.want {
 				t.Errorf("getProjectPlaceDir() = %v, want %v", got, tt.want)
 			}
 		})
diff --git a/contrib/log/aliyun/aliyun_test.go b/contrib/log/aliyun/aliyun_test.go
index e3e224ad..d8c914ba 100644
--- a/contrib/log/aliyun/aliyun_test.go
+++ b/contrib/log/aliyun/aliyun_test.go
@@ -58,7 +58,7 @@ func TestWithAccessSecret(t *testing.T) {
 	}
 }
 
-func TestLogger(t *testing.T) {
+func TestLogger(_ *testing.T) {
 	project := "foo"
 	logger := NewAliyunLog(WithProject(project))
 	defer logger.Close()
diff --git a/contrib/opensergo/opensergo_test.go b/contrib/opensergo/opensergo_test.go
index 70ffef8f..0a2165fb 100644
--- a/contrib/opensergo/opensergo_test.go
+++ b/contrib/opensergo/opensergo_test.go
@@ -23,7 +23,7 @@ type testMetadataServiceServer struct {
 	srvContractPb.UnimplementedMetadataServiceServer
 }
 
-func (m *testMetadataServiceServer) ReportMetadata(ctx context.Context, req *srvContractPb.ReportMetadataRequest) (*srvContractPb.ReportMetadataReply, error) {
+func (m *testMetadataServiceServer) ReportMetadata(_ context.Context, _ *srvContractPb.ReportMetadataRequest) (*srvContractPb.ReportMetadataReply, error) {
 	return &srvContractPb.ReportMetadataReply{}, nil
 }
 
diff --git a/contrib/registry/eureka/register_test.go b/contrib/registry/eureka/register_test.go
index 683b0c58..c8c340c8 100644
--- a/contrib/registry/eureka/register_test.go
+++ b/contrib/registry/eureka/register_test.go
@@ -11,7 +11,7 @@ import (
 	"github.com/go-kratos/kratos/v2/registry"
 )
 
-func TestRegistry(t *testing.T) {
+func TestRegistry(_ *testing.T) {
 	ctx := context.Background()
 	ctx, cancel := context.WithCancel(ctx)
 	s1 := &registry.ServiceInstance{
@@ -92,7 +92,7 @@ func do(r *Registry, s *registry.ServiceInstance) {
 	}
 }
 
-func TestLock(t *testing.T) {
+func TestLock(_ *testing.T) {
 	type me struct {
 		lock sync.Mutex
 	}
diff --git a/contrib/registry/servicecomb/registry_test.go b/contrib/registry/servicecomb/registry_test.go
index 4b4c2549..9e139492 100644
--- a/contrib/registry/servicecomb/registry_test.go
+++ b/contrib/registry/servicecomb/registry_test.go
@@ -19,13 +19,13 @@ func init() {
 
 type mockClient struct{}
 
-func (receiver *mockClient) WatchMicroService(microServiceID string, callback func(*sc.MicroServiceInstanceChangedEvent)) error {
+func (receiver *mockClient) WatchMicroService(_ string, _ func(*sc.MicroServiceInstanceChangedEvent)) error {
 	return nil
 }
 
 //nolint
-func (receiver *mockClient) FindMicroServiceInstances(consumerID,
-	appID, microServiceName, versionRule string, opts ...sc.CallOption,
+func (receiver *mockClient) FindMicroServiceInstances(_,
+	_, microServiceName, _ string, _ ...sc.CallOption,
 ) ([]*pb.MicroServiceInstance, error) {
 	if microServiceName == "KratosServicecomb" {
 		return []*pb.MicroServiceInstance{{}}, nil
@@ -33,23 +33,23 @@ func (receiver *mockClient) FindMicroServiceInstances(consumerID,
 	return nil, nil
 }
 
-func (receiver *mockClient) RegisterService(microService *pb.MicroService) (string, error) {
+func (receiver *mockClient) RegisterService(_ *pb.MicroService) (string, error) {
 	return "", nil
 }
 
-func (receiver *mockClient) RegisterMicroServiceInstance(microServiceInstance *pb.MicroServiceInstance) (string, error) {
+func (receiver *mockClient) RegisterMicroServiceInstance(_ *pb.MicroServiceInstance) (string, error) {
 	return "", nil
 }
 
-func (receiver *mockClient) Heartbeat(microServiceID, microServiceInstanceID string) (bool, error) {
+func (receiver *mockClient) Heartbeat(_, _ string) (bool, error) {
 	return true, nil
 }
 
-func (receiver *mockClient) UnregisterMicroServiceInstance(microServiceID, microServiceInstanceID string) (bool, error) {
+func (receiver *mockClient) UnregisterMicroServiceInstance(_, _ string) (bool, error) {
 	return true, nil
 }
 
-func (receiver *mockClient) GetMicroServiceID(appID, microServiceName, version, env string, opts ...sc.CallOption) (string, error) {
+func (receiver *mockClient) GetMicroServiceID(_, _, _, _ string, _ ...sc.CallOption) (string, error) {
 	return "", nil
 }
 
diff --git a/encoding/encoding_test.go b/encoding/encoding_test.go
index 1d79ebbd..9746788a 100644
--- a/encoding/encoding_test.go
+++ b/encoding/encoding_test.go
@@ -9,11 +9,11 @@ import (
 
 type codec struct{}
 
-func (c codec) Marshal(v interface{}) ([]byte, error) {
+func (c codec) Marshal(_ interface{}) ([]byte, error) {
 	panic("implement me")
 }
 
-func (c codec) Unmarshal(data []byte, v interface{}) error {
+func (c codec) Unmarshal(_ []byte, _ interface{}) error {
 	panic("implement me")
 }
 
diff --git a/log/filter_test.go b/log/filter_test.go
index 3e36deac..9258400c 100644
--- a/log/filter_test.go
+++ b/log/filter_test.go
@@ -6,7 +6,7 @@ import (
 	"testing"
 )
 
-func TestFilterAll(t *testing.T) {
+func TestFilterAll(_ *testing.T) {
 	logger := With(DefaultLogger, "ts", DefaultTimestamp, "caller", DefaultCaller)
 	log := NewHelper(NewFilter(logger,
 		FilterLevel(LevelDebug),
@@ -21,7 +21,7 @@ func TestFilterAll(t *testing.T) {
 	log.Warn("warn log")
 }
 
-func TestFilterLevel(t *testing.T) {
+func TestFilterLevel(_ *testing.T) {
 	logger := With(DefaultLogger, "ts", DefaultTimestamp, "caller", DefaultCaller)
 	log := NewHelper(NewFilter(NewFilter(logger, FilterLevel(LevelWarn))))
 	log.Log(LevelDebug, "msg1", "te1st debug")
@@ -31,7 +31,7 @@ func TestFilterLevel(t *testing.T) {
 	log.Warn("warn log")
 }
 
-func TestFilterCaller(t *testing.T) {
+func TestFilterCaller(_ *testing.T) {
 	logger := With(DefaultLogger, "ts", DefaultTimestamp, "caller", DefaultCaller)
 	log := NewFilter(logger)
 	_ = log.Log(LevelDebug, "msg1", "te1st debug")
@@ -39,19 +39,19 @@ func TestFilterCaller(t *testing.T) {
 	logHelper.Log(LevelDebug, "msg1", "te1st debug")
 }
 
-func TestFilterKey(t *testing.T) {
+func TestFilterKey(_ *testing.T) {
 	logger := With(DefaultLogger, "ts", DefaultTimestamp, "caller", DefaultCaller)
 	log := NewHelper(NewFilter(logger, FilterKey("password")))
 	log.Debugw("password", "123456")
 }
 
-func TestFilterValue(t *testing.T) {
+func TestFilterValue(_ *testing.T) {
 	logger := With(DefaultLogger, "ts", DefaultTimestamp, "caller", DefaultCaller)
 	log := NewHelper(NewFilter(logger, FilterValue("debug")))
 	log.Debugf("test %s", "debug")
 }
 
-func TestFilterFunc(t *testing.T) {
+func TestFilterFunc(_ *testing.T) {
 	logger := With(DefaultLogger, "ts", DefaultTimestamp, "caller", DefaultCaller)
 	log := NewHelper(NewFilter(logger, FilterFunc(testFilterFunc)))
 	log.Debug("debug level")
diff --git a/log/helper_test.go b/log/helper_test.go
index 0cb4ba87..c52f338b 100644
--- a/log/helper_test.go
+++ b/log/helper_test.go
@@ -7,7 +7,7 @@ import (
 	"testing"
 )
 
-func TestHelper(t *testing.T) {
+func TestHelper(_ *testing.T) {
 	logger := With(DefaultLogger, "ts", DefaultTimestamp, "caller", DefaultCaller)
 	log := NewHelper(logger)
 
@@ -21,14 +21,14 @@ func TestHelper(t *testing.T) {
 	log.Warnw("log", "test warn")
 }
 
-func TestHelperWithMsgKey(t *testing.T) {
+func TestHelperWithMsgKey(_ *testing.T) {
 	logger := With(DefaultLogger, "ts", DefaultTimestamp, "caller", DefaultCaller)
 	log := NewHelper(logger, WithMessageKey("message"))
 	log.Debugf("test %s", "debug")
 	log.Debugw("log", "test debug")
 }
 
-func TestHelperLevel(t *testing.T) {
+func TestHelperLevel(_ *testing.T) {
 	log := NewHelper(DefaultLogger)
 	log.Debug("test debug")
 	log.Info("test info")
@@ -62,7 +62,7 @@ func BenchmarkHelperPrintw(b *testing.B) {
 
 type traceKey struct{}
 
-func TestContext(t *testing.T) {
+func TestContext(_ *testing.T) {
 	logger := With(NewStdLogger(os.Stdout),
 		"trace", Trace(),
 	)
diff --git a/log/log_test.go b/log/log_test.go
index 38417f76..8221d9ef 100644
--- a/log/log_test.go
+++ b/log/log_test.go
@@ -5,13 +5,13 @@ import (
 	"testing"
 )
 
-func TestInfo(t *testing.T) {
+func TestInfo(_ *testing.T) {
 	logger := DefaultLogger
 	logger = With(logger, "ts", DefaultTimestamp)
 	logger = With(logger, "caller", DefaultCaller)
 	_ = logger.Log(LevelInfo, "key1", "value1")
 }
 
-func TestWithContext(t *testing.T) {
+func TestWithContext(_ *testing.T) {
 	WithContext(context.Background(), nil)
 }
diff --git a/log/std_test.go b/log/std_test.go
index e9da7730..2518a046 100644
--- a/log/std_test.go
+++ b/log/std_test.go
@@ -2,7 +2,7 @@ package log
 
 import "testing"
 
-func TestStdLogger(t *testing.T) {
+func TestStdLogger(_ *testing.T) {
 	logger := DefaultLogger
 	logger = With(logger, "caller", DefaultCaller, "ts", DefaultTimestamp)
 
diff --git a/middleware/circuitbreaker/circuitbreaker_test.go b/middleware/circuitbreaker/circuitbreaker_test.go
index 611419c7..3b27da1a 100644
--- a/middleware/circuitbreaker/circuitbreaker_test.go
+++ b/middleware/circuitbreaker/circuitbreaker_test.go
@@ -57,7 +57,7 @@ func Test_WithGroup(t *testing.T) {
 	}
 }
 
-func Test_Server(t *testing.T) {
+func TestServer(_ *testing.T) {
 	nextValid := func(ctx context.Context, req interface{}) (interface{}, error) {
 		return "Hello valid", nil
 	}
diff --git a/middleware/metrics/metrics_test.go b/middleware/metrics/metrics_test.go
index 9cf261ce..72b3137d 100644
--- a/middleware/metrics/metrics_test.go
+++ b/middleware/metrics/metrics_test.go
@@ -21,7 +21,7 @@ type (
 	}
 )
 
-func (m *mockCounter) With(lvs ...string) metrics.Counter {
+func (m *mockCounter) With(_ ...string) metrics.Counter {
 	return m
 }
 
@@ -33,7 +33,7 @@ func (m *mockCounter) Add(delta float64) {
 	m.value += delta
 }
 
-func (m *mockObserver) With(lvs ...string) metrics.Observer {
+func (m *mockObserver) With(_ ...string) metrics.Observer {
 	return m
 }
 
diff --git a/middleware/ratelimit/ratelimit_test.go b/middleware/ratelimit/ratelimit_test.go
index 2e4e5bde..b1422347 100644
--- a/middleware/ratelimit/ratelimit_test.go
+++ b/middleware/ratelimit/ratelimit_test.go
@@ -40,7 +40,7 @@ func Test_WithLimiter(t *testing.T) {
 	}
 }
 
-func Test_Server(t *testing.T) {
+func TestServer(t *testing.T) {
 	nextValid := func(ctx context.Context, req interface{}) (interface{}, error) {
 		return "Hello valid", nil
 	}
diff --git a/middleware/tracing/span_test.go b/middleware/tracing/span_test.go
index 110dc6f5..6929ece1 100644
--- a/middleware/tracing/span_test.go
+++ b/middleware/tracing/span_test.go
@@ -178,7 +178,7 @@ func Test_parseTarget(t *testing.T) {
 	}
 }
 
-func Test_setServerSpan(t *testing.T) {
+func TestSetServerSpan(_ *testing.T) {
 	ctx := context.Background()
 	_, span := trace.NewNoopTracerProvider().Tracer("Tracer").Start(ctx, "Spanname")
 
@@ -211,7 +211,7 @@ func Test_setServerSpan(t *testing.T) {
 	setServerSpan(ctx, span, m)
 }
 
-func Test_setClientSpan(t *testing.T) {
+func TestSetClientSpan(_ *testing.T) {
 	ctx := context.Background()
 	_, span := trace.NewNoopTracerProvider().Tracer("Tracer").Start(ctx, "Spanname")
 
diff --git a/middleware/tracing/statsHandler_test.go b/middleware/tracing/statsHandler_test.go
index d8a38dcd..ec7ea06a 100644
--- a/middleware/tracing/statsHandler_test.go
+++ b/middleware/tracing/statsHandler_test.go
@@ -14,7 +14,7 @@ type ctxKey string
 
 const testKey ctxKey = "MY_TEST_KEY"
 
-func Test_Client_HandleConn(t *testing.T) {
+func TestClient_HandleConn(_ *testing.T) {
 	(&ClientHandler{}).HandleConn(context.Background(), nil)
 }
 
@@ -47,7 +47,7 @@ func (m *mockSpan) SpanContext() trace.SpanContext {
 	return *m.mockSpanCtx
 }
 
-func Test_Client_HandleRPC(t *testing.T) {
+func TestClient_HandleRPC(_ *testing.T) {
 	client := &ClientHandler{}
 	ctx := context.Background()
 	rs := stats.OutHeader{}
diff --git a/middleware/tracing/tracer_test.go b/middleware/tracing/tracer_test.go
index af63844e..8983a073 100644
--- a/middleware/tracing/tracer_test.go
+++ b/middleware/tracing/tracer_test.go
@@ -10,7 +10,7 @@ import (
 	"github.com/go-kratos/kratos/v2/internal/testdata/binding"
 )
 
-func Test_NewTracer(t *testing.T) {
+func TestNewTracer(t *testing.T) {
 	tracer := NewTracer(trace.SpanKindClient, func(o *options) {
 		o.tracerProvider = trace.NewNoopTracerProvider()
 	})
@@ -29,7 +29,7 @@ func Test_NewTracer(t *testing.T) {
 	})
 }
 
-func Test_Tracer_End(t *testing.T) {
+func TestTracer_End(_ *testing.T) {
 	tracer := NewTracer(trace.SpanKindClient, func(o *options) {
 		o.tracerProvider = trace.NewNoopTracerProvider()
 	})
diff --git a/options_test.go b/options_test.go
index 60600173..e1b7288b 100644
--- a/options_test.go
+++ b/options_test.go
@@ -86,8 +86,8 @@ func TestLogger(t *testing.T) {
 
 type mockServer struct{}
 
-func (m *mockServer) Start(ctx context.Context) error { return nil }
-func (m *mockServer) Stop(ctx context.Context) error  { return nil }
+func (m *mockServer) Start(_ context.Context) error { return nil }
+func (m *mockServer) Stop(_ context.Context) error  { return nil }
 
 func TestServer(t *testing.T) {
 	o := &options{}
@@ -118,11 +118,11 @@ func TestSignal(t *testing.T) {
 
 type mockRegistrar struct{}
 
-func (m *mockRegistrar) Register(ctx context.Context, service *registry.ServiceInstance) error {
+func (m *mockRegistrar) Register(_ context.Context, _ *registry.ServiceInstance) error {
 	return nil
 }
 
-func (m *mockRegistrar) Deregister(ctx context.Context, service *registry.ServiceInstance) error {
+func (m *mockRegistrar) Deregister(_ context.Context, _ *registry.ServiceInstance) error {
 	return nil
 }
 
diff --git a/selector/selector_test.go b/selector/selector_test.go
index ca30fc0a..b7b963f0 100644
--- a/selector/selector_test.go
+++ b/selector/selector_test.go
@@ -71,7 +71,7 @@ func (b *mockBalancerBuilder) Build() Balancer {
 
 type mockBalancer struct{}
 
-func (b *mockBalancer) Pick(ctx context.Context, nodes []WeightedNode) (selected WeightedNode, done DoneFunc, err error) {
+func (b *mockBalancer) Pick(_ context.Context, nodes []WeightedNode) (selected WeightedNode, done DoneFunc, err error) {
 	if len(nodes) == 0 {
 		err = ErrNoAvailable
 		return
@@ -90,7 +90,7 @@ func (b *mockMustErrorBalancerBuilder) Build() Balancer {
 
 type mockMustErrorBalancer struct{}
 
-func (b *mockMustErrorBalancer) Pick(ctx context.Context, nodes []WeightedNode) (selected WeightedNode, done DoneFunc, err error) {
+func (b *mockMustErrorBalancer) Pick(_ context.Context, _ []WeightedNode) (selected WeightedNode, done DoneFunc, err error) {
 	return nil, nil, errNodeNotMatch
 }
 
diff --git a/transport/grpc/client_test.go b/transport/grpc/client_test.go
index 7ad55368..b2e5e377 100644
--- a/transport/grpc/client_test.go
+++ b/transport/grpc/client_test.go
@@ -44,11 +44,11 @@ func TestWithMiddleware(t *testing.T) {
 
 type mockRegistry struct{}
 
-func (m *mockRegistry) GetService(ctx context.Context, serviceName string) ([]*registry.ServiceInstance, error) {
+func (m *mockRegistry) GetService(_ context.Context, _ string) ([]*registry.ServiceInstance, error) {
 	return nil, nil
 }
 
-func (m *mockRegistry) Watch(ctx context.Context, serviceName string) (registry.Watcher, error) {
+func (m *mockRegistry) Watch(_ context.Context, _ string) (registry.Watcher, error) {
 	return nil, nil
 }
 
diff --git a/transport/grpc/resolver/direct/builder_test.go b/transport/grpc/resolver/direct/builder_test.go
index 82cd8cd1..d0a347df 100644
--- a/transport/grpc/resolver/direct/builder_test.go
+++ b/transport/grpc/resolver/direct/builder_test.go
@@ -29,11 +29,11 @@ func (m *mockConn) UpdateState(resolver.State) error {
 
 func (m *mockConn) ReportError(error) {}
 
-func (m *mockConn) NewAddress(addresses []resolver.Address) {}
+func (m *mockConn) NewAddress(_ []resolver.Address) {}
 
-func (m *mockConn) NewServiceConfig(serviceConfig string) {}
+func (m *mockConn) NewServiceConfig(_ string) {}
 
-func (m *mockConn) ParseServiceConfig(serviceConfigJSON string) *serviceconfig.ParseResult {
+func (m *mockConn) ParseServiceConfig(_ string) *serviceconfig.ParseResult {
 	return nil
 }
 
diff --git a/transport/grpc/resolver/discovery/builder_test.go b/transport/grpc/resolver/discovery/builder_test.go
index 664b5d44..e216a544 100644
--- a/transport/grpc/resolver/discovery/builder_test.go
+++ b/transport/grpc/resolver/discovery/builder_test.go
@@ -33,18 +33,18 @@ func TestWithTimeout(t *testing.T) {
 func TestDisableDebugLog(t *testing.T) {
 	o := &builder{}
 	DisableDebugLog()(o)
-	if !o.debugLogDisabled {
-		t.Errorf("expected debugLogDisabled true, got %v", o.debugLogDisabled)
+	if o.debugLog {
+		t.Errorf("expected debugLog true, got %v", o.debugLog)
 	}
 }
 
 type mockDiscovery struct{}
 
-func (m *mockDiscovery) GetService(ctx context.Context, serviceName string) ([]*registry.ServiceInstance, error) {
+func (m *mockDiscovery) GetService(_ context.Context, _ string) ([]*registry.ServiceInstance, error) {
 	return nil, nil
 }
 
-func (m *mockDiscovery) Watch(ctx context.Context, serviceName string) (registry.Watcher, error) {
+func (m *mockDiscovery) Watch(_ context.Context, _ string) (registry.Watcher, error) {
 	time.Sleep(time.Microsecond * 500)
 	return &testWatch{}, nil
 }
@@ -64,11 +64,11 @@ func (m *mockConn) UpdateState(resolver.State) error {
 
 func (m *mockConn) ReportError(error) {}
 
-func (m *mockConn) NewAddress(addresses []resolver.Address) {}
+func (m *mockConn) NewAddress(_ []resolver.Address) {}
 
-func (m *mockConn) NewServiceConfig(serviceConfig string) {}
+func (m *mockConn) NewServiceConfig(_ string) {}
 
-func (m *mockConn) ParseServiceConfig(serviceConfigJSON string) *serviceconfig.ParseResult {
+func (m *mockConn) ParseServiceConfig(_ string) *serviceconfig.ParseResult {
 	return nil
 }
 
diff --git a/transport/grpc/server_test.go b/transport/grpc/server_test.go
index 4db44fe9..d9d2c7af 100644
--- a/transport/grpc/server_test.go
+++ b/transport/grpc/server_test.go
@@ -56,7 +56,7 @@ func (s *server) SayHelloStream(streamServer pb.Greeter_SayHelloStreamServer) er
 }
 
 // SayHello implements helloworld.GreeterServer
-func (s *server) SayHello(ctx context.Context, in *pb.HelloRequest) (*pb.HelloReply, error) {
+func (s *server) SayHello(_ context.Context, in *pb.HelloRequest) (*pb.HelloReply, error) {
 	if in.Name == "error" {
 		return nil, errors.BadRequest("custom_error", fmt.Sprintf("invalid argument %s", in.Name))
 	}
diff --git a/transport/http/client_test.go b/transport/http/client_test.go
index 9a0dd782..063878af 100644
--- a/transport/http/client_test.go
+++ b/transport/http/client_test.go
@@ -10,13 +10,12 @@ import (
 	"io"
 	"log"
 	"net/http"
-	nethttp "net/http"
 	"reflect"
 	"strconv"
 	"testing"
 	"time"
 
-	kratosErrors "github.com/go-kratos/kratos/v2/errors"
+	kratoserrors "github.com/go-kratos/kratos/v2/errors"
 	"github.com/go-kratos/kratos/v2/middleware"
 	"github.com/go-kratos/kratos/v2/registry"
 	"github.com/go-kratos/kratos/v2/selector"
@@ -24,7 +23,7 @@ import (
 
 type mockRoundTripper struct{}
 
-func (rt *mockRoundTripper) RoundTrip(req *nethttp.Request) (resp *nethttp.Response, err error) {
+func (rt *mockRoundTripper) RoundTrip(_ *http.Request) (resp *http.Response, err error) {
 	return
 }
 
@@ -32,14 +31,14 @@ type mockCallOption struct {
 	needErr bool
 }
 
-func (x *mockCallOption) before(info *callInfo) error {
+func (x *mockCallOption) before(_ *callInfo) error {
 	if x.needErr {
 		return errors.New("option need return err")
 	}
 	return nil
 }
 
-func (x *mockCallOption) after(info *callInfo, attempt *csAttempt) {
+func (x *mockCallOption) after(_ *callInfo, _ *csAttempt) {
 	log.Println("run in mockCallOption.after")
 }
 
@@ -72,7 +71,8 @@ func TestWithBlock(t *testing.T) {
 	}
 }
 
-func TestWithBalancer(t *testing.T) {
+func TestWithBalancer(_ *testing.T) {
+	// TODO
 }
 
 func TestWithTLSConfig(t *testing.T) {
@@ -129,7 +129,7 @@ func TestWithRequestEncoder(t *testing.T) {
 
 func TestWithResponseDecoder(t *testing.T) {
 	o := &clientOptions{}
-	v := func(ctx context.Context, res *nethttp.Response, out interface{}) error { return nil }
+	v := func(ctx context.Context, res *http.Response, out interface{}) error { return nil }
 	WithResponseDecoder(v)(o)
 	if o.decoder == nil {
 		t.Errorf("expected encoder to be not nil")
@@ -138,7 +138,7 @@ func TestWithResponseDecoder(t *testing.T) {
 
 func TestWithErrorDecoder(t *testing.T) {
 	o := &clientOptions{}
-	v := func(ctx context.Context, res *nethttp.Response) error { return nil }
+	v := func(ctx context.Context, res *http.Response) error { return nil }
 	WithErrorDecoder(v)(o)
 	if o.errorDecoder == nil {
 		t.Errorf("expected encoder to be not nil")
@@ -147,11 +147,11 @@ func TestWithErrorDecoder(t *testing.T) {
 
 type mockDiscovery struct{}
 
-func (*mockDiscovery) GetService(ctx context.Context, serviceName string) ([]*registry.ServiceInstance, error) {
+func (*mockDiscovery) GetService(_ context.Context, _ string) ([]*registry.ServiceInstance, error) {
 	return nil, nil
 }
 
-func (*mockDiscovery) Watch(ctx context.Context, serviceName string) (registry.Watcher, error) {
+func (*mockDiscovery) Watch(_ context.Context, _ string) (registry.Watcher, error) {
 	return &mockWatcher{}, nil
 }
 
@@ -199,27 +199,24 @@ func TestWithNodeFilter(t *testing.T) {
 }
 
 func TestDefaultRequestEncoder(t *testing.T) {
-	req1 := &nethttp.Request{
-		Header: make(nethttp.Header),
-		Body:   io.NopCloser(bytes.NewBufferString("{\"a\":\"1\", \"b\": 2}")),
-	}
-	req1.Header.Set("Content-Type", "application/xml")
+	r, _ := http.NewRequest(http.MethodPost, "", io.NopCloser(bytes.NewBufferString(`{"a":"1", "b": 2}`)))
+	r.Header.Set("Content-Type", "application/xml")
 
 	v1 := &struct {
 		A string `json:"a"`
 		B int64  `json:"b"`
 	}{"a", 1}
-	b, err1 := DefaultRequestEncoder(context.TODO(), "application/json", v1)
-	if err1 != nil {
-		t.Errorf("expected no error, got %v", err1)
+	b, err := DefaultRequestEncoder(context.TODO(), "application/json", v1)
+	if err != nil {
+		t.Fatal(err)
 	}
 	v1b := &struct {
 		A string `json:"a"`
 		B int64  `json:"b"`
 	}{}
-	err1 = json.Unmarshal(b, v1b)
-	if err1 != nil {
-		t.Errorf("expected no error, got %v", err1)
+	err = json.Unmarshal(b, v1b)
+	if err != nil {
+		t.Fatal(err)
 	}
 	if !reflect.DeepEqual(v1b, v1) {
 		t.Errorf("expected %v, got %v", v1, v1b)
@@ -227,8 +224,8 @@ func TestDefaultRequestEncoder(t *testing.T) {
 }
 
 func TestDefaultResponseDecoder(t *testing.T) {
-	resp1 := &nethttp.Response{
-		Header:     make(nethttp.Header),
+	resp1 := &http.Response{
+		Header:     make(http.Header),
 		StatusCode: 200,
 		Body:       io.NopCloser(bytes.NewBufferString("{\"a\":\"1\", \"b\": 2}")),
 	}
@@ -236,19 +233,19 @@ func TestDefaultResponseDecoder(t *testing.T) {
 		A string `json:"a"`
 		B int64  `json:"b"`
 	}{}
-	err1 := DefaultResponseDecoder(context.TODO(), resp1, &v1)
-	if err1 != nil {
-		t.Errorf("expected no error, got %v", err1)
+	err := DefaultResponseDecoder(context.TODO(), resp1, &v1)
+	if err != nil {
+		t.Fatal(err)
 	}
-	if !reflect.DeepEqual("1", v1.A) {
+	if v1.A != "1" {
 		t.Errorf("expected %v, got %v", "1", v1.A)
 	}
-	if !reflect.DeepEqual(int64(2), v1.B) {
+	if v1.B != int64(2) {
 		t.Errorf("expected %v, got %v", 2, v1.B)
 	}
 
-	resp2 := &nethttp.Response{
-		Header:     make(nethttp.Header),
+	resp2 := &http.Response{
+		Header:     make(http.Header),
 		StatusCode: 200,
 		Body:       io.NopCloser(bytes.NewBufferString("{badjson}")),
 	}
@@ -256,22 +253,22 @@ func TestDefaultResponseDecoder(t *testing.T) {
 		A string `json:"a"`
 		B int64  `json:"b"`
 	}{}
-	err2 := DefaultResponseDecoder(context.TODO(), resp2, &v2)
-	terr1 := &json.SyntaxError{}
-	if !errors.As(err2, &terr1) {
-		t.Errorf("expected %v, got %v", terr1, err2)
+	err = DefaultResponseDecoder(context.TODO(), resp2, &v2)
+	syntaxErr := &json.SyntaxError{}
+	if !errors.As(err, &syntaxErr) {
+		t.Errorf("expected %v, got %v", syntaxErr, err)
 	}
 }
 
 func TestDefaultErrorDecoder(t *testing.T) {
 	for i := 200; i < 300; i++ {
-		resp := &nethttp.Response{Header: make(nethttp.Header), StatusCode: i}
+		resp := &http.Response{Header: make(http.Header), StatusCode: i}
 		if DefaultErrorDecoder(context.TODO(), resp) != nil {
 			t.Errorf("expected no error, got %v", DefaultErrorDecoder(context.TODO(), resp))
 		}
 	}
-	resp1 := &nethttp.Response{
-		Header:     make(nethttp.Header),
+	resp1 := &http.Response{
+		Header:     make(http.Header),
 		StatusCode: 300,
 		Body:       io.NopCloser(bytes.NewBufferString("{\"foo\":\"bar\"}")),
 	}
@@ -279,28 +276,28 @@ func TestDefaultErrorDecoder(t *testing.T) {
 		t.Errorf("expected error, got nil")
 	}
 
-	resp2 := &nethttp.Response{
-		Header:     make(nethttp.Header),
+	resp2 := &http.Response{
+		Header:     make(http.Header),
 		StatusCode: 500,
 		Body:       io.NopCloser(bytes.NewBufferString("{\"code\":54321, \"message\": \"hi\", \"reason\": \"FOO\"}")),
 	}
-	err2 := DefaultErrorDecoder(context.TODO(), resp2)
-	if err2 == nil {
+	err := DefaultErrorDecoder(context.TODO(), resp2)
+	if err == nil {
 		t.Errorf("expected error, got nil")
 	}
-	if !reflect.DeepEqual(int32(500), err2.(*kratosErrors.Error).Code) {
-		t.Errorf("expected %v, got %v", 500, err2.(*kratosErrors.Error).Code)
+	if err.(*kratoserrors.Error).Code != int32(500) {
+		t.Errorf("expected %v, got %v", 500, err.(*kratoserrors.Error).Code)
 	}
-	if !reflect.DeepEqual("hi", err2.(*kratosErrors.Error).Message) {
-		t.Errorf("expected %v, got %v", "hi", err2.(*kratosErrors.Error).Message)
+	if err.(*kratoserrors.Error).Message != "hi" {
+		t.Errorf("expected %v, got %v", "hi", err.(*kratoserrors.Error).Message)
 	}
-	if !reflect.DeepEqual("FOO", err2.(*kratosErrors.Error).Reason) {
-		t.Errorf("expected %v, got %v", "FOO", err2.(*kratosErrors.Error).Reason)
+	if err.(*kratoserrors.Error).Reason != "FOO" {
+		t.Errorf("expected %v, got %v", "FOO", err.(*kratoserrors.Error).Reason)
 	}
 }
 
 func TestCodecForResponse(t *testing.T) {
-	resp := &nethttp.Response{Header: make(nethttp.Header)}
+	resp := &http.Response{Header: make(http.Header)}
 	resp.Header.Set("Content-Type", "application/xml")
 	c := CodecForResponse(resp)
 	if !reflect.DeepEqual("xml", c.Name()) {
@@ -346,7 +343,7 @@ func TestNewClient(t *testing.T) {
 		}),
 	)
 	if err != nil {
-		t.Error(err)
+		t.Fatal(err)
 	}
 
 	err = client.Invoke(context.Background(), http.MethodPost, "/go", map[string]string{"name": "kratos"}, nil, EmptyCallOption{}, &mockCallOption{})
diff --git a/transport/http/codec_test.go b/transport/http/codec_test.go
index b701b70f..8efd2332 100644
--- a/transport/http/codec_test.go
+++ b/transport/http/codec_test.go
@@ -3,53 +3,50 @@ package http
 import (
 	"bytes"
 	"io"
-	nethttp "net/http"
-	"reflect"
+	"net/http"
 	"testing"
 
 	"github.com/go-kratos/kratos/v2/errors"
 )
 
 func TestDefaultRequestDecoder(t *testing.T) {
-	bodyString := "{\"a\":\"1\", \"b\": 2}"
-
-	req1 := &nethttp.Request{
-		Header: make(nethttp.Header),
-		Body:   io.NopCloser(bytes.NewBufferString(bodyString)),
-	}
-	req1.Header.Set("Content-Type", "application/json")
+	var (
+		bodyStr = `{"a":"1", "b": 2}`
+		r, _    = http.NewRequest(http.MethodPost, "", io.NopCloser(bytes.NewBufferString(bodyStr)))
+	)
+	r.Header.Set("Content-Type", "application/json")
 
 	v1 := &struct {
 		A string `json:"a"`
 		B int64  `json:"b"`
 	}{}
-	err1 := DefaultRequestDecoder(req1, &v1)
-	if err1 != nil {
-		t.Errorf("expected no error, got %v", err1)
+	err := DefaultRequestDecoder(r, &v1)
+	if err != nil {
+		t.Fatal(err)
 	}
-	if !reflect.DeepEqual("1", v1.A) {
+	if v1.A != "1" {
 		t.Errorf("expected %v, got %v", "1", v1.A)
 	}
-	if !reflect.DeepEqual(int64(2), v1.B) {
+	if v1.B != int64(2) {
 		t.Errorf("expected %v, got %v", 2, v1.B)
 	}
 
-	data, err := io.ReadAll(req1.Body)
+	data, err := io.ReadAll(r.Body)
 	if err != nil {
-		t.Errorf("expected no error, got %v", err1)
+		t.Fatal(err)
 	}
-	if !reflect.DeepEqual([]byte(bodyString), data) {
-		t.Errorf("expected %v, got %v", bodyString, data)
+	if bodyStr != string(data) {
+		t.Errorf("expected %v, got %v", bodyStr, string(data))
 	}
 }
 
 type mockResponseWriter struct {
 	StatusCode int
 	Data       []byte
-	header     nethttp.Header
+	header     http.Header
 }
 
-func (w *mockResponseWriter) Header() nethttp.Header {
+func (w *mockResponseWriter) Header() http.Header {
 	return w.header
 }
 
@@ -62,27 +59,28 @@ func (w *mockResponseWriter) WriteHeader(statusCode int) {
 	w.StatusCode = statusCode
 }
 
-type dataWithStatusCode struct {
-	A string `json:"a"`
-	B int64  `json:"b"`
-}
-
 func TestDefaultResponseEncoder(t *testing.T) {
-	w := &mockResponseWriter{StatusCode: 200, header: make(nethttp.Header)}
-	req1 := &nethttp.Request{
-		Header: make(nethttp.Header),
-	}
-	req1.Header.Set("Content-Type", "application/json")
-
-	v1 := &dataWithStatusCode{A: "1", B: 2}
-	err := DefaultResponseEncoder(w, req1, v1)
+	var (
+		w    = &mockResponseWriter{StatusCode: 200, header: make(http.Header)}
+		r, _ = http.NewRequest(http.MethodPost, "", nil)
+		v    = &struct {
+			A string `json:"a"`
+			B int64  `json:"b"`
+		}{
+			A: "1",
+			B: 2,
+		}
+	)
+	r.Header.Set("Content-Type", "application/json")
+
+	err := DefaultResponseEncoder(w, r, v)
 	if err != nil {
-		t.Errorf("expected no error, got %v", err)
+		t.Fatal(err)
 	}
-	if !reflect.DeepEqual("application/json", w.Header().Get("Content-Type")) {
+	if w.Header().Get("Content-Type") != "application/json" {
 		t.Errorf("expected %v, got %v", "application/json", w.Header().Get("Content-Type"))
 	}
-	if !reflect.DeepEqual(200, w.StatusCode) {
+	if w.StatusCode != 200 {
 		t.Errorf("expected %v, got %v", 200, w.StatusCode)
 	}
 	if w.Data == nil {
@@ -90,19 +88,19 @@ func TestDefaultResponseEncoder(t *testing.T) {
 	}
 }
 
-func TestDefaultResponseEncoderWithError(t *testing.T) {
-	w := &mockResponseWriter{header: make(nethttp.Header)}
-	req := &nethttp.Request{
-		Header: make(nethttp.Header),
-	}
-	req.Header.Set("Content-Type", "application/json")
+func TestDefaultErrorEncoder(t *testing.T) {
+	var (
+		w    = &mockResponseWriter{header: make(http.Header)}
+		r, _ = http.NewRequest(http.MethodPost, "", nil)
+		err  = errors.New(511, "", "")
+	)
+	r.Header.Set("Content-Type", "application/json")
 
-	se := errors.New(511, "", "")
-	DefaultErrorEncoder(w, req, se)
-	if !reflect.DeepEqual("application/json", w.Header().Get("Content-Type")) {
+	DefaultErrorEncoder(w, r, err)
+	if w.Header().Get("Content-Type") != "application/json" {
 		t.Errorf("expected %v, got %v", "application/json", w.Header().Get("Content-Type"))
 	}
-	if !reflect.DeepEqual(511, w.StatusCode) {
+	if w.StatusCode != 511 {
 		t.Errorf("expected %v, got %v", 511, w.StatusCode)
 	}
 	if w.Data == nil {
@@ -111,20 +109,20 @@ func TestDefaultResponseEncoderWithError(t *testing.T) {
 }
 
 func TestDefaultResponseEncoderEncodeNil(t *testing.T) {
-	w := &mockResponseWriter{StatusCode: 204, header: make(nethttp.Header)}
-	req1 := &nethttp.Request{
-		Header: make(nethttp.Header),
-	}
-	req1.Header.Set("Content-Type", "application/json")
+	var (
+		w    = &mockResponseWriter{StatusCode: 204, header: make(http.Header)}
+		r, _ = http.NewRequest(http.MethodPost, "", io.NopCloser(bytes.NewBufferString("<xml></xml>")))
+	)
+	r.Header.Set("Content-Type", "application/json")
 
-	err := DefaultResponseEncoder(w, req1, nil)
+	err := DefaultResponseEncoder(w, r, nil)
 	if err != nil {
-		t.Errorf("expected no error, got %v", err)
+		t.Fatal(err)
 	}
-	if !reflect.DeepEqual("", w.Header().Get("Content-Type")) {
+	if w.Header().Get("Content-Type") != "" {
 		t.Errorf("expected empty string, got %v", w.Header().Get("Content-Type"))
 	}
-	if !reflect.DeepEqual(204, w.StatusCode) {
+	if w.StatusCode != 204 {
 		t.Errorf("expected %v, got %v", 204, w.StatusCode)
 	}
 	if w.Data != nil {
@@ -133,31 +131,23 @@ func TestDefaultResponseEncoderEncodeNil(t *testing.T) {
 }
 
 func TestCodecForRequest(t *testing.T) {
-	req1 := &nethttp.Request{
-		Header: make(nethttp.Header),
-		Body:   io.NopCloser(bytes.NewBufferString("<xml></xml>")),
-	}
-	req1.Header.Set("Content-Type", "application/xml")
-
-	c, ok := CodecForRequest(req1, "Content-Type")
+	r, _ := http.NewRequest(http.MethodPost, "", io.NopCloser(bytes.NewBufferString("<xml></xml>")))
+	r.Header.Set("Content-Type", "application/xml")
+	c, ok := CodecForRequest(r, "Content-Type")
 	if !ok {
-		t.Errorf("expected true, got %v", ok)
+		t.Fatalf("expected true, got %v", ok)
 	}
-	if !reflect.DeepEqual("xml", c.Name()) {
+	if c.Name() != "xml" {
 		t.Errorf("expected %v, got %v", "xml", c.Name())
 	}
 
-	req2 := &nethttp.Request{
-		Header: make(nethttp.Header),
-		Body:   io.NopCloser(bytes.NewBufferString("{\"a\":\"1\", \"b\": 2}")),
-	}
-	req2.Header.Set("Content-Type", "blablablabla")
-
-	c, ok = CodecForRequest(req2, "Content-Type")
+	r, _ = http.NewRequest(http.MethodPost, "", io.NopCloser(bytes.NewBufferString(`{"a":"1", "b": 2}`)))
+	r.Header.Set("Content-Type", "blablablabla")
+	c, ok = CodecForRequest(r, "Content-Type")
 	if ok {
-		t.Errorf("expected false, got %v", ok)
+		t.Fatalf("expected false, got %v", ok)
 	}
-	if !reflect.DeepEqual("json", c.Name()) {
+	if c.Name() != "json" {
 		t.Errorf("expected %v, got %v", "json", c.Name())
 	}
 }
diff --git a/transport/http/resolver_test.go b/transport/http/resolver_test.go
index 4dfe3c5c..e1cfd103 100644
--- a/transport/http/resolver_test.go
+++ b/transport/http/resolver_test.go
@@ -57,7 +57,7 @@ func TestParseTarget(t *testing.T) {
 
 type mockRebalancer struct{}
 
-func (m *mockRebalancer) Apply(nodes []selector.Node) {}
+func (m *mockRebalancer) Apply(_ []selector.Node) {}
 
 type mockDiscoveries struct {
 	isSecure bool
@@ -65,7 +65,7 @@ type mockDiscoveries struct {
 	stopErr  bool
 }
 
-func (d *mockDiscoveries) GetService(ctx context.Context, serviceName string) ([]*registry.ServiceInstance, error) {
+func (d *mockDiscoveries) GetService(_ context.Context, _ string) ([]*registry.ServiceInstance, error) {
 	return nil, nil
 }
 
diff --git a/transport/http/router_test.go b/transport/http/router_test.go
index 747ebf05..1849939d 100644
--- a/transport/http/router_test.go
+++ b/transport/http/router_test.go
@@ -179,7 +179,7 @@ func TestRouter_Group(t *testing.T) {
 	}
 }
 
-func TestHandle(t *testing.T) {
+func TestHandle(_ *testing.T) {
 	r := newRouter("/", NewServer())
 	h := func(i Context) error {
 		return nil
diff --git a/transport/http/server_test.go b/transport/http/server_test.go
index 22865fc3..781c06a7 100644
--- a/transport/http/server_test.go
+++ b/transport/http/server_test.go
@@ -308,8 +308,8 @@ func TestTimeout(t *testing.T) {
 	}
 }
 
-func TestLogger(t *testing.T) {
-	// todo
+func TestLogger(_ *testing.T) {
+	// TODO
 }
 
 func TestRequestDecoder(t *testing.T) {