Repository: zeromicro/go-zero
Pull request #1700 (2022-03-23 11:00:42)

chore: refactor code


Patch:
diff --git a/tools/goctl/pkg/collection/sortedmap.go b/tools/goctl/pkg/collection/sortedmap.go
index 456170a5..3d4a5506 100644
--- a/tools/goctl/pkg/collection/sortedmap.go
+++ b/tools/goctl/pkg/collection/sortedmap.go
@@ -28,7 +28,7 @@ func New() *SortedMap {
 	}
 }
 
-func (m *SortedMap) SetExpression(expression string) (key interface{}, value interface{}, err error) {
+func (m *SortedMap) SetExpression(expression string) (key, value interface{}, err error) {
 	idx := strings.Index(expression, "=")
 	if idx == -1 {
 		return "", "", ErrInvalidKVExpression
@@ -86,7 +86,7 @@ func (m *SortedMap) Get(key interface{}) (interface{}, bool) {
 	return e.Value.(KV)[1], true
 }
 
-func (m *SortedMap) GetOr(key interface{}, dft interface{}) interface{} {
+func (m *SortedMap) GetOr(key, dft interface{}) interface{} {
 	e, ok := m.keys[key]
 	if !ok {
 		return dft
diff --git a/tools/goctl/pkg/downloader/downloader.go b/tools/goctl/pkg/downloader/downloader.go
index f17a9a20..44c1c5b5 100644
--- a/tools/goctl/pkg/downloader/downloader.go
+++ b/tools/goctl/pkg/downloader/downloader.go
@@ -6,7 +6,7 @@ import (
 	"os"
 )
 
-func Download(url string, filename string) error {
+func Download(url, filename string) error {
 	resp, err := http.Get(url)
 	if err != nil {
 		return err
diff --git a/tools/goctl/pkg/env/env.go b/tools/goctl/pkg/env/env.go
index 0e97e9e6..c240e205 100644
--- a/tools/goctl/pkg/env/env.go
+++ b/tools/goctl/pkg/env/env.go
@@ -88,7 +88,7 @@ func Get(key string) string {
 	return GetOr(key, "")
 }
 
-func GetOr(key string, def string) string {
+func GetOr(key, def string) string {
 	return goctlEnv.GetStringOr(key, def)
 }
 
diff --git a/tools/goctl/util/git.go b/tools/goctl/util/git.go
index 5eed43e5..7a4e56ff 100644
--- a/tools/goctl/util/git.go
+++ b/tools/goctl/util/git.go
@@ -12,7 +12,7 @@ import (
 	"github.com/zeromicro/go-zero/tools/goctl/util/pathx"
 )
 
-func CloneIntoGitHome(url string, branch string) (dir string, err error) {
+func CloneIntoGitHome(url, branch string) (dir string, err error) {
 	gitHome, err := pathx.GetGitHome()
 	if err != nil {
 		return "", err


Test patch:
diff --git a/tools/goctl/rpc/generator/genpb_test.go b/tools/goctl/rpc/generator/genpb_test.go
index 708853b4..04f7fcf8 100644
--- a/tools/goctl/rpc/generator/genpb_test.go
+++ b/tools/goctl/rpc/generator/genpb_test.go
@@ -25,7 +25,7 @@ message Resp{}
 service Greeter {
   rpc greet(Req) returns (Resp);
 }
-`), 0666)
+`), 0o666)
 	if err != nil {
 		t.Log(err)
 		return
diff --git a/tools/goctl/util/pathx/file_test.go b/tools/goctl/util/pathx/file_test.go
index 00690a17..7505fe49 100644
--- a/tools/goctl/util/pathx/file_test.go
+++ b/tools/goctl/util/pathx/file_test.go
@@ -79,7 +79,7 @@ func TestGetGoctlHome(t *testing.T) {
 	t.Run("goctl_is_file", func(t *testing.T) {
 		tmpFile := filepath.Join(t.TempDir(), "a.tmp")
 		backupTempFile := tmpFile + ".old"
-		err := ioutil.WriteFile(tmpFile, nil, 0666)
+		err := ioutil.WriteFile(tmpFile, nil, 0o666)
 		if err != nil {
 			return
 		}
@@ -104,5 +104,4 @@ func TestGetGoctlHome(t *testing.T) {
 		assert.Nil(t, err)
 		assert.Equal(t, dir, home)
 	})
-
 }