Distributed Services with Go: log.go, Reset function

Can please someone explain, in the Reset function from log.go, values are copied
*l = *new while Log type contains mutex. Is copying mutexes a safe operation?

1 Like

Ah yep, should make a new mutex there. Thanks.

2 Likes

I ended up fixing this by removing the copy altogether.

Now Reset looks like this:

func (l *Log) Reset() error {
	if err := l.Remove(); err != nil {
		return err
	}
	return l.setup()
}

which re-initializes the same log. Both Reset and NewLog call this new setup method. Which will be in the next beta.

1 Like