и посмотреть медиа
NOP - Nuances of Programming
и посмотреть медиа
Channel about nuances of programming, IT humor and remote vacancies. Fresh insights for developers.
Channel about nuances of programming, IT humor and remote vacancies. Fresh insights for developers.
NOP::Nuances of Programming - channel with in-depth analysis of programming subtleties, humor and selections of remote vacancies. Useful content for developers of all levels in Telegram.
Как Go ловит копирование структур через sync.noCopy В sync.Mutex, sync.Once и sync.Map лежит пустое поле типа noCopy. Компилятор про него ничего не знает — предупреждение выдаёт go vet. Проверка copylocks ищет типы, у которых sync.Locker реализует указатель, но не значение. Поэтому у noCopy есть пустые методы Lock и Unlock: они нужны только для этого трюка. Тот же приём работает и в твоих структурах — добавь поле-маркер с двумя пустыми методами. Подвох в том, что sync.RWMutex маркера не имеет, и через свой именованный тип копию можно протащить незаметно. 🔗 Подробнее @nuancesprog #Languages #Go
Открыть канал и посмотреть медиаOnly registered users can share their opinion.
Be the first to share your impression of this resource!