From 67d6a477469dfbbf1db3cca3f33296d946febe66 Mon Sep 17 00:00:00 2001 From: Harshavardhana Date: Fri, 2 Oct 2015 17:44:25 -0700 Subject: [PATCH] Avoid pointer reference of immutable methods --- diff.go | 6 +++--- session-v2.go | 2 +- session_test.go | 2 +- sorted-list.go | 4 ++-- utils.go | 4 ++-- 5 files changed, 9 insertions(+), 9 deletions(-) diff --git a/diff.go b/diff.go index 6e89dc65..c9572c7b 100644 --- a/diff.go +++ b/diff.go @@ -237,9 +237,9 @@ func dodiffRecursive(firstClnt, secondClnt client.Client, ch chan DiffMessage) { firstSortedList := sortedList{} secondSortedList := sortedList{} - id := randomID(8) - firstid := id + ".1" - secondid := id + ".2" + id := newRandomID(8) + firstid := id + ".firstURL" + secondid := id + ".secondURL" wg.Add(1) go func() { diff --git a/session-v2.go b/session-v2.go index 76ff25aa..efc72987 100644 --- a/session-v2.go +++ b/session-v2.go @@ -114,7 +114,7 @@ func newSessionV2() *sessionV2 { s.Header.CommandArgs = nil s.Header.When = time.Now().UTC() s.mutex = new(sync.Mutex) - s.SessionID = randomID(8) + s.SessionID = newRandomID(8) sessionDataFile, perr := getSessionDataFile(s.SessionID) fatalIf(perr.Trace(s.SessionID), "Unable to create session data file \""+sessionDataFile+"\".") diff --git a/session_test.go b/session_test.go index 8560375c..092e3e14 100644 --- a/session_test.go +++ b/session_test.go @@ -26,7 +26,7 @@ import ( func (s *TestSuite) TestValidSessionID(c *C) { validSid := regexp.MustCompile("^[a-zA-Z]+$") - sid := randomID(8) + sid := newRandomID(8) c.Assert(len(sid), Equals, 8) c.Assert(validSid.MatchString(sid), Equals, true) } diff --git a/sorted-list.go b/sorted-list.go index daec3156..7fc08688 100644 --- a/sorted-list.go +++ b/sorted-list.go @@ -103,7 +103,7 @@ func (sl *sortedList) Create(clnt client.Client, id string) *probe.Error { } // List list the entries from the sorted file -func (sl *sortedList) List(recursive bool) <-chan client.ContentOnChannel { +func (sl sortedList) List(recursive bool) <-chan client.ContentOnChannel { ch := make(chan client.ContentOnChannel) go func() { defer close(ch) @@ -124,7 +124,7 @@ func (sl *sortedList) List(recursive bool) <-chan client.ContentOnChannel { } // Delete close and delete the ondisk file -func (sl *sortedList) Delete() *probe.Error { +func (sl sortedList) Delete() *probe.Error { if err := sl.file.Close(); err != nil { return probe.NewError(err) } diff --git a/utils.go b/utils.go index 6ada2fc6..63a19cb7 100644 --- a/utils.go +++ b/utils.go @@ -23,8 +23,8 @@ import ( var letters = []rune("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ") -// randomID generates a random id of regular lower case and uppercase english characters -func randomID(n int) string { +// newRandomID generates a random id of regular lower case and uppercase english characters +func newRandomID(n int) string { rand.Seed(time.Now().UTC().UnixNano()) sid := make([]rune, n) for i := range sid {