March 2019
Intermediate to advanced
336 pages
9h 9m
English
The GetKeys method of the Dictionary class is shown in the following code snippet. The method returns the array of the DictKey elements. The RLock method of the lock instance is invoked, and the RUnlock method is deferred. The dictionary keys are returned by traversing the element's map:
// GetKeys methodfunc (dict *Dictionary) GetKeys() []DictKey { dict.lock.RLock() defer dict.lock.RUnlock() var dictKeys []DictKey dictKeys = []DictKey{} var key DictKey for key = range dict.elements { dictKeys = append(dictKeys, key) } return dictKeys}
Read now
Unlock full access