summaryrefslogtreecommitdiffstats
path: root/modules/templates/helper.go
diff options
context:
space:
mode:
author6543 <6543@obermui.de>2022-01-20 18:46:10 +0100
committerGitHub <noreply@github.com>2022-01-20 18:46:10 +0100
commit54e9ee37a7a301dbe74d46fd3c87712e6120e9bf (patch)
tree1be12fb072625c1b896b9d72f7912b018aad502b /modules/templates/helper.go
parent1d98d205f5825f40110e6628b61a97c91ac7f72d (diff)
downloadgitea-54e9ee37a7a301dbe74d46fd3c87712e6120e9bf.tar.gz
gitea-54e9ee37a7a301dbe74d46fd3c87712e6120e9bf.zip
format with gofumpt (#18184)
* gofumpt -w -l . * gofumpt -w -l -extra . * Add linter * manual fix * change make fmt
Diffstat (limited to 'modules/templates/helper.go')
-rw-r--r--modules/templates/helper.go16
1 files changed, 9 insertions, 7 deletions
diff --git a/modules/templates/helper.go b/modules/templates/helper.go
index 833b582073..255866e2ed 100644
--- a/modules/templates/helper.go
+++ b/modules/templates/helper.go
@@ -213,7 +213,7 @@ func NewFuncMap() []template.FuncMap {
}
return path
},
- "DiffStatsWidth": func(adds int, dels int) string {
+ "DiffStatsWidth": func(adds, dels int) string {
return fmt.Sprintf("%f", float64(adds)/(float64(adds)+float64(dels))*100)
},
"Json": func(in interface{}) string {
@@ -286,7 +286,7 @@ func NewFuncMap() []template.FuncMap {
return util.MergeInto(dict, values...)
},
"percentage": func(n int, values ...int) float32 {
- var sum = 0
+ sum := 0
for i := 0; i < len(values); i++ {
sum += values[i]
}
@@ -302,7 +302,7 @@ func NewFuncMap() []template.FuncMap {
"EventSourceUpdateTime": int(setting.UI.Notification.EventSourceUpdateTime / time.Millisecond),
}
},
- "containGeneric": func(arr interface{}, v interface{}) bool {
+ "containGeneric": func(arr, v interface{}) bool {
arrV := reflect.ValueOf(arr)
if arrV.Kind() == reflect.String && reflect.ValueOf(v).Kind() == reflect.String {
return strings.Contains(arr.(string), v.(string))
@@ -478,7 +478,7 @@ func NewTextFuncMap() []texttmpl.FuncMap {
return dict, nil
},
"percentage": func(n int, values ...int) float32 {
- var sum = 0
+ sum := 0
for i := 0; i < len(values); i++ {
sum += values[i]
}
@@ -502,8 +502,10 @@ func NewTextFuncMap() []texttmpl.FuncMap {
}}
}
-var widthRe = regexp.MustCompile(`width="[0-9]+?"`)
-var heightRe = regexp.MustCompile(`height="[0-9]+?"`)
+var (
+ widthRe = regexp.MustCompile(`width="[0-9]+?"`)
+ heightRe = regexp.MustCompile(`height="[0-9]+?"`)
+)
func parseOthers(defaultSize int, defaultClass string, others ...interface{}) (int, string) {
size := defaultSize
@@ -741,7 +743,7 @@ func RenderEmoji(text string) template.HTML {
return template.HTML(renderedText)
}
-//ReactionToEmoji renders emoji for use in reactions
+// ReactionToEmoji renders emoji for use in reactions
func ReactionToEmoji(reaction string) template.HTML {
val := emoji.FromCode(reaction)
if val != nil {