aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBo-Yi Wu <appleboy.tw@gmail.com>2017-01-27 23:03:32 +0800
committerLunny Xiao <xiaolunwen@gmail.com>2017-01-27 23:03:32 +0800
commit25663b58161c48bdc8e9cae900544378dede0d2b (patch)
tree1d0cab794b549116cf685101a62cc21634356d6b
parent4faf097fb9d07003b52d5f6e51ad3e624a5db062 (diff)
downloadgitea-25663b58161c48bdc8e9cae900544378dede0d2b.tar.gz
gitea-25663b58161c48bdc8e9cae900544378dede0d2b.zip
refactor: Remove unnecessary type conversions (#772)
-rw-r--r--models/ssh_key.go2
-rw-r--r--modules/lfs/server.go2
-rw-r--r--modules/markdown/markdown.go2
-rw-r--r--modules/templates/helper.go4
4 files changed, 5 insertions, 5 deletions
diff --git a/models/ssh_key.go b/models/ssh_key.go
index 2f23026997..3bd2a739df 100644
--- a/models/ssh_key.go
+++ b/models/ssh_key.go
@@ -219,7 +219,7 @@ func SSHKeyGenParsePublicKey(key string) (string, int, error) {
func SSHNativeParsePublicKey(keyLine string) (string, int, error) {
fields := strings.Fields(keyLine)
if len(fields) < 2 {
- return "", 0, fmt.Errorf("not enough fields in public key line: %s", string(keyLine))
+ return "", 0, fmt.Errorf("not enough fields in public key line: %s", keyLine)
}
raw, err := base64.StdEncoding.DecodeString(fields[1])
diff --git a/modules/lfs/server.go b/modules/lfs/server.go
index f82cb70364..1bdeadc463 100644
--- a/modules/lfs/server.go
+++ b/modules/lfs/server.go
@@ -132,7 +132,7 @@ func GetContentHandler(ctx *context.Context) {
if match != nil && len(match) > 1 {
statusCode = 206
fromByte, _ = strconv.ParseInt(match[1], 10, 32)
- ctx.Resp.Header().Set("Content-Range", fmt.Sprintf("bytes %d-%d/%d", fromByte, meta.Size-1, int64(meta.Size)-fromByte))
+ ctx.Resp.Header().Set("Content-Range", fmt.Sprintf("bytes %d-%d/%d", fromByte, meta.Size-1, meta.Size-fromByte))
}
}
diff --git a/modules/markdown/markdown.go b/modules/markdown/markdown.go
index b973b7c836..c0b7c91f83 100644
--- a/modules/markdown/markdown.go
+++ b/modules/markdown/markdown.go
@@ -301,7 +301,7 @@ func RenderSha1CurrentPattern(rawBytes []byte, urlPrefix string) []byte {
if com.StrTo(m).MustInt() > 0 {
return m
}
- return fmt.Sprintf(`<a href="%s/commit/%s"><code>%s</code></a>`, urlPrefix, m, base.ShortSha(string(m)))
+ return fmt.Sprintf(`<a href="%s/commit/%s"><code>%s</code></a>`, urlPrefix, m, base.ShortSha(m))
}))
}
diff --git a/modules/templates/helper.go b/modules/templates/helper.go
index f65b8c6856..0c56ae0e0a 100644
--- a/modules/templates/helper.go
+++ b/modules/templates/helper.go
@@ -121,8 +121,8 @@ func NewFuncMap() []template.FuncMap {
var path []string
index := strings.LastIndex(str, "/")
if index != -1 && index != len(str) {
- path = append(path, string(str[0:index+1]))
- path = append(path, string(str[index+1:]))
+ path = append(path, str[0:index+1])
+ path = append(path, str[index+1:])
} else {
path = append(path, str)
}