瀏覽代碼

Merge pull request #28383 from zteBill/fix-useless-var

Remove needless var
Brian Goff 8 年之前
父節點
當前提交
6969c98a3c
共有 1 個文件被更改,包括 7 次插入6 次删除
  1. 7 6
      api/server/httputils/httputils.go

+ 7 - 6
api/server/httputils/httputils.go

@@ -78,13 +78,14 @@ func ParseForm(r *http.Request) error {
 
 // VersionFromContext returns an API version from the context using APIVersionKey.
 // It panics if the context value does not have version.Version type.
-func VersionFromContext(ctx context.Context) (ver string) {
+func VersionFromContext(ctx context.Context) string {
 	if ctx == nil {
-		return
+		return ""
 	}
-	val := ctx.Value(APIVersionKey)
-	if val == nil {
-		return
+
+	if val := ctx.Value(APIVersionKey); val != nil {
+		return val.(string)
 	}
-	return val.(string)
+
+	return ""
 }