From d6ac053b620bd99aed497d60b071ac3ff3548b69 Mon Sep 17 00:00:00 2001 From: Alex Bramley Date: Thu, 28 Jul 2011 17:56:14 +0100 Subject: [PATCH] Add a function to make a copy of a *Line (bar the Time field). --- client/line.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/client/line.go b/client/line.go index 313d542..820464b 100644 --- a/client/line.go +++ b/client/line.go @@ -17,6 +17,14 @@ type Line struct { Time *time.Time } +// NOTE: this doesn't copy l.Time (this should be read-only anyway) +func (l *Line) Copy() *Line { + nl := *line + nl.Args = make([]string, len(line.Args)) + copy(nl.Args, line.Args) + return &nl +} + func parseLine(s string) *Line { line := &Line{Raw: s} if s[0] == ':' {