Documentation ¶
Index ¶
- Constants
- Variables
- func Bytes2String(b []byte) string
- func ChanIsClosed(ch any) bool
- func CheckFilepath(filename string, notExistToCreate ...bool) error
- func CloseQuietly(closer io.Closer)
- func Convert[T any](data []string, v *T) error
- func Copy[T any, S any](to *T, from *S) (err error)
- func CopyWithOption(toValue interface{}, fromValue interface{}, opt Option) (err error)
- func CsvToSlices[S ~[]E, E any](filename string, pointer *S) error
- func DateZero(t time.Time) time.Time
- func DifferDays(t1, t2 time.Time) int
- func EndsWith(str string, suffixes []string) bool
- func FileExist(path string) bool
- func FileIsValid(path string) bool
- func Filter[S ~[]E, E any](slice S, condition func(E) bool) S
- func Float64s(a *[]float64)
- func Float64sAreUnique(a []float64) bool
- func GetMonthDay(date ...string) (string, string)
- func GetQuarterByDate(date string, diffQuarters ...int) (quarter, first, last string)
- func GetQuarterDay(months ...int) (string, string)
- func GetQuarterDayByDate(date string, diffQuarters ...int) (firstOfQuarter, lastOfQuarter string)
- func GetWeekDay(date ...string) (string, string)
- func Ints(a *[]int)
- func IntsAreUnique(a []int) bool
- func IsEmpty(s string) bool
- func IsUniqued(data sort.Interface) bool
- func IsWorkday(t time.Time) bool
- func KebabCase(s string) string
- func LowerCamelCase(s string) string
- func ParseFloat(s string) float64
- func ParseInt(s string) int64
- func ParseTime(timestr string) (time.Time, error)
- func ParseUint(s string) uint64
- func Reverse[S ~[]E, E any](s S) S
- func SliceSort[S ~[]E, E any](slice S, less func(a, b E) bool)
- func SliceUnique[S ~[]E, E any](slice S, compare func(a E, b E) int) S
- func SlicesToCsv[S ~[]E, E any](filename string, s S) error
- func SnakeCase(s string) string
- func Sort(data Interface)
- func StartsWith(str string, prefixes []string) bool
- func String2Bytes(s string) []byte
- func Strings(a *[]string)
- func StringsAreUnique(a []string) bool
- func ToCamelCase(kebab string) (camelCase string)
- func ToFront(data sort.Interface) (n int)
- func ToString(value interface{}) string
- func Unique(data Interface)
- func UpperCamelCase(s string) string
- func UpperKebabCase(s string) string
- func UpperSnakeCase(s string) string
- type Float64Slice
- type IntSlice
- type Interface
- type Option
- type ScopeLimit
- type StringSlice
Constants ¶
const ( // CACHE_DIR_MODE 目录权限 CACHE_DIR_MODE os.FileMode = 0755 // CACHE_FILE_MODE 文件权限 CACHE_FILE_MODE os.FileMode = 0644 // DEBUG 调试开关 DEBUG = false // CACHE_REPLACE 文件替换模式, 会用到os.TRUNC CACHE_REPLACE = os.O_CREATE | os.O_RDWR | os.O_TRUNC // CACHE_UPDATE 更新 CACHE_UPDATE = os.O_CREATE | os.O_WRONLY )
const (
DefaultTagName = "dataframe"
)
const (
IGNORE_FLOAT = true
)
const (
YearOnly = "2006" // 日期格式仅输出"年"
)
Variables ¶
Functions ¶
func CopyWithOption ¶
CopyWithOption copy with option
func CsvToSlices ¶ added in v1.6.7
CsvToSlices CSV文件转struct切片
func Float64s ¶
func Float64s(a *[]float64)
Float64s removes duplicate elements from a sorted slice of float64s.
func Float64sAreUnique ¶
Float64sAreUnique tests whether a slice of float64s is sorted and its elements are unique.
func GetMonthDay ¶ added in v1.6.1
GetMonthDay 获得当前月的初始和结束日期
func GetQuarterByDate ¶ added in v1.7.6
GetQuarterByDate 通过给定的日期 获得日期所在财报的季度、初始以及结束日期
diffQuarters 季度偏移数, 大于0前移diffQuarters个季度, 小于0后移diffQuarters个季度, 默认为当前季度
func GetQuarterDay ¶ added in v1.6.1
GetQuarterDay 获得当前季度的初始和结束日期
func GetQuarterDayByDate ¶ added in v1.7.4
GetQuarterDayByDate 通过给定的日期 获得日期所在上一个季度的初始和结束日期
diffQuarters 季度偏移数, 大于0前移diffQuarters个季度, 小于0后移diffQuarters个季度, 默认为当前季度
func GetWeekDay ¶ added in v1.6.1
GetWeekDay 获得当前周的初始和结束日期
func IntsAreUnique ¶
IntsAreUnique tests whether a slice of ints is sorted and its elements are unique.
func LowerCamelCase ¶
LowerCamelCase converts a string into camel case starting with a lower case letter.
func ParseFloat ¶
func SliceUnique ¶ added in v1.6.5
func SlicesToCsv ¶ added in v1.6.7
SlicesToCsv struct切片转csv文件
func Strings ¶
func Strings(a *[]string)
Strings removes duplicate elements from a sorted slice of strings.
func StringsAreUnique ¶
StringsAreUnique tests whether a slice of strings is sorted and its elements are unique.
func ToFront ¶
ToFront reports the number of unique elements of data which it moves to the first n positions. It assumes sort.IsSorted(data).
func Unique ¶
func Unique(data Interface)
Unique removes duplicate elements from data. It assumes sort.IsSorted(data).
func UpperCamelCase ¶
UpperCamelCase converts a string into camel case starting with a upper case letter.
func UpperKebabCase ¶
UpperKebabCase converts a string into kebab case with capital letters.
func UpperSnakeCase ¶
UpperSnakeCase converts a string into snake case with capital letters.
Types ¶
type Float64Slice ¶
type Float64Slice struct{ P *[]float64 }
Float64Slice attaches the methods of Interface to []float64.
func (Float64Slice) Len ¶
func (p Float64Slice) Len() int
func (Float64Slice) Less ¶
func (p Float64Slice) Less(i, j int) bool
func (Float64Slice) Swap ¶
func (p Float64Slice) Swap(i, j int)
func (Float64Slice) Truncate ¶
func (p Float64Slice) Truncate(n int)
type IntSlice ¶
type IntSlice struct{ P *[]int }
IntSlice attaches the methods of Interface to []int.
type Interface ¶
type Interface interface { sort.Interface // Truncate reduces the length to the first n elements. Truncate(n int) }
Interface Types that implement unique.Interface can have duplicate elements removed by the functionality in this package.
type Option ¶
type Option struct { // setting this value to true will ignore copying zero values of all the fields, including bools, as well as a // struct having all it's fields set to their zero values respectively (see IsZero() in reflect/value.go) IgnoreEmpty bool DeepCopy bool }
Option sets copy options
type ScopeLimit ¶ added in v1.7.0
ScopeLimit is used to specify a range. Both Start and End are inclusive. A nil value means no limit, so a Start of nil means 0 and an End of nil means no limit. The End value must always be equal to or larger than Start. Negative values are acceptable. A value of -2 means the second last row.
func IntsToRanges ¶ added in v1.7.0
func IntsToRanges(ints []int) []ScopeLimit
IntsToRanges will convert an already (ascending) ordered list of ints to a slice of Ranges.
Example:
import "sort" ints := []int{2,4,5,6,8,10,11,45,46} sort.Ints(ints) fmt.Println(IntsToRanges(ints)) // Output: R{2,2}, R{4,6}, R{8,8}, R{10,11}, R{45,46}
func RangeFinite ¶ added in v1.7.0
func RangeFinite(start int, end ...int) ScopeLimit
RangeFinite returns a ScopeLimit that has a finite span.
func (*ScopeLimit) Limits ¶ added in v1.7.0
func (r *ScopeLimit) Limits(length int) (s int, e int, _ error)
Limits is used to return the start and end limits of a ScopeLimit object for a given Dataframe or Series with length number of rows.
func (*ScopeLimit) NRows ¶ added in v1.7.0
func (r *ScopeLimit) NRows(length ...int) (int, error)
NRows returns the number of rows contained by ScopeLimit. If End is nil, then length must be provided.
func (ScopeLimit) String ¶ added in v1.7.0
func (r ScopeLimit) String() string
String implements Stringer interface.
type StringSlice ¶
type StringSlice struct{ P *[]string }
StringSlice attaches the methods of Interface to []string.
func (StringSlice) Len ¶
func (p StringSlice) Len() int
func (StringSlice) Less ¶
func (p StringSlice) Less(i, j int) bool
func (StringSlice) Swap ¶
func (p StringSlice) Swap(i, j int)
func (StringSlice) Truncate ¶
func (p StringSlice) Truncate(n int)