FAQ
Maybe we are not on the same page, but I think this is what you really want:
http://play.golang.org/p/qiviYUSO7s

Otherwise as it was pointed by James, you will have copies of X all sharing
the same Mutex and I'm sure that's not what you want most of the time, if
ever.

On Thursday, August 27, 2015 at 4:41:59 PM UTC-7, Gbr wrote:


On Thursday, August 27, 2015 at 4:35:12 PM UTC-7, Gbr wrote:

No, unfortunately. If you make sync.Mutex a direct embedded field (as
opposed to a pointer field), you loose implementation of Y -- sync.Locker
requires a pointer receiver.
Play ground: example <http://play.golang.org/p/cbYiLuXw66>

On Thursday, August 27, 2015 at 4:24:39 PM UTC-7, James Aguilar wrote:

type X struct {
Value int
sync.Mutex
}

If I understand you correctly, you want to avoid having to type out the
"new" for the mutex each time you use the type literal. This should work,
shouldn't it?
--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Search Discussions

Discussion Posts

Previous

Follow ups

Related Discussions

Discussion Navigation
viewthread | post
posts ‹ prev | 7 of 19 | next ›
Discussion Overview
groupgolang-nuts @
categoriesgo
postedAug 27, '15 at 10:48p
activeAug 29, '15 at 1:56a
posts19
users7
websitegolang.org

People

Translate

site design / logo © 2022 Grokbase