diff --git a/container/glist/glist.go b/container/glist/glist.go index e0e461b05..ee6baa3d7 100644 --- a/container/glist/glist.go +++ b/container/glist/glist.go @@ -50,7 +50,7 @@ func NewFrom(array []interface{}, safe ...bool) *List { } } -// PushFront inserts a new element with value at the front of list and returns `e`. +// PushFront inserts a new element `e` with value `v` at the front of list `l` and returns `e`. func (l *List) PushFront(v interface{}) (e *Element) { l.mu.Lock() if l.list == nil { @@ -61,7 +61,7 @@ func (l *List) PushFront(v interface{}) (e *Element) { return } -// PushBack inserts a new element with value at the back of list and returns `e`. +// PushBack inserts a new element `e` with value `v` at the back of list `l` and returns `e`. func (l *List) PushBack(v interface{}) (e *Element) { l.mu.Lock() if l.list == nil { @@ -72,7 +72,7 @@ func (l *List) PushBack(v interface{}) (e *Element) { return } -// PushFronts inserts multiple new elements with values at the front of list `l`. +// PushFronts inserts multiple new elements with values `values` at the front of list `l`. func (l *List) PushFronts(values []interface{}) { l.mu.Lock() if l.list == nil { @@ -84,7 +84,7 @@ func (l *List) PushFronts(values []interface{}) { l.mu.Unlock() } -// PushBacks inserts multiple new elements with values at the back of list `l`. +// PushBacks inserts multiple new elements with values `values` at the back of list `l`. func (l *List) PushBacks(values []interface{}) { l.mu.Lock() if l.list == nil { @@ -124,7 +124,7 @@ func (l *List) PopFront() (value interface{}) { return } -// PopBacks removes elements from back of `l` +// PopBacks removes `max` elements from back of `l` // and returns values of the removed elements as slice. func (l *List) PopBacks(max int) (values []interface{}) { l.mu.Lock() @@ -146,7 +146,7 @@ func (l *List) PopBacks(max int) (values []interface{}) { return } -// PopFronts removes elements from front of `l` +// PopFronts removes `max` elements from front of `l` // and returns values of the removed elements as slice. func (l *List) PopFronts(max int) (values []interface{}) { l.mu.Lock() @@ -279,8 +279,8 @@ func (l *List) Size() int { return l.Len() } -// MoveBefore moves element to its new position before `p`. -// If or

is not an element of , or == `p`, the list is not modified. +// MoveBefore moves element `e` to its new position before `p`. +// If `e` or `p` is not an element of `l`, or `e` == `p`, the list is not modified. // The element and `p` must not be nil. func (l *List) MoveBefore(e, p *Element) { l.mu.Lock() @@ -291,8 +291,8 @@ func (l *List) MoveBefore(e, p *Element) { l.list.MoveBefore(e, p) } -// MoveAfter moves element to its new position after `p`. -// If or

is not an element of , or == `p`, the list is not modified. +// MoveAfter moves element `e` to its new position after `p`. +// If `e` or `p` is not an element of `l`, or `e` == `p`, the list is not modified. // The element and `p` must not be nil. func (l *List) MoveAfter(e, p *Element) { l.mu.Lock() @@ -303,8 +303,8 @@ func (l *List) MoveAfter(e, p *Element) { l.list.MoveAfter(e, p) } -// MoveToFront moves element to the front of list `l`. -// If is not an element of `l`, the list is not modified. +// MoveToFront moves element `e` to the front of list `l`. +// If `e` is not an element of `l`, the list is not modified. // The element must not be nil. func (l *List) MoveToFront(e *Element) { l.mu.Lock() @@ -315,8 +315,8 @@ func (l *List) MoveToFront(e *Element) { l.list.MoveToFront(e) } -// MoveToBack moves element to the back of list `l`. -// If is not an element of `l`, the list is not modified. +// MoveToBack moves element `e` to the back of list `l`. +// If `e` is not an element of `l`, the list is not modified. // The element must not be nil. func (l *List) MoveToBack(e *Element) { l.mu.Lock() @@ -328,7 +328,7 @@ func (l *List) MoveToBack(e *Element) { } // PushBackList inserts a copy of an other list at the back of list `l`. -// The lists and `other` may be the same, but they must not be nil. +// The lists `l` and `other` may be the same, but they must not be nil. func (l *List) PushBackList(other *List) { if l != other { other.mu.RLock() @@ -343,7 +343,7 @@ func (l *List) PushBackList(other *List) { } // PushFrontList inserts a copy of an other list at the front of list `l`. -// The lists and `other` may be the same, but they must not be nil. +// The lists `l` and `other` may be the same, but they must not be nil. func (l *List) PushFrontList(other *List) { if l != other { other.mu.RLock() @@ -357,8 +357,8 @@ func (l *List) PushFrontList(other *List) { l.list.PushFrontList(other.list) } -// InsertAfter inserts a new element with value immediately after

and returns `e`. -// If

is not an element of `l`, the list is not modified. +// InsertAfter inserts a new element `e` with value `v` immediately after `p` and returns `e`. +// If `p` is not an element of `l`, the list is not modified. // The `p` must not be nil. func (l *List) InsertAfter(p *Element, v interface{}) (e *Element) { l.mu.Lock() @@ -370,8 +370,8 @@ func (l *List) InsertAfter(p *Element, v interface{}) (e *Element) { return } -// InsertBefore inserts a new element with value immediately before

and returns `e`. -// If

is not an element of `l`, the list is not modified. +// InsertBefore inserts a new element `e` with value `v` immediately before `p` and returns `e`. +// If `p` is not an element of `l`, the list is not modified. // The `p` must not be nil. func (l *List) InsertBefore(p *Element, v interface{}) (e *Element) { l.mu.Lock() @@ -383,7 +383,7 @@ func (l *List) InsertBefore(p *Element, v interface{}) (e *Element) { return } -// Remove removes from if is an element of list `l`. +// Remove removes `e` from `l` if `e` is an element of list `l`. // It returns the element value e.Value. // The element must not be nil. func (l *List) Remove(e *Element) (value interface{}) { @@ -396,7 +396,7 @@ func (l *List) Remove(e *Element) (value interface{}) { return } -// Removes removes multiple elements from if are elements of list `l`. +// Removes removes multiple elements `es` from `l` if `es` are elements of list `l`. func (l *List) Removes(es []*Element) { l.mu.Lock() defer l.mu.Unlock() diff --git a/container/gmap/gmap_hash_any_any_map.go b/container/gmap/gmap_hash_any_any_map.go index 891905c38..1d56eb859 100644 --- a/container/gmap/gmap_hash_any_any_map.go +++ b/container/gmap/gmap_hash_any_any_map.go @@ -205,7 +205,7 @@ func (m *AnyAnyMap) Pops(size int) map[interface{}]interface{} { // if not exists, set value to the map with given `key`, // or else just return the existing value. // -// When setting value, if `value` is type of , +// When setting value, if `value` is type of `func() interface {}`, // it will be executed with mutex.Lock of the hash map, // and its return value will be set to the map with `key`. // @@ -287,8 +287,8 @@ func (m *AnyAnyMap) GetVarOrSetFuncLock(key interface{}, f func() interface{}) * return gvar.New(m.GetOrSetFuncLock(key, f)) } -// SetIfNotExist sets to the map if the `key` does not exist, and then returns true. -// It returns false if exists, and `value` would be ignored. +// SetIfNotExist sets `value` to the map if the `key` does not exist, and then returns true. +// It returns false if `key` exists, and `value` would be ignored. func (m *AnyAnyMap) SetIfNotExist(key interface{}, value interface{}) bool { if !m.Contains(key) { m.doSetWithLockCheck(key, value) @@ -298,7 +298,7 @@ func (m *AnyAnyMap) SetIfNotExist(key interface{}, value interface{}) bool { } // SetIfNotExistFunc sets value with return value of callback function `f`, and then returns true. -// It returns false if exists, and `value` would be ignored. +// It returns false if `key` exists, and `value` would be ignored. func (m *AnyAnyMap) SetIfNotExistFunc(key interface{}, f func() interface{}) bool { if !m.Contains(key) { m.doSetWithLockCheck(key, f()) @@ -308,7 +308,7 @@ func (m *AnyAnyMap) SetIfNotExistFunc(key interface{}, f func() interface{}) boo } // SetIfNotExistFuncLock sets value with return value of callback function `f`, and then returns true. -// It returns false if exists, and `value` would be ignored. +// It returns false if `key` exists, and `value` would be ignored. // // SetIfNotExistFuncLock differs with SetIfNotExistFunc function is that // it executes function `f` with mutex.Lock of the hash map. @@ -440,7 +440,7 @@ func (m *AnyAnyMap) Flip() { } // Merge merges two hash maps. -// The map will be merged into the map `m`. +// The `other` map will be merged into the map `m`. func (m *AnyAnyMap) Merge(other *AnyAnyMap) { m.mu.Lock() defer m.mu.Unlock() diff --git a/container/gmap/gmap_hash_int_any_map.go b/container/gmap/gmap_hash_int_any_map.go index 0d3ac30a2..4d2986eb8 100644 --- a/container/gmap/gmap_hash_int_any_map.go +++ b/container/gmap/gmap_hash_int_any_map.go @@ -205,7 +205,7 @@ func (m *IntAnyMap) Pops(size int) map[int]interface{} { // if not exists, set value to the map with given `key`, // or else just return the existing value. // -// When setting value, if `value` is type of , +// When setting value, if `value` is type of `func() interface {}`, // it will be executed with mutex.Lock of the hash map, // and its return value will be set to the map with `key`. // @@ -285,8 +285,8 @@ func (m *IntAnyMap) GetVarOrSetFuncLock(key int, f func() interface{}) *gvar.Var return gvar.New(m.GetOrSetFuncLock(key, f)) } -// SetIfNotExist sets to the map if the `key` does not exist, and then returns true. -// It returns false if exists, and `value` would be ignored. +// SetIfNotExist sets `value` to the map if the `key` does not exist, and then returns true. +// It returns false if `key` exists, and `value` would be ignored. func (m *IntAnyMap) SetIfNotExist(key int, value interface{}) bool { if !m.Contains(key) { m.doSetWithLockCheck(key, value) @@ -296,7 +296,7 @@ func (m *IntAnyMap) SetIfNotExist(key int, value interface{}) bool { } // SetIfNotExistFunc sets value with return value of callback function `f`, and then returns true. -// It returns false if exists, and `value` would be ignored. +// It returns false if `key` exists, and `value` would be ignored. func (m *IntAnyMap) SetIfNotExistFunc(key int, f func() interface{}) bool { if !m.Contains(key) { m.doSetWithLockCheck(key, f()) @@ -306,7 +306,7 @@ func (m *IntAnyMap) SetIfNotExistFunc(key int, f func() interface{}) bool { } // SetIfNotExistFuncLock sets value with return value of callback function `f`, and then returns true. -// It returns false if exists, and `value` would be ignored. +// It returns false if `key` exists, and `value` would be ignored. // // SetIfNotExistFuncLock differs with SetIfNotExistFunc function is that // it executes function `f` with mutex.Lock of the hash map. @@ -438,7 +438,7 @@ func (m *IntAnyMap) Flip() { } // Merge merges two hash maps. -// The map will be merged into the map `m`. +// The `other` map will be merged into the map `m`. func (m *IntAnyMap) Merge(other *IntAnyMap) { m.mu.Lock() defer m.mu.Unlock() diff --git a/container/gmap/gmap_hash_int_int_map.go b/container/gmap/gmap_hash_int_int_map.go index d6bafb63b..e82593db2 100644 --- a/container/gmap/gmap_hash_int_int_map.go +++ b/container/gmap/gmap_hash_int_int_map.go @@ -249,8 +249,8 @@ func (m *IntIntMap) GetOrSetFuncLock(key int, f func() int) int { } } -// SetIfNotExist sets to the map if the `key` does not exist, and then returns true. -// It returns false if exists, and `value` would be ignored. +// SetIfNotExist sets `value` to the map if the `key` does not exist, and then returns true. +// It returns false if `key` exists, and `value` would be ignored. func (m *IntIntMap) SetIfNotExist(key int, value int) bool { if !m.Contains(key) { m.doSetWithLockCheck(key, value) @@ -260,7 +260,7 @@ func (m *IntIntMap) SetIfNotExist(key int, value int) bool { } // SetIfNotExistFunc sets value with return value of callback function `f`, and then returns true. -// It returns false if exists, and `value` would be ignored. +// It returns false if `key` exists, and `value` would be ignored. func (m *IntIntMap) SetIfNotExistFunc(key int, f func() int) bool { if !m.Contains(key) { m.doSetWithLockCheck(key, f()) @@ -270,7 +270,7 @@ func (m *IntIntMap) SetIfNotExistFunc(key int, f func() int) bool { } // SetIfNotExistFuncLock sets value with return value of callback function `f`, and then returns true. -// It returns false if exists, and `value` would be ignored. +// It returns false if `key` exists, and `value` would be ignored. // // SetIfNotExistFuncLock differs with SetIfNotExistFunc function is that // it executes function `f` with mutex.Lock of the hash map. @@ -409,7 +409,7 @@ func (m *IntIntMap) Flip() { } // Merge merges two hash maps. -// The map will be merged into the map `m`. +// The `other` map will be merged into the map `m`. func (m *IntIntMap) Merge(other *IntIntMap) { m.mu.Lock() defer m.mu.Unlock() diff --git a/container/gmap/gmap_hash_int_str_map.go b/container/gmap/gmap_hash_int_str_map.go index 92a701e7e..7be2376ca 100644 --- a/container/gmap/gmap_hash_int_str_map.go +++ b/container/gmap/gmap_hash_int_str_map.go @@ -249,8 +249,8 @@ func (m *IntStrMap) GetOrSetFuncLock(key int, f func() string) string { } } -// SetIfNotExist sets to the map if the `key` does not exist, and then returns true. -// It returns false if exists, and `value` would be ignored. +// SetIfNotExist sets `value` to the map if the `key` does not exist, and then returns true. +// It returns false if `key` exists, and `value` would be ignored. func (m *IntStrMap) SetIfNotExist(key int, value string) bool { if !m.Contains(key) { m.doSetWithLockCheck(key, value) @@ -260,7 +260,7 @@ func (m *IntStrMap) SetIfNotExist(key int, value string) bool { } // SetIfNotExistFunc sets value with return value of callback function `f`, and then returns true. -// It returns false if exists, and `value` would be ignored. +// It returns false if `key` exists, and `value` would be ignored. func (m *IntStrMap) SetIfNotExistFunc(key int, f func() string) bool { if !m.Contains(key) { m.doSetWithLockCheck(key, f()) @@ -270,7 +270,7 @@ func (m *IntStrMap) SetIfNotExistFunc(key int, f func() string) bool { } // SetIfNotExistFuncLock sets value with return value of callback function `f`, and then returns true. -// It returns false if exists, and `value` would be ignored. +// It returns false if `key` exists, and `value` would be ignored. // // SetIfNotExistFuncLock differs with SetIfNotExistFunc function is that // it executes function `f` with mutex.Lock of the hash map. @@ -409,7 +409,7 @@ func (m *IntStrMap) Flip() { } // Merge merges two hash maps. -// The map will be merged into the map `m`. +// The `other` map will be merged into the map `m`. func (m *IntStrMap) Merge(other *IntStrMap) { m.mu.Lock() defer m.mu.Unlock() diff --git a/container/gmap/gmap_hash_str_any_map.go b/container/gmap/gmap_hash_str_any_map.go index 84652f3f0..832fbdd5d 100644 --- a/container/gmap/gmap_hash_str_any_map.go +++ b/container/gmap/gmap_hash_str_any_map.go @@ -199,7 +199,7 @@ func (m *StrAnyMap) Pops(size int) map[string]interface{} { // if not exists, set value to the map with given `key`, // or else just return the existing value. // -// When setting value, if `value` is type of , +// When setting value, if `value` is type of `func() interface {}`, // it will be executed with mutex.Lock of the hash map, // and its return value will be set to the map with `key`. // @@ -281,8 +281,8 @@ func (m *StrAnyMap) GetVarOrSetFuncLock(key string, f func() interface{}) *gvar. return gvar.New(m.GetOrSetFuncLock(key, f)) } -// SetIfNotExist sets to the map if the `key` does not exist, and then returns true. -// It returns false if exists, and `value` would be ignored. +// SetIfNotExist sets `value` to the map if the `key` does not exist, and then returns true. +// It returns false if `key` exists, and `value` would be ignored. func (m *StrAnyMap) SetIfNotExist(key string, value interface{}) bool { if !m.Contains(key) { m.doSetWithLockCheck(key, value) @@ -292,7 +292,7 @@ func (m *StrAnyMap) SetIfNotExist(key string, value interface{}) bool { } // SetIfNotExistFunc sets value with return value of callback function `f`, and then returns true. -// It returns false if exists, and `value` would be ignored. +// It returns false if `key` exists, and `value` would be ignored. func (m *StrAnyMap) SetIfNotExistFunc(key string, f func() interface{}) bool { if !m.Contains(key) { m.doSetWithLockCheck(key, f()) @@ -302,7 +302,7 @@ func (m *StrAnyMap) SetIfNotExistFunc(key string, f func() interface{}) bool { } // SetIfNotExistFuncLock sets value with return value of callback function `f`, and then returns true. -// It returns false if exists, and `value` would be ignored. +// It returns false if `key` exists, and `value` would be ignored. // // SetIfNotExistFuncLock differs with SetIfNotExistFunc function is that // it executes function `f` with mutex.Lock of the hash map. @@ -434,7 +434,7 @@ func (m *StrAnyMap) Flip() { } // Merge merges two hash maps. -// The map will be merged into the map `m`. +// The `other` map will be merged into the map `m`. func (m *StrAnyMap) Merge(other *StrAnyMap) { m.mu.Lock() defer m.mu.Unlock() diff --git a/container/gmap/gmap_hash_str_int_map.go b/container/gmap/gmap_hash_str_int_map.go index a09343ea1..f068940d5 100644 --- a/container/gmap/gmap_hash_str_int_map.go +++ b/container/gmap/gmap_hash_str_int_map.go @@ -252,8 +252,8 @@ func (m *StrIntMap) GetOrSetFuncLock(key string, f func() int) int { } } -// SetIfNotExist sets to the map if the `key` does not exist, and then returns true. -// It returns false if exists, and `value` would be ignored. +// SetIfNotExist sets `value` to the map if the `key` does not exist, and then returns true. +// It returns false if `key` exists, and `value` would be ignored. func (m *StrIntMap) SetIfNotExist(key string, value int) bool { if !m.Contains(key) { m.doSetWithLockCheck(key, value) @@ -263,7 +263,7 @@ func (m *StrIntMap) SetIfNotExist(key string, value int) bool { } // SetIfNotExistFunc sets value with return value of callback function `f`, and then returns true. -// It returns false if exists, and `value` would be ignored. +// It returns false if `key` exists, and `value` would be ignored. func (m *StrIntMap) SetIfNotExistFunc(key string, f func() int) bool { if !m.Contains(key) { m.doSetWithLockCheck(key, f()) @@ -273,7 +273,7 @@ func (m *StrIntMap) SetIfNotExistFunc(key string, f func() int) bool { } // SetIfNotExistFuncLock sets value with return value of callback function `f`, and then returns true. -// It returns false if exists, and `value` would be ignored. +// It returns false if `key` exists, and `value` would be ignored. // // SetIfNotExistFuncLock differs with SetIfNotExistFunc function is that // it executes function `f` with mutex.Lock of the hash map. @@ -412,7 +412,7 @@ func (m *StrIntMap) Flip() { } // Merge merges two hash maps. -// The map will be merged into the map `m`. +// The `other` map will be merged into the map `m`. func (m *StrIntMap) Merge(other *StrIntMap) { m.mu.Lock() defer m.mu.Unlock() diff --git a/container/gmap/gmap_hash_str_str_map.go b/container/gmap/gmap_hash_str_str_map.go index 0202017d6..3a0900d7b 100644 --- a/container/gmap/gmap_hash_str_str_map.go +++ b/container/gmap/gmap_hash_str_str_map.go @@ -252,8 +252,8 @@ func (m *StrStrMap) GetOrSetFuncLock(key string, f func() string) string { } } -// SetIfNotExist sets to the map if the `key` does not exist, and then returns true. -// It returns false if exists, and `value` would be ignored. +// SetIfNotExist sets `value` to the map if the `key` does not exist, and then returns true. +// It returns false if `key` exists, and `value` would be ignored. func (m *StrStrMap) SetIfNotExist(key string, value string) bool { if !m.Contains(key) { m.doSetWithLockCheck(key, value) @@ -263,7 +263,7 @@ func (m *StrStrMap) SetIfNotExist(key string, value string) bool { } // SetIfNotExistFunc sets value with return value of callback function `f`, and then returns true. -// It returns false if exists, and `value` would be ignored. +// It returns false if `key` exists, and `value` would be ignored. func (m *StrStrMap) SetIfNotExistFunc(key string, f func() string) bool { if !m.Contains(key) { m.doSetWithLockCheck(key, f()) @@ -273,7 +273,7 @@ func (m *StrStrMap) SetIfNotExistFunc(key string, f func() string) bool { } // SetIfNotExistFuncLock sets value with return value of callback function `f`, and then returns true. -// It returns false if exists, and `value` would be ignored. +// It returns false if `key` exists, and `value` would be ignored. // // SetIfNotExistFuncLock differs with SetIfNotExistFunc function is that // it executes function `f` with mutex.Lock of the hash map. @@ -412,7 +412,7 @@ func (m *StrStrMap) Flip() { } // Merge merges two hash maps. -// The map will be merged into the map `m`. +// The `other` map will be merged into the map `m`. func (m *StrStrMap) Merge(other *StrStrMap) { m.mu.Lock() defer m.mu.Unlock() diff --git a/container/gmap/gmap_list_map.go b/container/gmap/gmap_list_map.go index f046537ee..a0f2f1e30 100644 --- a/container/gmap/gmap_list_map.go +++ b/container/gmap/gmap_list_map.go @@ -271,7 +271,7 @@ func (m *ListMap) Pops(size int) map[interface{}]interface{} { // if not exists, set value to the map with given `key`, // or else just return the existing value. // -// When setting value, if `value` is type of , +// When setting value, if `value` is type of `func() interface {}`, // it will be executed with mutex.Lock of the map, // and its return value will be set to the map with `key`. // @@ -354,8 +354,8 @@ func (m *ListMap) GetVarOrSetFuncLock(key interface{}, f func() interface{}) *gv return gvar.New(m.GetOrSetFuncLock(key, f)) } -// SetIfNotExist sets to the map if the `key` does not exist, and then returns true. -// It returns false if exists, and `value` would be ignored. +// SetIfNotExist sets `value` to the map if the `key` does not exist, and then returns true. +// It returns false if `key` exists, and `value` would be ignored. func (m *ListMap) SetIfNotExist(key interface{}, value interface{}) bool { if !m.Contains(key) { m.doSetWithLockCheck(key, value) @@ -365,7 +365,7 @@ func (m *ListMap) SetIfNotExist(key interface{}, value interface{}) bool { } // SetIfNotExistFunc sets value with return value of callback function `f`, and then returns true. -// It returns false if exists, and `value` would be ignored. +// It returns false if `key` exists, and `value` would be ignored. func (m *ListMap) SetIfNotExistFunc(key interface{}, f func() interface{}) bool { if !m.Contains(key) { m.doSetWithLockCheck(key, f()) @@ -375,7 +375,7 @@ func (m *ListMap) SetIfNotExistFunc(key interface{}, f func() interface{}) bool } // SetIfNotExistFuncLock sets value with return value of callback function `f`, and then returns true. -// It returns false if exists, and `value` would be ignored. +// It returns false if `key` exists, and `value` would be ignored. // // SetIfNotExistFuncLock differs with SetIfNotExistFunc function is that // it executes function `f` with mutex.Lock of the map. @@ -486,7 +486,7 @@ func (m *ListMap) Flip() { } // Merge merges two link maps. -// The map will be merged into the map `m`. +// The `other` map will be merged into the map `m`. func (m *ListMap) Merge(other *ListMap) { m.mu.Lock() defer m.mu.Unlock() diff --git a/container/gset/gset_any_set.go b/container/gset/gset_any_set.go index f08019ef1..c91b4fd6e 100644 --- a/container/gset/gset_any_set.go +++ b/container/gset/gset_any_set.go @@ -27,7 +27,8 @@ func New(safe ...bool) *Set { return NewSet(safe...) } -// See New. +// NewSet create and returns a new set, which contains un-repeated items. +// Also see New. func NewSet(safe ...bool) *Set { return &Set{ data: make(map[interface{}]struct{}), @@ -99,7 +100,7 @@ func (set *Set) AddIfNotExist(item interface{}) bool { // it adds the item to set and returns true if it does not exists in the set and // function `f` returns true, or else it does nothing and returns false. // -// Note that, if is nil, it does nothing and returns false. The function `f` +// Note that, if `item` is nil, it does nothing and returns false. The function `f` // is executed without writing lock. func (set *Set) AddIfNotExistFunc(item interface{}, f func() bool) bool { if item == nil { @@ -121,11 +122,11 @@ func (set *Set) AddIfNotExistFunc(item interface{}, f func() bool) bool { return false } -// AddIfNotExistFunc checks whether item exists in the set, +// AddIfNotExistFuncLock checks whether item exists in the set, // it adds the item to set and returns true if it does not exists in the set and // function `f` returns true, or else it does nothing and returns false. // -// Note that, if is nil, it does nothing and returns false. The function `f` +// Note that, if `item` is nil, it does nothing and returns false. The function `f` // is executed within writing lock. func (set *Set) AddIfNotExistFuncLock(item interface{}, f func() bool) bool { if item == nil { @@ -297,8 +298,8 @@ func (set *Set) IsSubsetOf(other *Set) bool { return true } -// Union returns a new set which is the union of and `others`. -// Which means, all the items in are in or in `others`. +// Union returns a new set which is the union of `set` and `others`. +// Which means, all the items in `newSet` are in `set` or in `others`. func (set *Set) Union(others ...*Set) (newSet *Set) { newSet = NewSet() set.mu.RLock() @@ -323,8 +324,8 @@ func (set *Set) Union(others ...*Set) (newSet *Set) { return } -// Diff returns a new set which is the difference set from to `others`. -// Which means, all the items in are in but not in `others`. +// Diff returns a new set which is the difference set from `set` to `others`. +// Which means, all the items in `newSet` are in `set` but not in `others`. func (set *Set) Diff(others ...*Set) (newSet *Set) { newSet = NewSet() set.mu.RLock() @@ -344,8 +345,8 @@ func (set *Set) Diff(others ...*Set) (newSet *Set) { return } -// Intersect returns a new set which is the intersection from to `others`. -// Which means, all the items in are in and also in `others`. +// Intersect returns a new set which is the intersection from `set` to `others`. +// Which means, all the items in `newSet` are in `set` and also in `others`. func (set *Set) Intersect(others ...*Set) (newSet *Set) { newSet = NewSet() set.mu.RLock() @@ -366,11 +367,11 @@ func (set *Set) Intersect(others ...*Set) (newSet *Set) { return } -// Complement returns a new set which is the complement from to `full`. -// Which means, all the items in are in and not in `set`. +// Complement returns a new set which is the complement from `set` to `full`. +// Which means, all the items in `newSet` are in `full` and not in `set`. // -// It returns the difference between and `set` -// if the given set is not the full set of `set`. +// It returns the difference between `full` and `set` +// if the given set `full` is not the full set of `set`. func (set *Set) Complement(full *Set) (newSet *Set) { newSet = NewSet() set.mu.RLock() @@ -387,7 +388,7 @@ func (set *Set) Complement(full *Set) (newSet *Set) { return } -// Merge adds items from sets into `set`. +// Merge adds items from `others` sets into `set`. func (set *Set) Merge(others ...*Set) *Set { set.mu.Lock() defer set.mu.Unlock() @@ -417,7 +418,7 @@ func (set *Set) Sum() (sum int) { return } -// Pops randomly pops an item from set. +// Pop randomly pops an item from set. func (set *Set) Pop() interface{} { set.mu.Lock() defer set.mu.Unlock() diff --git a/container/gset/gset_int_set.go b/container/gset/gset_int_set.go index 04ec0bb52..3c6320a95 100644 --- a/container/gset/gset_int_set.go +++ b/container/gset/gset_int_set.go @@ -19,7 +19,7 @@ type IntSet struct { data map[int]struct{} } -// New create and returns a new set, which contains un-repeated items. +// NewIntSet create and returns a new set, which contains un-repeated items. // The parameter `safe` is used to specify whether using set in concurrent-safety, // which is false in default. func NewIntSet(safe ...bool) *IntSet { @@ -107,7 +107,7 @@ func (set *IntSet) AddIfNotExistFunc(item int, f func() bool) bool { return false } -// AddIfNotExistFunc checks whether item exists in the set, +// AddIfNotExistFuncLock checks whether item exists in the set, // it adds the item to set and returns true if it does not exists in the set and // function `f` returns true, or else it does nothing and returns false. // @@ -257,8 +257,8 @@ func (set *IntSet) IsSubsetOf(other *IntSet) bool { return true } -// Union returns a new set which is the union of and `other`. -// Which means, all the items in are in or in `other`. +// Union returns a new set which is the union of `set` and `other`. +// Which means, all the items in `newSet` are in `set` or in `other`. func (set *IntSet) Union(others ...*IntSet) (newSet *IntSet) { newSet = NewIntSet() set.mu.RLock() @@ -283,8 +283,8 @@ func (set *IntSet) Union(others ...*IntSet) (newSet *IntSet) { return } -// Diff returns a new set which is the difference set from to `other`. -// Which means, all the items in are in but not in `other`. +// Diff returns a new set which is the difference set from `set` to `other`. +// Which means, all the items in `newSet` are in `set` but not in `other`. func (set *IntSet) Diff(others ...*IntSet) (newSet *IntSet) { newSet = NewIntSet() set.mu.RLock() @@ -304,8 +304,8 @@ func (set *IntSet) Diff(others ...*IntSet) (newSet *IntSet) { return } -// Intersect returns a new set which is the intersection from to `other`. -// Which means, all the items in are in and also in `other`. +// Intersect returns a new set which is the intersection from `set` to `other`. +// Which means, all the items in `newSet` are in `set` and also in `other`. func (set *IntSet) Intersect(others ...*IntSet) (newSet *IntSet) { newSet = NewIntSet() set.mu.RLock() @@ -326,11 +326,11 @@ func (set *IntSet) Intersect(others ...*IntSet) (newSet *IntSet) { return } -// Complement returns a new set which is the complement from to `full`. -// Which means, all the items in are in and not in `set`. +// Complement returns a new set which is the complement from `set` to `full`. +// Which means, all the items in `newSet` are in `full` and not in `set`. // -// It returns the difference between and `set` -// if the given set is not the full set of `set`. +// It returns the difference between `full` and `set` +// if the given set `full` is not the full set of `set`. func (set *IntSet) Complement(full *IntSet) (newSet *IntSet) { newSet = NewIntSet() set.mu.RLock() @@ -347,7 +347,7 @@ func (set *IntSet) Complement(full *IntSet) (newSet *IntSet) { return } -// Merge adds items from sets into `set`. +// Merge adds items from `others` sets into `set`. func (set *IntSet) Merge(others ...*IntSet) *IntSet { set.mu.Lock() defer set.mu.Unlock() @@ -377,7 +377,7 @@ func (set *IntSet) Sum() (sum int) { return } -// Pops randomly pops an item from set. +// Pop randomly pops an item from set. func (set *IntSet) Pop() int { set.mu.Lock() defer set.mu.Unlock() diff --git a/container/gset/gset_str_set.go b/container/gset/gset_str_set.go index a227607ac..a7f43e773 100644 --- a/container/gset/gset_str_set.go +++ b/container/gset/gset_str_set.go @@ -107,7 +107,7 @@ func (set *StrSet) AddIfNotExistFunc(item string, f func() bool) bool { return false } -// AddIfNotExistFunc checks whether item exists in the set, +// AddIfNotExistFuncLock checks whether item exists in the set, // it adds the item to set and returns true if it does not exists in the set and // function `f` returns true, or else it does nothing and returns false. // @@ -285,8 +285,8 @@ func (set *StrSet) IsSubsetOf(other *StrSet) bool { return true } -// Union returns a new set which is the union of and `other`. -// Which means, all the items in are in or in `other`. +// Union returns a new set which is the union of `set` and `other`. +// Which means, all the items in `newSet` are in `set` or in `other`. func (set *StrSet) Union(others ...*StrSet) (newSet *StrSet) { newSet = NewStrSet() set.mu.RLock() @@ -311,8 +311,8 @@ func (set *StrSet) Union(others ...*StrSet) (newSet *StrSet) { return } -// Diff returns a new set which is the difference set from to `other`. -// Which means, all the items in are in but not in `other`. +// Diff returns a new set which is the difference set from `set` to `other`. +// Which means, all the items in `newSet` are in `set` but not in `other`. func (set *StrSet) Diff(others ...*StrSet) (newSet *StrSet) { newSet = NewStrSet() set.mu.RLock() @@ -332,8 +332,8 @@ func (set *StrSet) Diff(others ...*StrSet) (newSet *StrSet) { return } -// Intersect returns a new set which is the intersection from to `other`. -// Which means, all the items in are in and also in `other`. +// Intersect returns a new set which is the intersection from `set` to `other`. +// Which means, all the items in `newSet` are in `set` and also in `other`. func (set *StrSet) Intersect(others ...*StrSet) (newSet *StrSet) { newSet = NewStrSet() set.mu.RLock() @@ -354,11 +354,11 @@ func (set *StrSet) Intersect(others ...*StrSet) (newSet *StrSet) { return } -// Complement returns a new set which is the complement from to `full`. -// Which means, all the items in are in and not in `set`. +// Complement returns a new set which is the complement from `set` to `full`. +// Which means, all the items in `newSet` are in `full` and not in `set`. // -// It returns the difference between and `set` -// if the given set is not the full set of `set`. +// It returns the difference between `full` and `set` +// if the given set `full` is not the full set of `set`. func (set *StrSet) Complement(full *StrSet) (newSet *StrSet) { newSet = NewStrSet() set.mu.RLock() @@ -375,7 +375,7 @@ func (set *StrSet) Complement(full *StrSet) (newSet *StrSet) { return } -// Merge adds items from sets into `set`. +// Merge adds items from `others` sets into `set`. func (set *StrSet) Merge(others ...*StrSet) *StrSet { set.mu.Lock() defer set.mu.Unlock() @@ -405,7 +405,7 @@ func (set *StrSet) Sum() (sum int) { return } -// Pops randomly pops an item from set. +// Pop randomly pops an item from set. func (set *StrSet) Pop() string { set.mu.Lock() defer set.mu.Unlock() diff --git a/container/gtree/gtree_avltree.go b/container/gtree/gtree_avltree.go index 1265c5b34..bec0198a3 100644 --- a/container/gtree/gtree_avltree.go +++ b/container/gtree/gtree_avltree.go @@ -195,8 +195,8 @@ func (tree *AVLTree) GetVarOrSetFuncLock(key interface{}, f func() interface{}) return gvar.New(tree.GetOrSetFuncLock(key, f)) } -// SetIfNotExist sets to the map if the `key` does not exist, and then returns true. -// It returns false if exists, and `value` would be ignored. +// SetIfNotExist sets `value` to the map if the `key` does not exist, and then returns true. +// It returns false if `key` exists, and `value` would be ignored. func (tree *AVLTree) SetIfNotExist(key interface{}, value interface{}) bool { if !tree.Contains(key) { tree.doSetWithLockCheck(key, value) @@ -206,7 +206,7 @@ func (tree *AVLTree) SetIfNotExist(key interface{}, value interface{}) bool { } // SetIfNotExistFunc sets value with return value of callback function `f`, and then returns true. -// It returns false if exists, and `value` would be ignored. +// It returns false if `key` exists, and `value` would be ignored. func (tree *AVLTree) SetIfNotExistFunc(key interface{}, f func() interface{}) bool { if !tree.Contains(key) { tree.doSetWithLockCheck(key, f()) @@ -216,7 +216,7 @@ func (tree *AVLTree) SetIfNotExistFunc(key interface{}, f func() interface{}) bo } // SetIfNotExistFuncLock sets value with return value of callback function `f`, and then returns true. -// It returns false if exists, and `value` would be ignored. +// It returns false if `key` exists, and `value` would be ignored. // // SetIfNotExistFuncLock differs with SetIfNotExistFunc function is that // it executes function `f` with mutex.Lock of the hash map. @@ -474,7 +474,7 @@ func (tree *AVLTree) IteratorAsc(f func(key, value interface{}) bool) { } // IteratorAscFrom iterates the tree readonly in ascending order with given callback function `f`. -// The parameter specifies the start entry for iterating. The `match` specifies whether +// The parameter `key` specifies the start entry for iterating. The `match` specifies whether // starting iterating if the `key` is fully matched, or else using index searching iterating. // If `f` returns true, then it continues iterating; or false to stop. func (tree *AVLTree) IteratorAscFrom(key interface{}, match bool, f func(key, value interface{}) bool) { @@ -508,7 +508,7 @@ func (tree *AVLTree) IteratorDesc(f func(key, value interface{}) bool) { } // IteratorDescFrom iterates the tree readonly in descending order with given callback function `f`. -// The parameter specifies the start entry for iterating. The `match` specifies whether +// The parameter `key` specifies the start entry for iterating. The `match` specifies whether // starting iterating if the `key` is fully matched, or else using index searching iterating. // If `f` returns true, then it continues iterating; or false to stop. func (tree *AVLTree) IteratorDescFrom(key interface{}, match bool, f func(key, value interface{}) bool) { diff --git a/container/gtree/gtree_btree.go b/container/gtree/gtree_btree.go index 365502d58..ffd12c5ca 100644 --- a/container/gtree/gtree_btree.go +++ b/container/gtree/gtree_btree.go @@ -193,8 +193,8 @@ func (tree *BTree) GetVarOrSetFuncLock(key interface{}, f func() interface{}) *g return gvar.New(tree.GetOrSetFuncLock(key, f)) } -// SetIfNotExist sets to the map if the `key` does not exist, and then returns true. -// It returns false if exists, and `value` would be ignored. +// SetIfNotExist sets `value` to the map if the `key` does not exist, and then returns true. +// It returns false if `key` exists, and `value` would be ignored. func (tree *BTree) SetIfNotExist(key interface{}, value interface{}) bool { if !tree.Contains(key) { tree.doSetWithLockCheck(key, value) @@ -204,7 +204,7 @@ func (tree *BTree) SetIfNotExist(key interface{}, value interface{}) bool { } // SetIfNotExistFunc sets value with return value of callback function `f`, and then returns true. -// It returns false if exists, and `value` would be ignored. +// It returns false if `key` exists, and `value` would be ignored. func (tree *BTree) SetIfNotExistFunc(key interface{}, f func() interface{}) bool { if !tree.Contains(key) { tree.doSetWithLockCheck(key, f()) @@ -214,7 +214,7 @@ func (tree *BTree) SetIfNotExistFunc(key interface{}, f func() interface{}) bool } // SetIfNotExistFuncLock sets value with return value of callback function `f`, and then returns true. -// It returns false if exists, and `value` would be ignored. +// It returns false if `key` exists, and `value` would be ignored. // // SetIfNotExistFuncLock differs with SetIfNotExistFunc function is that // it executes function `f` with mutex.Lock of the hash map. @@ -419,7 +419,7 @@ func (tree *BTree) IteratorAsc(f func(key, value interface{}) bool) { } // IteratorAscFrom iterates the tree readonly in ascending order with given callback function `f`. -// The parameter specifies the start entry for iterating. The `match` specifies whether +// The parameter `key` specifies the start entry for iterating. The `match` specifies whether // starting iterating if the `key` is fully matched, or else using index searching iterating. // If `f` returns true, then it continues iterating; or false to stop. func (tree *BTree) IteratorAscFrom(key interface{}, match bool, f func(key, value interface{}) bool) { @@ -494,7 +494,7 @@ func (tree *BTree) IteratorDesc(f func(key, value interface{}) bool) { } // IteratorDescFrom iterates the tree readonly in descending order with given callback function `f`. -// The parameter specifies the start entry for iterating. The `match` specifies whether +// The parameter `key` specifies the start entry for iterating. The `match` specifies whether // starting iterating if the `key` is fully matched, or else using index searching iterating. // If `f` returns true, then it continues iterating; or false to stop. func (tree *BTree) IteratorDescFrom(key interface{}, match bool, f func(key, value interface{}) bool) { diff --git a/container/gtree/gtree_redblacktree.go b/container/gtree/gtree_redblacktree.go index 6883133dd..2b917d649 100644 --- a/container/gtree/gtree_redblacktree.go +++ b/container/gtree/gtree_redblacktree.go @@ -235,8 +235,8 @@ func (tree *RedBlackTree) GetVarOrSetFuncLock(key interface{}, f func() interfac return gvar.New(tree.GetOrSetFuncLock(key, f)) } -// SetIfNotExist sets to the map if the `key` does not exist, and then returns true. -// It returns false if exists, and `value` would be ignored. +// SetIfNotExist sets `value` to the map if the `key` does not exist, and then returns true. +// It returns false if `key` exists, and `value` would be ignored. func (tree *RedBlackTree) SetIfNotExist(key interface{}, value interface{}) bool { if !tree.Contains(key) { tree.doSetWithLockCheck(key, value) @@ -246,7 +246,7 @@ func (tree *RedBlackTree) SetIfNotExist(key interface{}, value interface{}) bool } // SetIfNotExistFunc sets value with return value of callback function `f`, and then returns true. -// It returns false if exists, and `value` would be ignored. +// It returns false if `key` exists, and `value` would be ignored. func (tree *RedBlackTree) SetIfNotExistFunc(key interface{}, f func() interface{}) bool { if !tree.Contains(key) { tree.doSetWithLockCheck(key, f()) @@ -256,7 +256,7 @@ func (tree *RedBlackTree) SetIfNotExistFunc(key interface{}, f func() interface{ } // SetIfNotExistFuncLock sets value with return value of callback function `f`, and then returns true. -// It returns false if exists, and `value` would be ignored. +// It returns false if `key` exists, and `value` would be ignored. // // SetIfNotExistFuncLock differs with SetIfNotExistFunc function is that // it executes function `f` with mutex.Lock of the hash map. @@ -508,7 +508,7 @@ func (tree *RedBlackTree) IteratorAsc(f func(key, value interface{}) bool) { } // IteratorAscFrom iterates the tree readonly in ascending order with given callback function `f`. -// The parameter specifies the start entry for iterating. The `match` specifies whether +// The parameter `key` specifies the start entry for iterating. The `match` specifies whether // starting iterating if the `key` is fully matched, or else using index searching iterating. // If `f` returns true, then it continues iterating; or false to stop. func (tree *RedBlackTree) IteratorAscFrom(key interface{}, match bool, f func(key, value interface{}) bool) { @@ -559,7 +559,7 @@ func (tree *RedBlackTree) IteratorDesc(f func(key, value interface{}) bool) { } // IteratorDescFrom iterates the tree readonly in descending order with given callback function `f`. -// The parameter specifies the start entry for iterating. The `match` specifies whether +// The parameter `key` specifies the start entry for iterating. The `match` specifies whether // starting iterating if the `key` is fully matched, or else using index searching iterating. // If `f` returns true, then it continues iterating; or false to stop. func (tree *RedBlackTree) IteratorDescFrom(key interface{}, match bool, f func(key, value interface{}) bool) { diff --git a/database/gdb/gdb_model_utility.go b/database/gdb/gdb_model_utility.go index 089d87873..b01438a62 100644 --- a/database/gdb/gdb_model_utility.go +++ b/database/gdb/gdb_model_utility.go @@ -225,7 +225,7 @@ func (m *Model) getPrimaryKey() string { return "" } -// mergeArguments creates and returns new arguments by merging and given `args`. +// mergeArguments creates and returns new arguments by merging `m.extraArgs` and given `args`. func (m *Model) mergeArguments(args []interface{}) []interface{} { if len(m.extraArgs) > 0 { newArgs := make([]interface{}, len(m.extraArgs)+len(args)) diff --git a/database/gredis/gredis_instance.go b/database/gredis/gredis_instance.go index 9efbef886..915099726 100644 --- a/database/gredis/gredis_instance.go +++ b/database/gredis/gredis_instance.go @@ -17,7 +17,7 @@ var ( ) // Instance returns an instance of redis client with specified group. -// The param is unnecessary, if `name` is not passed, +// The `name` param is unnecessary, if `name` is not passed, // it returns a redis instance with default configuration group. func Instance(name ...string) *Redis { group := DefaultGroupName diff --git a/debug/gdebug/gdebug_caller.go b/debug/gdebug/gdebug_caller.go index 660a9c67e..d084b8c58 100644 --- a/debug/gdebug/gdebug_caller.go +++ b/debug/gdebug/gdebug_caller.go @@ -86,7 +86,7 @@ func CallerWithFilter(filter string, skip ...int) (function string, path string, // callerFromIndex returns the caller position and according information exclusive of the // debug package. // -// VERY NOTE THAT, the returned index value should be as the caller's start point. +// VERY NOTE THAT, the returned index value should be `index - 1` as the caller's start point. func callerFromIndex(filters []string) (pc uintptr, file string, line int, index int) { var filtered, ok bool for index = 0; index < maxCallerDepth; index++ { diff --git a/encoding/gbase64/gbase64.go b/encoding/gbase64/gbase64.go index 30e104aec..6222f4289 100644 --- a/encoding/gbase64/gbase64.go +++ b/encoding/gbase64/gbase64.go @@ -29,7 +29,7 @@ func EncodeToString(src []byte) string { return string(Encode(src)) } -// EncryptFile encodes file content of using BASE64 algorithms. +// EncryptFile encodes file content of `path` using BASE64 algorithms. func EncodeFile(path string) ([]byte, error) { content, err := ioutil.ReadFile(path) if err != nil { @@ -38,7 +38,7 @@ func EncodeFile(path string) ([]byte, error) { return Encode(content), nil } -// MustEncodeFile encodes file content of using BASE64 algorithms. +// MustEncodeFile encodes file content of `path` using BASE64 algorithms. // It panics if any error occurs. func MustEncodeFile(path string) []byte { result, err := EncodeFile(path) @@ -48,7 +48,7 @@ func MustEncodeFile(path string) []byte { return result } -// EncodeFileToString encodes file content of to string using BASE64 algorithms. +// EncodeFileToString encodes file content of `path` to string using BASE64 algorithms. func EncodeFileToString(path string) (string, error) { content, err := EncodeFile(path) if err != nil { @@ -57,7 +57,7 @@ func EncodeFileToString(path string) (string, error) { return string(content), nil } -// MustEncodeFileToString encodes file content of to string using BASE64 algorithms. +// MustEncodeFileToString encodes file content of `path` to string using BASE64 algorithms. // It panics if any error occurs. func MustEncodeFileToString(path string) string { result, err := EncodeFileToString(path) diff --git a/encoding/gbinary/gbinary_be.go b/encoding/gbinary/gbinary_be.go index 2313aff1d..2ff9b2e64 100644 --- a/encoding/gbinary/gbinary_be.go +++ b/encoding/gbinary/gbinary_be.go @@ -13,8 +13,8 @@ import ( "math" ) -// BeEncode encodes one or multiple into bytes using BigEndian. -// It uses type asserting checking the type of each value of and internally +// BeEncode encodes one or multiple `values` into bytes using BigEndian. +// It uses type asserting checking the type of each value of `values` and internally // calls corresponding converting function do the bytes converting. // // It supports common variable type asserting, and finally it uses fmt.Sprintf converting @@ -269,7 +269,7 @@ func BeDecodeToFloat64(b []byte) float64 { return math.Float64frombits(binary.BigEndian.Uint64(BeFillUpSize(b, 8))) } -// BeFillUpSize fills up the bytes to given length using big BigEndian. +// BeFillUpSize fills up the bytes `b` to given length `l` using big BigEndian. // // Note that it creates a new bytes slice by copying the original one to avoid changing // the original parameter bytes. diff --git a/encoding/gbinary/gbinary_le.go b/encoding/gbinary/gbinary_le.go index 001208ddf..63e7cbe0f 100644 --- a/encoding/gbinary/gbinary_le.go +++ b/encoding/gbinary/gbinary_le.go @@ -13,8 +13,8 @@ import ( "math" ) -// LeEncode encodes one or multiple into bytes using LittleEndian. -// It uses type asserting checking the type of each value of and internally +// LeEncode encodes one or multiple `values` into bytes using LittleEndian. +// It uses type asserting checking the type of each value of `values` and internally // calls corresponding converting function do the bytes converting. // // It supports common variable type asserting, and finally it uses fmt.Sprintf converting diff --git a/encoding/gcharset/gcharset.go b/encoding/gcharset/gcharset.go index 61f6fa0bf..2caf48612 100644 --- a/encoding/gcharset/gcharset.go +++ b/encoding/gcharset/gcharset.go @@ -40,20 +40,20 @@ var ( } ) -// Supported returns whether charset is supported. +// Supported returns whether charset `charset` is supported. func Supported(charset string) bool { return getEncoding(charset) != nil } -// Convert converts charset encoding from to , +// Convert converts `src` charset encoding from `srcCharset` to `dstCharset`, // and returns the converted string. -// It returns as if it fails converting. +// It returns `src` as `dst` if it fails converting. func Convert(dstCharset string, srcCharset string, src string) (dst string, err error) { if dstCharset == srcCharset { return src, nil } dst = src - // Converting to UTF-8. + // Converting `src` to UTF-8. if srcCharset != "UTF-8" { if e := getEncoding(srcCharset); e != nil { tmp, err := ioutil.ReadAll( @@ -67,7 +67,7 @@ func Convert(dstCharset string, srcCharset string, src string) (dst string, err return dst, gerror.NewCodef(gcode.CodeInvalidParameter, "unsupported srcCharset: %s", srcCharset) } } - // Do the converting from UTF-8 to . + // Do the converting from UTF-8 to `dstCharset`. if dstCharset != "UTF-8" { if e := getEncoding(dstCharset); e != nil { tmp, err := ioutil.ReadAll( @@ -86,20 +86,20 @@ func Convert(dstCharset string, srcCharset string, src string) (dst string, err return dst, nil } -// ToUTF8 converts charset encoding from to UTF-8 , +// ToUTF8 converts `src` charset encoding from `srcCharset` to UTF-8 , // and returns the converted string. func ToUTF8(srcCharset string, src string) (dst string, err error) { return Convert("UTF-8", srcCharset, src) } -// UTF8To converts charset encoding from UTF-8 to , +// UTF8To converts `src` charset encoding from UTF-8 to `dstCharset`, // and returns the converted string. func UTF8To(dstCharset string, src string) (dst string, err error) { return Convert(dstCharset, "UTF-8", src) } -// getEncoding returns the encoding.Encoding interface object for . -// It returns nil if is not supported. +// getEncoding returns the encoding.Encoding interface object for `charset`. +// It returns nil if `charset` is not supported. func getEncoding(charset string) encoding.Encoding { if c, ok := charsetAlias[charset]; ok { charset = c diff --git a/encoding/gcompress/gcompress_gzip.go b/encoding/gcompress/gcompress_gzip.go index 9cfee7215..b7b44a49f 100644 --- a/encoding/gcompress/gcompress_gzip.go +++ b/encoding/gcompress/gcompress_gzip.go @@ -13,11 +13,11 @@ import ( "io" ) -// Gzip compresses using gzip algorithm. -// The optional parameter specifies the compression level from +// Gzip compresses `data` using gzip algorithm. +// The optional parameter `level` specifies the compression level from // 1 to 9 which means from none to the best compression. // -// Note that it returns error if given is invalid. +// Note that it returns error if given `level` is invalid. func Gzip(data []byte, level ...int) ([]byte, error) { var ( writer *gzip.Writer @@ -41,7 +41,7 @@ func Gzip(data []byte, level ...int) ([]byte, error) { return buf.Bytes(), nil } -// GzipFile compresses the file to using gzip algorithm. +// GzipFile compresses the file `src` to `dst` using gzip algorithm. func GzipFile(src, dst string, level ...int) error { var ( writer *gzip.Writer @@ -75,7 +75,7 @@ func GzipFile(src, dst string, level ...int) error { return nil } -// UnGzip decompresses with gzip algorithm. +// UnGzip decompresses `data` with gzip algorithm. func UnGzip(data []byte) ([]byte, error) { var buf bytes.Buffer reader, err := gzip.NewReader(bytes.NewReader(data)) @@ -91,7 +91,7 @@ func UnGzip(data []byte) ([]byte, error) { return buf.Bytes(), nil } -// UnGzip decompresses file to using gzip algorithm. +// UnGzip decompresses file `src` to `dst` using gzip algorithm. func UnGzipFile(src, dst string) error { srcFile, err := gfile.Open(src) if err != nil { diff --git a/encoding/gcompress/gcompress_zip.go b/encoding/gcompress/gcompress_zip.go index f63f96367..74a255de7 100644 --- a/encoding/gcompress/gcompress_zip.go +++ b/encoding/gcompress/gcompress_zip.go @@ -19,10 +19,10 @@ import ( "strings" ) -// ZipPath compresses to using zip compressing algorithm. -// The unnecessary parameter indicates the path prefix for zip file. +// ZipPath compresses `paths` to `dest` using zip compressing algorithm. +// The unnecessary parameter `prefix` indicates the path prefix for zip file. // -// Note that the parameter can be either a directory or a file, which +// Note that the parameter `paths` can be either a directory or a file, which // supports multiple paths join with ','. func ZipPath(paths, dest string, prefix ...string) error { writer, err := os.Create(dest) @@ -41,10 +41,10 @@ func ZipPath(paths, dest string, prefix ...string) error { return nil } -// ZipPathWriter compresses to using zip compressing algorithm. -// The unnecessary parameter indicates the path prefix for zip file. +// ZipPathWriter compresses `paths` to `writer` using zip compressing algorithm. +// The unnecessary parameter `prefix` indicates the path prefix for zip file. // -// Note that the parameter can be either a directory or a file, which +// Note that the parameter `paths` can be either a directory or a file, which // supports multiple paths join with ','. func ZipPathWriter(paths string, writer io.Writer, prefix ...string) error { zipWriter := zip.NewWriter(writer) @@ -58,10 +58,10 @@ func ZipPathWriter(paths string, writer io.Writer, prefix ...string) error { return nil } -// doZipPathWriter compresses the file of given and writes the content to . -// The parameter specifies the exclusive file path that is not compressed to , +// doZipPathWriter compresses the file of given `path` and writes the content to `zipWriter`. +// The parameter `exclude` specifies the exclusive file path that is not compressed to `zipWriter`, // commonly the destination zip file path. -// The unnecessary parameter indicates the path prefix for zip file. +// The unnecessary parameter `prefix` indicates the path prefix for zip file. func doZipPathWriter(path string, exclude string, zipWriter *zip.Writer, prefix ...string) error { var err error var files []string @@ -108,11 +108,11 @@ func doZipPathWriter(path string, exclude string, zipWriter *zip.Writer, prefix return nil } -// UnZipFile decompresses to using zip compressing algorithm. -// The optional parameter specifies the unzipped path of , +// UnZipFile decompresses `archive` to `dest` using zip compressing algorithm. +// The optional parameter `path` specifies the unzipped path of `archive`, // which can be used to specify part of the archive file to unzip. // -// Note that the parameter should be a directory. +// Note that the parameter `dest` should be a directory. func UnZipFile(archive, dest string, path ...string) error { readerCloser, err := zip.OpenReader(archive) if err != nil { @@ -122,11 +122,11 @@ func UnZipFile(archive, dest string, path ...string) error { return unZipFileWithReader(&readerCloser.Reader, dest, path...) } -// UnZipContent decompresses to using zip compressing algorithm. -// The parameter specifies the unzipped path of , +// UnZipContent decompresses `data` to `dest` using zip compressing algorithm. +// The parameter `path` specifies the unzipped path of `archive`, // which can be used to specify part of the archive file to unzip. // -// Note that the parameter should be a directory. +// Note that the parameter `dest` should be a directory. func UnZipContent(data []byte, dest string, path ...string) error { reader, err := zip.NewReader(bytes.NewReader(data), int64(len(data))) if err != nil { @@ -186,8 +186,8 @@ func unZipFileWithReader(reader *zip.Reader, dest string, path ...string) error return nil } -// zipFile compresses the file of given and writes the content to . -// The parameter indicates the path prefix for zip file. +// zipFile compresses the file of given `path` and writes the content to `zw`. +// The parameter `prefix` indicates the path prefix for zip file. func zipFile(path string, prefix string, zw *zip.Writer) error { file, err := os.Open(path) if err != nil { diff --git a/encoding/gcompress/gcompress_zlib.go b/encoding/gcompress/gcompress_zlib.go index 8d3f74605..f0dc74660 100644 --- a/encoding/gcompress/gcompress_zlib.go +++ b/encoding/gcompress/gcompress_zlib.go @@ -13,7 +13,7 @@ import ( "io" ) -// Zlib compresses with zlib algorithm. +// Zlib compresses `data` with zlib algorithm. func Zlib(data []byte) ([]byte, error) { if data == nil || len(data) < 13 { return data, nil @@ -30,7 +30,7 @@ func Zlib(data []byte) ([]byte, error) { return in.Bytes(), nil } -// UnZlib decompresses with zlib algorithm. +// UnZlib decompresses `data` with zlib algorithm. func UnZlib(data []byte) ([]byte, error) { if data == nil || len(data) < 13 { return data, nil diff --git a/encoding/gjson/gjson.go b/encoding/gjson/gjson.go index f5210f32c..2461ca5ff 100644 --- a/encoding/gjson/gjson.go +++ b/encoding/gjson/gjson.go @@ -43,7 +43,7 @@ type iInterface interface { Interface() interface{} } -// setValue sets to by . +// setValue sets `value` to `j` by `pattern`. // Note: // 1. If value is nil and removed is true, means deleting this value; // 2. It's quite complicated in hierarchical data search, node creating and data assignment; @@ -206,7 +206,7 @@ func (j *Json) setValue(pattern string, value interface{}, removed bool) error { } } - // If the variable pointed to by the is not of a reference type, + // If the variable pointed to by the `pointer` is not of a reference type, // then it modifies the variable via its the parent, ie: pparent. default: if removed && value == nil { @@ -250,7 +250,7 @@ done: return nil } -// convertValue converts to map[string]interface{} or []interface{}, +// convertValue converts `value` to map[string]interface{} or []interface{}, // which can be supported for hierarchical data access. func (j *Json) convertValue(value interface{}) interface{} { switch value.(type) { @@ -283,7 +283,7 @@ func (j *Json) convertValue(value interface{}) interface{} { } } -// setPointerWithValue sets : to , the may be a map key or slice index. +// setPointerWithValue sets `key`:`value` to `pointer`, the `key` may be a map key or slice index. // It returns the pointer to the new value set. func (j *Json) setPointerWithValue(pointer *interface{}, key string, value interface{}) *interface{} { switch (*pointer).(type) { @@ -308,7 +308,7 @@ func (j *Json) setPointerWithValue(pointer *interface{}, key string, value inter return pointer } -// getPointerByPattern returns a pointer to the value by specified . +// getPointerByPattern returns a pointer to the value by specified `pattern`. func (j *Json) getPointerByPattern(pattern string) *interface{} { if j.vc { return j.getPointerByPatternWithViolenceCheck(pattern) @@ -317,7 +317,7 @@ func (j *Json) getPointerByPattern(pattern string) *interface{} { } } -// getPointerByPatternWithViolenceCheck returns a pointer to the value of specified with violence check. +// getPointerByPatternWithViolenceCheck returns a pointer to the value of specified `pattern` with violence check. func (j *Json) getPointerByPatternWithViolenceCheck(pattern string) *interface{} { if !j.vc { return j.getPointerByPatternWithoutViolenceCheck(pattern) @@ -367,7 +367,7 @@ func (j *Json) getPointerByPatternWithViolenceCheck(pattern string) *interface{} return nil } -// getPointerByPatternWithoutViolenceCheck returns a pointer to the value of specified , with no violence check. +// getPointerByPatternWithoutViolenceCheck returns a pointer to the value of specified `pattern`, with no violence check. func (j *Json) getPointerByPatternWithoutViolenceCheck(pattern string) *interface{} { if j.vc { return j.getPointerByPatternWithViolenceCheck(pattern) @@ -401,7 +401,7 @@ func (j *Json) getPointerByPatternWithoutViolenceCheck(pattern string) *interfac return nil } -// checkPatternByPointer checks whether there's value by in specified . +// checkPatternByPointer checks whether there's value by `key` in specified `pointer`. // It returns a pointer to the value. func (j *Json) checkPatternByPointer(key string, pointer *interface{}) *interface{} { switch (*pointer).(type) { diff --git a/encoding/gjson/gjson_api.go b/encoding/gjson/gjson_api.go index 29cdbf307..6d0a3a067 100644 --- a/encoding/gjson/gjson_api.go +++ b/encoding/gjson/gjson_api.go @@ -27,21 +27,21 @@ func (j *Json) Var() *gvar.Var { return gvar.New(j.Interface()) } -// IsNil checks whether the value pointed by is nil. +// IsNil checks whether the value pointed by `j` is nil. func (j *Json) IsNil() bool { j.mu.RLock() defer j.mu.RUnlock() return j.p == nil || *(j.p) == nil } -// Get retrieves and returns value by specified . -// It returns all values of current Json object if is given empty or string ".". -// It returns nil if no value found by . +// Get retrieves and returns value by specified `pattern`. +// It returns all values of current Json object if `pattern` is given empty or string ".". +// It returns nil if no value found by `pattern`. // -// We can also access slice item by its index number in like: +// We can also access slice item by its index number in `pattern` like: // "list.10", "array.0.name", "array.0.1.id". // -// It returns a default value specified by if value for is not found. +// It returns a default value specified by `def` if value for `pattern` is not found. func (j *Json) Get(pattern string, def ...interface{}) *gvar.Var { j.mu.RLock() defer j.mu.RUnlock() @@ -66,13 +66,13 @@ func (j *Json) Get(pattern string, def ...interface{}) *gvar.Var { return nil } -// GetJson gets the value by specified , +// GetJson gets the value by specified `pattern`, // and converts it to a un-concurrent-safe Json object. func (j *Json) GetJson(pattern string, def ...interface{}) *Json { return New(j.Get(pattern, def...).Val()) } -// GetJsons gets the value by specified , +// GetJsons gets the value by specified `pattern`, // and converts it to a slice of un-concurrent-safe Json object. func (j *Json) GetJsons(pattern string, def ...interface{}) []*Json { array := j.Get(pattern, def...).Array() @@ -86,7 +86,7 @@ func (j *Json) GetJsons(pattern string, def ...interface{}) []*Json { return nil } -// GetJsonMap gets the value by specified , +// GetJsonMap gets the value by specified `pattern`, // and converts it to a map of un-concurrent-safe Json object. func (j *Json) GetJsonMap(pattern string, def ...interface{}) map[string]*Json { m := j.Get(pattern, def...).Map() @@ -100,25 +100,25 @@ func (j *Json) GetJsonMap(pattern string, def ...interface{}) map[string]*Json { return nil } -// Set sets value with specified . +// Set sets value with specified `pattern`. // It supports hierarchical data access by char separator, which is '.' in default. func (j *Json) Set(pattern string, value interface{}) error { return j.setValue(pattern, value, false) } -// Remove deletes value with specified . +// Remove deletes value with specified `pattern`. // It supports hierarchical data access by char separator, which is '.' in default. func (j *Json) Remove(pattern string) error { return j.setValue(pattern, nil, true) } -// Contains checks whether the value by specified exist. +// Contains checks whether the value by specified `pattern` exist. func (j *Json) Contains(pattern string) bool { return j.Get(pattern) != nil } -// Len returns the length/size of the value by specified . -// The target value by should be type of slice or map. +// Len returns the length/size of the value by specified `pattern`. +// The target value by `pattern` should be type of slice or map. // It returns -1 if the target value is not found, or its type is invalid. func (j *Json) Len(pattern string) int { p := j.getPointerByPattern(pattern) @@ -135,8 +135,8 @@ func (j *Json) Len(pattern string) int { return -1 } -// Append appends value to the value by specified . -// The target value by should be type of slice. +// Append appends value to the value by specified `pattern`. +// The target value by `pattern` should be type of slice. func (j *Json) Append(pattern string, value interface{}) error { p := j.getPointerByPattern(pattern) if p == nil || *p == nil { @@ -168,7 +168,7 @@ func (j *Json) Array() []interface{} { } // Scan automatically calls Struct or Structs function according to the type of parameter -// to implement the converting. +// `pointer` to implement the converting. func (j *Json) Scan(pointer interface{}, mapping ...map[string]string) error { return j.Var().Scan(pointer, mapping...) } @@ -180,7 +180,7 @@ func (j *Json) Dump() { gutil.Dump(*j.p) } -// Export returns as a string with more manually readable. +// Export returns `j` as a string with more manually readable. func (j *Json) Export() string { j.mu.RLock() defer j.mu.RUnlock() diff --git a/encoding/gjson/gjson_api_new_load.go b/encoding/gjson/gjson_api_new_load.go index cfd9a3304..ddaac9097 100644 --- a/encoding/gjson/gjson_api_new_load.go +++ b/encoding/gjson/gjson_api_new_load.go @@ -24,22 +24,22 @@ import ( "github.com/gogf/gf/v2/util/gconv" ) -// New creates a Json object with any variable type of , but should be a map +// New creates a Json object with any variable type of `data`, but `data` should be a map // or slice for data access reason, or it will make no sense. // -// The parameter specifies whether using this Json object in concurrent-safe context, +// The parameter `safe` specifies whether using this Json object in concurrent-safe context, // which is false in default. func New(data interface{}, safe ...bool) *Json { return NewWithTag(data, "json", safe...) } -// NewWithTag creates a Json object with any variable type of , but should be a map +// NewWithTag creates a Json object with any variable type of `data`, but `data` should be a map // or slice for data access reason, or it will make no sense. // -// The parameter specifies priority tags for struct conversion to map, multiple tags joined +// The parameter `tags` specifies priority tags for struct conversion to map, multiple tags joined // with char ','. // -// The parameter specifies whether using this Json object in concurrent-safe context, which +// The parameter `safe` specifies whether using this Json object in concurrent-safe context, which // is false in default. func NewWithTag(data interface{}, tags string, safe ...bool) *Json { option := Options{ @@ -51,7 +51,7 @@ func NewWithTag(data interface{}, tags string, safe ...bool) *Json { return NewWithOptions(data, option) } -// NewWithOptions creates a Json object with any variable type of , but should be a map +// NewWithOptions creates a Json object with any variable type of `data`, but `data` should be a map // or slice for data access reason, or it will make no sense. func NewWithOptions(data interface{}, options Options) *Json { var j *Json @@ -104,7 +104,7 @@ func NewWithOptions(data interface{}, options Options) *Json { return j } -// Load loads content from specified file , and creates a Json object from its content. +// Load loads content from specified file `path`, and creates a Json object from its content. func Load(path string, safe ...bool) (*Json, error) { if p, err := gfile.Search(path); err != nil { return nil, err @@ -163,7 +163,7 @@ func LoadToml(data interface{}, safe ...bool) (*Json, error) { return doLoadContentWithOptions("toml", gconv.Bytes(data), option) } -// LoadContent creates a Json object from given content, it checks the data type of +// LoadContent creates a Json object from given content, it checks the data type of `content` // automatically, supporting data content type as follows: // JSON, XML, INI, YAML and TOML. func LoadContent(data interface{}, safe ...bool) (*Json, error) { @@ -193,7 +193,7 @@ func LoadContentType(dataType string, data interface{}, safe ...bool) (*Json, er return doLoadContentWithOptions(dataType, content, option) } -// IsValidDataType checks and returns whether given a valid data type for loading. +// IsValidDataType checks and returns whether given `dataType` a valid data type for loading. func IsValidDataType(dataType string) bool { if dataType == "" { return false @@ -285,7 +285,7 @@ func doLoadContentWithOptions(dataType string, data []byte, options Options) (*J return NewWithOptions(result, options), nil } -// checkDataType automatically checks and returns the data type for . +// checkDataType automatically checks and returns the data type for `content`. // Note that it uses regular expression for loose checking, you can use LoadXXX/LoadContentType // functions to load the content for certain content type. func checkDataType(content []byte) string { diff --git a/encoding/gjson/gjson_stdlib_json_util.go b/encoding/gjson/gjson_stdlib_json_util.go index 9885e051f..33d7c7481 100644 --- a/encoding/gjson/gjson_stdlib_json_util.go +++ b/encoding/gjson/gjson_stdlib_json_util.go @@ -12,20 +12,20 @@ import ( "github.com/gogf/gf/v2/util/gconv" ) -// Valid checks whether is a valid JSON data type. -// The parameter specifies the json format data, which can be either +// Valid checks whether `data` is a valid JSON data type. +// The parameter `data` specifies the json format data, which can be either // bytes or string type. func Valid(data interface{}) bool { return json.Valid(gconv.Bytes(data)) } -// Encode encodes any golang variable to JSON bytes. +// Encode encodes any golang variable `value` to JSON bytes. func Encode(value interface{}) ([]byte, error) { return json.Marshal(value) } -// Decode decodes json format to golang variable. -// The parameter can be either bytes or string type. +// Decode decodes json format `data` to golang variable. +// The parameter `data` can be either bytes or string type. func Decode(data interface{}) (interface{}, error) { var value interface{} if err := DecodeTo(gconv.Bytes(data), &value); err != nil { @@ -35,9 +35,9 @@ func Decode(data interface{}) (interface{}, error) { } } -// DecodeTo decodes json format to specified golang variable . -// The parameter can be either bytes or string type. -// The parameter should be a pointer type. +// DecodeTo decodes json format `data` to specified golang variable `v`. +// The parameter `data` can be either bytes or string type. +// The parameter `v` should be a pointer type. func DecodeTo(data interface{}, v interface{}) error { decoder := json.NewDecoder(bytes.NewReader(gconv.Bytes(data))) // Do not use number, it converts float64 to json.Number type, @@ -47,8 +47,8 @@ func DecodeTo(data interface{}, v interface{}) error { return decoder.Decode(v) } -// DecodeToJson codes json format to a Json object. -// The parameter can be either bytes or string type. +// DecodeToJson codes json format `data` to a Json object. +// The parameter `data` can be either bytes or string type. func DecodeToJson(data interface{}, safe ...bool) (*Json, error) { if v, err := Decode(gconv.Bytes(data)); err != nil { return nil, err diff --git a/encoding/gxml/gxml.go b/encoding/gxml/gxml.go index 9fc55d2c8..9dc9a5780 100644 --- a/encoding/gxml/gxml.go +++ b/encoding/gxml/gxml.go @@ -15,7 +15,7 @@ import ( "github.com/gogf/gf/v2/text/gregex" ) -// Decode parses into and returns as map. +// Decode parses `content` into and returns as map. func Decode(content []byte) (map[string]interface{}, error) { res, err := convert(content) if err != nil { @@ -24,7 +24,7 @@ func Decode(content []byte) (map[string]interface{}, error) { return mxj.NewMapXml(res) } -// DecodeWithoutRoot parses into a map, and returns the map without root level. +// DecodeWithoutRoot parses `content` into a map, and returns the map without root level. func DecodeWithoutRoot(content []byte) (map[string]interface{}, error) { res, err := convert(content) if err != nil { @@ -42,19 +42,19 @@ func DecodeWithoutRoot(content []byte) (map[string]interface{}, error) { return m, nil } -// Encode encodes map to a XML format content as bytes. -// The optional parameter is used to specify the XML root tag. +// Encode encodes map `m` to an XML format content as bytes. +// The optional parameter `rootTag` is used to specify the XML root tag. func Encode(m map[string]interface{}, rootTag ...string) ([]byte, error) { return mxj.Map(m).Xml(rootTag...) } -// EncodeWithIndent encodes map to an XML format content as bytes with indent. -// The optional parameter is used to specify the XML root tag. +// EncodeWithIndent encodes map `m` to an XML format content as bytes with indent. +// The optional parameter `rootTag` is used to specify the XML root tag. func EncodeWithIndent(m map[string]interface{}, rootTag ...string) ([]byte, error) { return mxj.Map(m).XmlIndent("", "\t", rootTag...) } -// ToJson converts as XML format into JSON format bytes. +// ToJson converts `content` as XML format into JSON format bytes. func ToJson(content []byte) ([]byte, error) { res, err := convert(content) if err != nil { diff --git a/frame/g/g_func.go b/frame/g/g_func.go index 25e4f6060..d656c9b6d 100644 --- a/frame/g/g_func.go +++ b/frame/g/g_func.go @@ -61,7 +61,7 @@ func TryCatch(try func(), catch ...func(exception error)) { } // IsNil checks whether given `value` is nil. -// Parameter is used for tracing to the source variable if given `value` is type +// Parameter `traceSource` is used for tracing to the source variable if given `value` is type // of pinter that also points to a pointer. It returns nil if the source is nil when `traceSource` // is true. // Note that it might use reflect feature which affects performance a little. diff --git a/frame/gins/gins.go b/frame/gins/gins.go index 070984329..6c1c19f74 100644 --- a/frame/gins/gins.go +++ b/frame/gins/gins.go @@ -49,8 +49,8 @@ func GetOrSetFuncLock(name string, f func() interface{}) interface{} { return localInstances.GetOrSetFuncLock(name, f) } -// SetIfNotExist sets to the map if the `name` does not exist, then returns true. -// It returns false if exists, and `instance` would be ignored. +// SetIfNotExist sets `instance` to the map if the `name` does not exist, then returns true. +// It returns false if `name` exists, and `instance` would be ignored. func SetIfNotExist(name string, instance interface{}) bool { return localInstances.SetIfNotExist(name, instance) } diff --git a/i18n/gi18n/gi18n.go b/i18n/gi18n/gi18n.go index 460239807..09b78f114 100644 --- a/i18n/gi18n/gi18n.go +++ b/i18n/gi18n/gi18n.go @@ -34,13 +34,13 @@ func Tf(ctx context.Context, format string, values ...interface{}) string { return Instance().TranslateFormat(ctx, format, values...) } -// TranslateFormat translates, formats and returns the with configured language -// and given . +// TranslateFormat translates, formats and returns the `format` with configured language +// and given `values`. func TranslateFormat(ctx context.Context, format string, values ...interface{}) string { return Instance().TranslateFormat(ctx, format, values...) } -// Translate translates with configured language and returns the translated content. +// Translate translates `content` with configured language and returns the translated content. func Translate(ctx context.Context, content string) string { return Instance().Translate(ctx, content) } diff --git a/i18n/gi18n/gi18n_instance.go b/i18n/gi18n/gi18n_instance.go index 7fdb4541f..58505b948 100644 --- a/i18n/gi18n/gi18n_instance.go +++ b/i18n/gi18n/gi18n_instance.go @@ -20,7 +20,7 @@ var ( ) // Instance returns an instance of Resource. -// The parameter is the name for the instance. +// The parameter `name` is the name for the instance. func Instance(name ...string) *Manager { key := DefaultName if len(name) > 0 && name[0] != "" { diff --git a/i18n/gi18n/gi18n_manager.go b/i18n/gi18n/gi18n_manager.go index ada7b9bc9..81bc954f0 100644 --- a/i18n/gi18n/gi18n_manager.go +++ b/i18n/gi18n/gi18n_manager.go @@ -48,7 +48,7 @@ var ( ) // New creates and returns a new i18n manager. -// The optional parameter

to its ip and port. +// ParseAddress parses `address` to its ip and port. // Eg: 192.168.1.1:80 -> 192.168.1.1, 80 func ParseAddress(address string) (string, int) { match, err := gregex.MatchString(`^(.+):(\d+)$`, address) diff --git a/net/gipv6/gipv6.go b/net/gipv6/gipv6.go index 74eeacd64..5b99917f9 100644 --- a/net/gipv6/gipv6.go +++ b/net/gipv6/gipv6.go @@ -9,7 +9,7 @@ package gipv6 import "github.com/gogf/gf/v2/text/gregex" -// Validate checks whether given a valid IPv6 address. +// Validate checks whether given `ip` a valid IPv6 address. func Validate(ip string) bool { return gregex.IsMatchString(`^([\da-fA-F]{1,4}:){7}[\da-fA-F]{1,4}$|^:((:[\da-fA-F]{1,4}){1,6}|:)$|^[\da-fA-F]{1,4}:((:[\da-fA-F]{1,4}){1,5}|:)$|^([\da-fA-F]{1,4}:){2}((:[\da-fA-F]{1,4}){1,4}|:)$|^([\da-fA-F]{1,4}:){3}((:[\da-fA-F]{1,4}){1,3}|:)$|^([\da-fA-F]{1,4}:){4}((:[\da-fA-F]{1,4}){1,2}|:)$|^([\da-fA-F]{1,4}:){5}:([\da-fA-F]{1,4})?$|^([\da-fA-F]{1,4}:){6}:$`, ip) } diff --git a/net/gsmtp/gsmtp.go b/net/gsmtp/gsmtp.go index bdf412735..5a1aa1aa2 100644 --- a/net/gsmtp/gsmtp.go +++ b/net/gsmtp/gsmtp.go @@ -43,10 +43,10 @@ var ( // SendMail connects to the server at addr, switches to TLS if // possible, authenticates with the optional mechanism an if possible, -// and then sends an email from address , to addresses , with +// and then sends an email from address `from`, to addresses `to`, with // message msg. // -// The parameter specifies the content type of the mail, eg: html. +// The parameter `contentType` specifies the content type of the mail, eg: html. func (s *SMTP) SendMail(from, tos, subject, body string, contentType ...string) error { var ( server = "" diff --git a/net/gtcp/gtcp_conn.go b/net/gtcp/gtcp_conn.go index ff0154c13..dbea3eb96 100644 --- a/net/gtcp/gtcp_conn.go +++ b/net/gtcp/gtcp_conn.go @@ -127,7 +127,7 @@ func (c *Conn) Recv(length int, retry ...Retry) ([]byte, error) { if size > 0 { index += size if length > 0 { - // It reads til size if is specified. + // It reads til `length` size if `length` is specified. if index == length { break } @@ -201,8 +201,8 @@ func (c *Conn) RecvLine(retry ...Retry) ([]byte, error) { return data, err } -// RecvTil reads data from the connection until reads bytes . -// Note that the returned result contains the last bytes . +// RecvTil reads data from the connection until reads bytes `til`. +// Note that the returned result contains the last bytes `til`. func (c *Conn) RecvTil(til []byte, retry ...Retry) ([]byte, error) { var err error var buffer []byte diff --git a/net/gtcp/gtcp_func.go b/net/gtcp/gtcp_func.go index 4ff25d404..5520b6aec 100644 --- a/net/gtcp/gtcp_func.go +++ b/net/gtcp/gtcp_func.go @@ -27,7 +27,7 @@ type Retry struct { } // NewNetConn creates and returns a net.Conn with given address like "127.0.0.1:80". -// The optional parameter specifies the timeout for dialing connection. +// The optional parameter `timeout` specifies the timeout for dialing connection. func NewNetConn(addr string, timeout ...time.Duration) (net.Conn, error) { d := defaultConnTimeout if len(timeout) > 0 { @@ -37,7 +37,7 @@ func NewNetConn(addr string, timeout ...time.Duration) (net.Conn, error) { } // NewNetConnTLS creates and returns a TLS net.Conn with given address like "127.0.0.1:80". -// The optional parameter specifies the timeout for dialing connection. +// The optional parameter `timeout` specifies the timeout for dialing connection. func NewNetConnTLS(addr string, tlsConfig *tls.Config, timeout ...time.Duration) (net.Conn, error) { dialer := &net.Dialer{ Timeout: defaultConnTimeout, @@ -49,7 +49,7 @@ func NewNetConnTLS(addr string, tlsConfig *tls.Config, timeout ...time.Duration) } // NewNetConnKeyCrt creates and returns a TLS net.Conn with given TLS certificate and key files -// and address like "127.0.0.1:80". The optional parameter specifies the timeout for +// and address like "127.0.0.1:80". The optional parameter `timeout` specifies the timeout for // dialing connection. func NewNetConnKeyCrt(addr, crtFile, keyFile string, timeout ...time.Duration) (net.Conn, error) { tlsConfig, err := LoadKeyCrt(crtFile, keyFile) @@ -59,8 +59,8 @@ func NewNetConnKeyCrt(addr, crtFile, keyFile string, timeout ...time.Duration) ( return NewNetConnTLS(addr, tlsConfig, timeout...) } -// Send creates connection to
, writes to the connection and then closes the connection. -// The optional parameter specifies the retry policy when fails in writing data. +// Send creates connection to `address`, writes `data` to the connection and then closes the connection. +// The optional parameter `retry` specifies the retry policy when fails in writing data. func Send(address string, data []byte, retry ...Retry) error { conn, err := NewConn(address) if err != nil { @@ -70,13 +70,13 @@ func Send(address string, data []byte, retry ...Retry) error { return conn.Send(data, retry...) } -// SendRecv creates connection to
, writes to the connection, receives response +// SendRecv creates connection to `address`, writes `data` to the connection, receives response // and then closes the connection. // -// The parameter specifies the bytes count waiting to receive. It receives all buffer content -// and returns if is -1. +// The parameter `length` specifies the bytes count waiting to receive. It receives all buffer content +// and returns if `length` is -1. // -// The optional parameter specifies the retry policy when fails in writing data. +// The optional parameter `retry` specifies the retry policy when fails in writing data. func SendRecv(address string, data []byte, length int, retry ...Retry) ([]byte, error) { conn, err := NewConn(address) if err != nil { @@ -106,7 +106,7 @@ func SendRecvWithTimeout(address string, data []byte, receive int, timeout time. return conn.SendRecvWithTimeout(data, receive, timeout, retry...) } -// isTimeout checks whether given is a timeout error. +// isTimeout checks whether given `err` is a timeout error. func isTimeout(err error) bool { if err == nil { return false diff --git a/net/gtcp/gtcp_func_pkg.go b/net/gtcp/gtcp_func_pkg.go index 09cf2fdb9..39a3754b1 100644 --- a/net/gtcp/gtcp_func_pkg.go +++ b/net/gtcp/gtcp_func_pkg.go @@ -8,8 +8,8 @@ package gtcp import "time" -// SendPkg sends a package containing to
and closes the connection. -// The optional parameter