Browse code

make each return explicitly Signed-off-by: zteBill <bi.zhenkun@zte.com.cn>

zteBill authored on 2016/11/15 02:15:24
Showing 1 changed files
... ...
@@ -78,13 +78,14 @@ func ParseForm(r *http.Request) error {
78 78
 
79 79
 // VersionFromContext returns an API version from the context using APIVersionKey.
80 80
 // It panics if the context value does not have version.Version type.
81
-func VersionFromContext(ctx context.Context) (ver string) {
81
+func VersionFromContext(ctx context.Context) string {
82 82
 	if ctx == nil {
83
-		return
83
+		return ""
84 84
 	}
85
-	val := ctx.Value(APIVersionKey)
86
-	if val == nil {
87
-		return
85
+
86
+	if val := ctx.Value(APIVersionKey); val != nil {
87
+		return val.(string)
88 88
 	}
89
-	return val.(string)
89
+
90
+	return ""
90 91
 }