*: reflow comments to 80 characters
This reformats the entire Metropolis codebase to have comments no longer
than 80 characters, implementing CR/66.
This has been done half manually, as we don't have a good integration
between commentwrap/Bazel, but that can be implemented if we decide to
go for this tool/limit.
Change-Id: If1fff0b093ef806f5dc00551c11506e8290379d0
diff --git a/metropolis/pkg/logbuffer/linebuffer.go b/metropolis/pkg/logbuffer/linebuffer.go
index 8048604..6fd9a62 100644
--- a/metropolis/pkg/logbuffer/linebuffer.go
+++ b/metropolis/pkg/logbuffer/linebuffer.go
@@ -25,7 +25,8 @@
apb "source.monogon.dev/metropolis/proto/api"
)
-// Line is a line stored in the log buffer - a string, that has been perhaps truncated (due to exceeded limits).
+// Line is a line stored in the log buffer - a string, that has been perhaps
+// truncated (due to exceeded limits).
type Line struct {
Data string
OriginalLength int
@@ -36,8 +37,8 @@
return l.OriginalLength > len(l.Data)
}
-// String returns the line with an ellipsis at the end (...) if the line has been truncated, or the original line
-// otherwise.
+// String returns the line with an ellipsis at the end (...) if the line has been
+// truncated, or the original line otherwise.
func (l *Line) String() string {
if l.Truncated() {
return l.Data + "..."
@@ -68,24 +69,27 @@
}, nil
}
-// LineBuffer is a io.WriteCloser that will call a given callback every time a line is completed.
+// LineBuffer is a io.WriteCloser that will call a given callback every time a line
+// is completed.
type LineBuffer struct {
maxLineLength int
cb LineBufferCallback
mu sync.Mutex
cur strings.Builder
- // length is the length of the line currently being written - this will continue to increase, even if the string
- // exceeds maxLineLength.
+ // length is the length of the line currently being written - this will continue to
+ // increase, even if the string exceeds maxLineLength.
length int
closed bool
}
-// LineBufferCallback is a callback that will get called any time the line is completed. The function must not cause another
-// write to the LineBuffer, or the program will deadlock.
+// LineBufferCallback is a callback that will get called any time the line is
+// completed. The function must not cause another write to the LineBuffer, or the
+// program will deadlock.
type LineBufferCallback func(*Line)
-// NewLineBuffer creates a new LineBuffer with a given line length limit and callback.
+// NewLineBuffer creates a new LineBuffer with a given line length limit and
+// callback.
func NewLineBuffer(maxLineLength int, cb LineBufferCallback) *LineBuffer {
return &LineBuffer{
maxLineLength: maxLineLength,
@@ -93,7 +97,8 @@
}
}
-// writeLimited writes to the internal buffer, making sure that its size does not exceed the maxLineLength.
+// writeLimited writes to the internal buffer, making sure that its size does not
+// exceed the maxLineLength.
func (l *LineBuffer) writeLimited(data []byte) {
l.length += len(data)
if l.cur.Len()+len(data) > l.maxLineLength {
@@ -144,8 +149,8 @@
return len(data), nil
}
-// Close will emit any leftover data in the buffer to the callback. Subsequent calls to Write will fail. Subsequent calls to Close
-// will also fail.
+// Close will emit any leftover data in the buffer to the callback. Subsequent
+// calls to Write will fail. Subsequent calls to Close will also fail.
func (l *LineBuffer) Close() error {
if l.closed {
return fmt.Errorf("already closed")