Browse Source

refactor: Remove unnecessary type conversions (#772)

Bo-Yi Wu 3 years ago
parent
commit
25663b5816
4 changed files with 5 additions and 5 deletions
  1. 1 1
      models/ssh_key.go
  2. 1 1
      modules/lfs/server.go
  3. 1 1
      modules/markdown/markdown.go
  4. 2 2
      modules/templates/helper.go

+ 1 - 1
models/ssh_key.go

@@ -219,7 +219,7 @@ func SSHKeyGenParsePublicKey(key string) (string, int, error) {
219 219
 func SSHNativeParsePublicKey(keyLine string) (string, int, error) {
220 220
 	fields := strings.Fields(keyLine)
221 221
 	if len(fields) < 2 {
222
-		return "", 0, fmt.Errorf("not enough fields in public key line: %s", string(keyLine))
222
+		return "", 0, fmt.Errorf("not enough fields in public key line: %s", keyLine)
223 223
 	}
224 224
 
225 225
 	raw, err := base64.StdEncoding.DecodeString(fields[1])

+ 1 - 1
modules/lfs/server.go

@@ -132,7 +132,7 @@ func GetContentHandler(ctx *context.Context) {
132 132
 		if match != nil && len(match) > 1 {
133 133
 			statusCode = 206
134 134
 			fromByte, _ = strconv.ParseInt(match[1], 10, 32)
135
-			ctx.Resp.Header().Set("Content-Range", fmt.Sprintf("bytes %d-%d/%d", fromByte, meta.Size-1, int64(meta.Size)-fromByte))
135
+			ctx.Resp.Header().Set("Content-Range", fmt.Sprintf("bytes %d-%d/%d", fromByte, meta.Size-1, meta.Size-fromByte))
136 136
 		}
137 137
 	}
138 138
 

+ 1 - 1
modules/markdown/markdown.go

@@ -301,7 +301,7 @@ func RenderSha1CurrentPattern(rawBytes []byte, urlPrefix string) []byte {
301 301
 		if com.StrTo(m).MustInt() > 0 {
302 302
 			return m
303 303
 		}
304
-		return fmt.Sprintf(`<a href="%s/commit/%s"><code>%s</code></a>`, urlPrefix, m, base.ShortSha(string(m)))
304
+		return fmt.Sprintf(`<a href="%s/commit/%s"><code>%s</code></a>`, urlPrefix, m, base.ShortSha(m))
305 305
 	}))
306 306
 }
307 307
 

+ 2 - 2
modules/templates/helper.go

@@ -121,8 +121,8 @@ func NewFuncMap() []template.FuncMap {
121 121
 			var path []string
122 122
 			index := strings.LastIndex(str, "/")
123 123
 			if index != -1 && index != len(str) {
124
-				path = append(path, string(str[0:index+1]))
125
-				path = append(path, string(str[index+1:]))
124
+				path = append(path, str[0:index+1])
125
+				path = append(path, str[index+1:])
126 126
 			} else {
127 127
 				path = append(path, str)
128 128
 			}