Empty string check (#1101)

This commit is contained in:
田欧
2017-09-28 11:22:35 -05:00
committed by Bo-Yi Wu
parent f7376f7c7f
commit 3b300929e8
5 changed files with 11 additions and 12 deletions

View File

@ -103,7 +103,7 @@ func parseAccept(acceptHeader string) []string {
if index := strings.IndexByte(part, ';'); index >= 0 {
part = part[0:index]
}
if part = strings.TrimSpace(part); len(part) > 0 {
if part = strings.TrimSpace(part); part != "" {
out = append(out, part)
}
}
@ -111,11 +111,10 @@ func parseAccept(acceptHeader string) []string {
}
func lastChar(str string) uint8 {
size := len(str)
if size == 0 {
if str == "" {
panic("The length of the string can't be 0")
}
return str[size-1]
return str[len(str)-1]
}
func nameOfFunction(f interface{}) string {
@ -123,7 +122,7 @@ func nameOfFunction(f interface{}) string {
}
func joinPaths(absolutePath, relativePath string) string {
if len(relativePath) == 0 {
if relativePath == "" {
return absolutePath
}
@ -138,7 +137,7 @@ func joinPaths(absolutePath, relativePath string) string {
func resolveAddress(addr []string) string {
switch len(addr) {
case 0:
if port := os.Getenv("PORT"); len(port) > 0 {
if port := os.Getenv("PORT"); port != "" {
debugPrint("Environment variable PORT=\"%s\"", port)
return ":" + port
}