Documentation ¶
Index ¶
- Variables
- func AppendFile(path string) (*os.File, error)
- func BackupFileName(path, extension string) string
- func CallerFuncName() (string, error)
- func CallerFuncNameString() string
- func CallerFuncNameStringWithOffset(i int) string
- func CallerFuncNameWithOffset(i int) (string, error)
- func CheckSnils(snils string) (bool, error)
- func CircularAdd(a int, max int) int
- func CountElementsOnPage(elementsTotal uint, page uint, pageSize uint) uint
- func CountPages(elementsTotal uint, pageSize uint) uint
- func EncodeToWindows1251(b []byte) ([]byte, error)
- func FileExists(path string) bool
- func FileSize(path string) int64
- func FormatPhone(phone string) (string, error)
- func GetFunctionName(function interface{}) (string, error)
- func GetIPAddress(request *http.Request) string
- func GetSelfPath() (string, error)
- func IsDir(path string) (bool, error)
- func IsEmptyDir(path string) (bool, error)
- func IsInDocker() bool
- func IsInGitlab() bool
- func IsInVexor() bool
- func IsNil(obj interface{}) bool
- func MarshalUnmarshalJSON(data, out interface{}) error
- func MustMarshalJSON(data interface{}) []byte
- func MustMarshalUnmarshalJSON(data, out interface{})
- func MustSelfPath() string
- func NewFileUploadRequest(req FileUploadRequest) (*http.Request, error)
- func PBool(b bool) *bool
- func PInt(i int) *int
- func PString(s string) *string
- func PUint(i uint) *uint
- func RemoveDuplicates(slice interface{}) (interface{}, bool, error)
- func RenderFloat(format string, n float64) (string, error)
- func RenderInteger(format string, n int64) (string, error)
- func Round(val float64, roundOn float64, places int) float64
- func SliceContains(needle interface{}, haystack interface{}) bool
- func SliceIntersects(a, b interface{}) bool
- func SortUints(a []uint)
- func StringSliceSubstract(a, b []string) []string
- func StringToStringSlice(s, sep string) []string
- func StringToUint(s string) (uint, error)
- func StringToUintSlice(s string, sep string, min uint) ([]uint, error)
- func SubstringBetween(s, l, r string) string
- func ToLowerFirstRune(s string) string
- func Try(actionFunc func() error, n int, delay time.Duration, ...) (int, error)
- func UintsAreSorted(a []uint) bool
- func UniqID(n int) (string, error)
- type FileUploadRequest
- type IndicesSlice
- type StringSlice
- type UintSlice
Constants ¶
This section is empty.
Variables ¶
var (
ErrorNotADirectory = errors.New("not a directory")
)
errors
Functions ¶
func BackupFileName ¶
BackupFileName returns a new name for inputFileName and backup extension, also checking the existence of other bak files with intention not to overwrite it when renaming to new name
func CallerFuncName ¶
CallerFuncName returns name of a func which is a caller for func from which CallerFuncName was called
func CallerFuncNameString ¶
func CallerFuncNameString() string
CallerFuncNameString returns a string from CallerFuncName
func CallerFuncNameStringWithOffset ¶ added in v1.0.11
CallerFuncNameStringWithOffset returns a string from CallerFuncNameWithOffset
func CallerFuncNameWithOffset ¶ added in v1.0.11
CallerFuncNameWithOffset works like CallerFuncName but skips additional i stack frames
func CheckSnils ¶
CheckSnils проверяет СНИЛС на валидность путём вычисления его контрольной суммы
func CircularAdd ¶
CircularAdd возвращает следующий элемент кольцевой целочисленной арифметики начиная от a, макс. элемент равен max
func CountElementsOnPage ¶
CountElementsOnPage возвращает количество элементов на заданной странице page с размером pageSize если всего элементов elementsTotal. Если pageSize равно 0, считается что оно равно elementsTotal
func CountPages ¶
CountPages возвращает количство страниц размера pageSize если всего элементов elementsTotal. Если pageSize равно 0, возвращает 1
func EncodeToWindows1251 ¶
EncodeToWindows1251 перекодирует срез байт b из стандартной Go кодировки UTF-8 в кодировку Windows-1251
func FileExists ¶
FileExists returns true if a file with given path exists
func FileSize ¶
FileSize returns size of a file with given path, it returns 0 if file doesn't exists or on error
func FormatPhone ¶
FormatPhone форматирует строку с номером телефона в формат "71234567890" Возвращает: Успех: Форматированный номер телефона, nil Ошибка: Исходный номер телефона, ошибка
func GetFunctionName ¶
GetFunctionName returns a name of function
func GetIPAddress ¶
GetIPAddress пытается получить IP адрес из заголовков HTTP возвращает соотв-ю строку, или "0.0.0.0"
func GetSelfPath ¶
GetSelfPath returns a path to the caller executable
func IsEmptyDir ¶ added in v1.0.6
IsEmptyDir returns true if the path specified is an empty directory
func IsInDocker ¶ added in v1.0.7
func IsInDocker() bool
IsInDocker returns whether execution is going inside a Docker container
func IsInGitlab ¶ added in v1.0.8
func IsInGitlab() bool
IsInGitlab returns true if we are in Gitlab
func IsNil ¶
func IsNil(obj interface{}) bool
IsNil returns true if obj is nil or contains empty value, otherwise returns false
func MarshalUnmarshalJSON ¶ added in v1.0.2
func MarshalUnmarshalJSON(data, out interface{}) error
MarshalUnmarshalJSON marshals data to JSON and unmarshal it to out. Useful to convert interface{} to something more concrete via JSON
func MustMarshalJSON ¶ added in v1.0.12
func MustMarshalJSON(data interface{}) []byte
MustMarshalJSON works as json.Marshal, but panics on error
func MustMarshalUnmarshalJSON ¶ added in v1.0.5
func MustMarshalUnmarshalJSON(data, out interface{})
MustMarshalUnmarshalJSON works like MarshalUnmarshalJSON but panic on error
func MustSelfPath ¶
func MustSelfPath() string
MustSelfPath returns path to this application executable, it panic at error
func NewFileUploadRequest ¶
func NewFileUploadRequest(req FileUploadRequest) (*http.Request, error)
NewFileUploadRequest creates a new file upload HTTP request with optional extra params
func RemoveDuplicates ¶
RemoveDuplicates returns a slice with duplicates removed. It omits NaN values and returns true in second parameter if a NaN value were found.
func Round ¶
Round округляет значение val. Возвращает округлённое значение. Параметр roundOn задаёт значение разряда, по которому определяется вид округления - в большую или в меньшую сторону. Параметр places определяет количество знаков после десятичной точки, в случае, если он положителен, до целых - если 0. Может быть отрицательным, в этом случае, например, при -1 округление выполняется до десятков. Примеры: Round(2.34, .5, 1) возвращает 2.3 Round(2.37, .5, 1) возвращает 2.4 Round(2.37, .5, 0) возвращает 2.0 Round(2.77, .5, 0) возвращает 3.0
func SliceContains ¶
func SliceContains(needle interface{}, haystack interface{}) bool
SliceContains checks for value of needle in slice haystack haystack's underlying type should be a slice, if not, the function panics
func SliceIntersects ¶ added in v1.0.10
func SliceIntersects(a, b interface{}) bool
SliceIntersects returns whether two slices intersects
func StringSliceSubstract ¶ added in v1.0.9
StringSliceSubstract substracts b from a, working with slices of strings
func StringToStringSlice ¶
StringToStringSlice converts a string values separated by sep to slice of string elements empty elements are ignored
func StringToUint ¶
StringToUint interpretes string as a value of type uint
func StringToUintSlice ¶
StringToUintSlice converts a string values separated by sep to slice of uint elements It returns an error if any element can't be converted to uint If a converted element is less than min, it will not be added empty elements are ignored
func SubstringBetween ¶
SubstringBetween returns a substring between substrs l and r from source string s
func ToLowerFirstRune ¶
ToLowerFirstRune returns string s with first rune converted to it's lowercase form
func Try ¶
func Try(actionFunc func() error, n int, delay time.Duration, conditionFunc func(e error) bool) (int, error)
Try tries n times to call an actionFunc() until conditionFunc() returns true actionFunc is a func returning error n is a number of times to try to call actionFunc() delay is a delay between calls actionFunc() conditionFunc is a func accepting error, if it returns true, Try will try again Try returns a number of attempts
func UintsAreSorted ¶
UintsAreSorted tests whether a slice of uints is sorted in increasing order.
Types ¶
type FileUploadRequest ¶
type FileUploadRequest struct { Uri string // uri to send request Params map[string]string // additional parameters or nil, would be written into request fields Key string // key of multipart field Data []byte // file data FileName string // file name }
FileUploadRequest это параметры для POST запроса с файлом
type IndicesSlice ¶
IndicesSlice is a type for sorting with indexes remembering
func NewIndicesSlice ¶
func NewIndicesSlice(n sort.Interface) *IndicesSlice
NewIndicesSlice creates new slice for sorting with indices remembering
func NewIndicesUintSlice ¶
func NewIndicesUintSlice(n ...uint) *IndicesSlice
NewIndicesUintSlice creates new slice of uint type for sorting with indices remembering
func (IndicesSlice) Swap ¶
func (s IndicesSlice) Swap(i, j int)
Swap reimplements Swap() for sort.Interface
type StringSlice ¶
type StringSlice []string
StringSlice это срез строк реализует интерфейс Stringer
func (StringSlice) String ¶
func (ss StringSlice) String() string
String возвращает строку, содержащую значения среза строк, где элементы разделены переносами строки