Kaynağa Gözat

Print into logs if length > Width.

Steve Thielemann 2 yıl önce
ebeveyn
işleme
4ba57fa4e3
1 değiştirilmiş dosya ile 6 ekleme ve 1 silme
  1. 6 1
      door/line.go

+ 6 - 1
door/line.go

@@ -1,6 +1,7 @@
 package door
 
 import (
+	"log"
 	"strings"
 	"unicode"
 )
@@ -109,7 +110,11 @@ func (l *Line) LineLength(text *string) {
 	} else {
 		length = len([]byte(*text))
 	}
-	*text += strings.Repeat(" ", l.Width-length)
+	if length > l.Width {
+		log.Printf("ERROR: Line Width %d: Have %d\n", l.Width, length)
+	} else {
+		*text += strings.Repeat(" ", l.Width-length)
+	}
 }
 
 /*