Browse Source

add ineffassign check

tags/v1.10.0
astaxie 2 years ago
parent
commit
e1f3353511

+ 2
- 0
.travis.yml View File

@@ -10,6 +10,7 @@ install:
10 10
   - go get -u honnef.co/go/tools/cmd/staticcheck
11 11
   - go get -u honnef.co/go/tools/cmd/unused
12 12
   - go get -u github.com/mdempsky/unconvert
13
+  - go get -u github.com/gordonklaus/ineffassign
13 14
 script:
14 15
   - find . ! \( -path './vendor' -prune \) -type f -name '*.go' -print0 | xargs -0 gofmt -l -s
15 16
   - go vet  $(go list ./... | grep -v /vendor/)
@@ -18,3 +19,4 @@ script:
18 19
   - staticcheck $(go list ./... | grep -v /vendor/)
19 20
   - unused $(go list ./... | grep -v /vendor/)
20 21
   - unconvert $(go list ./... | grep -v /vendor/)
22
+  - ineffassign .

+ 1
- 1
cmd/commands/pack/pack.go View File

@@ -417,7 +417,7 @@ func packDirectory(output io.Writer, excludePrefix []string, excludeSuffix []str
417 417
 func packApp(cmd *commands.Command, args []string) int {
418 418
 	output := cmd.Out()
419 419
 	curPath, _ := os.Getwd()
420
-	thePath := ""
420
+	var thePath string
421 421
 
422 422
 	nArgs := []string{}
423 423
 	has := false

+ 2
- 4
generate/g_appcode.go View File

@@ -503,9 +503,7 @@ func (mysqlDB *MysqlDB) GetColumns(db *sql.DB, table *Table, blackList map[strin
503 503
 
504 504
 // GetGoDataType maps an SQL data type to Golang data type
505 505
 func (*MysqlDB) GetGoDataType(sqlType string) (string, error) {
506
-	var typeMapping = map[string]string{}
507
-	typeMapping = typeMappingMysql
508
-	if v, ok := typeMapping[sqlType]; ok {
506
+	if v, ok := typeMappingMysql[sqlType]; ok {
509 507
 		return v, nil
510 508
 	}
511 509
 	return "", fmt.Errorf("data type '%s' not found", sqlType)
@@ -766,7 +764,7 @@ func writeModelFiles(tables []*Table, mPath string, selectedTables map[string]bo
766 764
 				continue
767 765
 			}
768 766
 		}
769
-		template := ""
767
+		var template string
770 768
 		if tb.Pk == "" {
771 769
 			template = StructModelTPL
772 770
 		} else {

+ 1
- 1
generate/g_hproseappcode.go View File

@@ -369,7 +369,7 @@ func writeHproseModelFiles(tables []*Table, mPath string, selectedTables map[str
369 369
 				continue
370 370
 			}
371 371
 		}
372
-		template := ""
372
+		var template string
373 373
 		if tb.Pk == "" {
374 374
 			template = HproseStructModelTPL
375 375
 		} else {

+ 2
- 5
generate/swaggergen/g_docs.go View File

@@ -216,7 +216,7 @@ func GenerateDocs(curpath string) {
216 216
 							for _, p := range params {
217 217
 								switch pp := p.(type) {
218 218
 								case *ast.CallExpr:
219
-									controllerName := ""
219
+									var controllerName string
220 220
 									if selname := pp.Fun.(*ast.SelectorExpr).Sel.String(); selname == "NSNamespace" {
221 221
 										s, params := analyseNewNamespace(pp)
222 222
 										for _, sp := range params {
@@ -298,12 +298,10 @@ func analyseNSInclude(baseurl string, ce *ast.CallExpr) string {
298 298
 		}
299 299
 		if apis, ok := controllerList[cname]; ok {
300 300
 			for rt, item := range apis {
301
-				tag := ""
301
+				tag := cname
302 302
 				if baseurl != "" {
303 303
 					rt = baseurl + rt
304 304
 					tag = strings.Trim(baseurl, "/")
305
-				} else {
306
-					tag = cname
307 305
 				}
308 306
 				if item.Get != nil {
309 307
 					item.Get.Tags = []string{tag}
@@ -749,7 +747,6 @@ func parseObject(d *ast.Object, k string, m *swagger.Schema, realTypes *[]string
749 747
 	if st.Fields.List != nil {
750 748
 		m.Properties = make(map[string]swagger.Propertie)
751 749
 		for _, field := range st.Fields.List {
752
-			realType := ""
753 750
 			isSlice, realType, sType := typeAnalyser(field)
754 751
 			if (isSlice && isBasicType(realType)) || sType == "object" {
755 752
 				if len(strings.Split(realType, " ")) > 1 {

+ 1
- 1
logger/colors/colorwriter_windows.go View File

@@ -360,7 +360,7 @@ func isParameterChar(b byte) bool {
360 360
 }
361 361
 
362 362
 func (cw *colorWriter) Write(p []byte) (int, error) {
363
-	r, nw, first, last := 0, 0, 0, 0
363
+	var r, nw, first, last int
364 364
 	if cw.mode != DiscardNonColorEscSeq {
365 365
 		cw.state = outsideCsiCode
366 366
 		cw.resetBuffer()

Loading…
Cancel
Save