summaryrefslogtreecommitdiffstats
path: root/modules/base
diff options
context:
space:
mode:
authorBo-Yi Wu <appleboy.tw@gmail.com>2019-05-28 23:45:54 +0800
committerGitHub <noreply@github.com>2019-05-28 23:45:54 +0800
commit743697a549bda16508ab961ac79a8bc5bdca3bbd (patch)
tree23d40a210acd7b84dd62f6c5ec73dfea938faa5f /modules/base
parent31557b12744410633ceb6fc12b53fb09038cee35 (diff)
downloadgitea-743697a549bda16508ab961ac79a8bc5bdca3bbd.tar.gz
gitea-743697a549bda16508ab961ac79a8bc5bdca3bbd.zip
refactor: append, build variable and type switch (#4940)
* refactor: append, build variable and type switch * fix: remove redundant space.
Diffstat (limited to 'modules/base')
-rw-r--r--modules/base/tool.go32
-rw-r--r--modules/base/tool_test.go16
2 files changed, 24 insertions, 24 deletions
diff --git a/modules/base/tool.go b/modules/base/tool.go
index 3a6e28a885..dcf9155a07 100644
--- a/modules/base/tool.go
+++ b/modules/base/tool.go
@@ -465,41 +465,41 @@ func Subtract(left interface{}, right interface{}) interface{} {
var rleft, rright int64
var fleft, fright float64
var isInt = true
- switch left := left.(type) {
+ switch v := left.(type) {
case int:
- rleft = int64(left)
+ rleft = int64(v)
case int8:
- rleft = int64(left)
+ rleft = int64(v)
case int16:
- rleft = int64(left)
+ rleft = int64(v)
case int32:
- rleft = int64(left)
+ rleft = int64(v)
case int64:
- rleft = left
+ rleft = v
case float32:
- fleft = float64(left)
+ fleft = float64(v)
isInt = false
case float64:
- fleft = left
+ fleft = v
isInt = false
}
- switch right := right.(type) {
+ switch v := right.(type) {
case int:
- rright = int64(right)
+ rright = int64(v)
case int8:
- rright = int64(right)
+ rright = int64(v)
case int16:
- rright = int64(right)
+ rright = int64(v)
case int32:
- rright = int64(right)
+ rright = int64(v)
case int64:
- rright = right
+ rright = v
case float32:
- fright = float64(right)
+ fright = float64(v)
isInt = false
case float64:
- fright = right
+ fright = v
isInt = false
}
diff --git a/modules/base/tool_test.go b/modules/base/tool_test.go
index dcaf2fcbb0..ec9bc1eb52 100644
--- a/modules/base/tool_test.go
+++ b/modules/base/tool_test.go
@@ -306,21 +306,21 @@ func TestFileSize(t *testing.T) {
func TestSubtract(t *testing.T) {
toFloat64 := func(n interface{}) float64 {
- switch n := n.(type) {
+ switch v := n.(type) {
case int:
- return float64(n)
+ return float64(v)
case int8:
- return float64(n)
+ return float64(v)
case int16:
- return float64(n)
+ return float64(v)
case int32:
- return float64(n)
+ return float64(v)
case int64:
- return float64(n)
+ return float64(v)
case float32:
- return float64(n)
+ return float64(v)
case float64:
- return n
+ return v
default:
return 0.0
}