From 364c6da7ae5caeeb78346d8ae77ddf5a6bd37602 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 5934e65..48bbdab 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] == ':' {