Add a function to make a copy of a *Line (bar the Time field).

This commit is contained in:
Alex Bramley 2011-07-28 17:56:14 +01:00
parent 8fed417dce
commit d6ac053b62
1 changed files with 8 additions and 0 deletions

View File

@ -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] == ':' {