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 any, fromValue any, opt Option) (err error)
- func CsvToSlices[S ~[]E, E any](filename string, pointer *S) error
- func DateZero(t time.Time) time.Time
- func Decimal(value float64, digits ...int) float64
- func DifferDays(t1, t2 time.Time) int
- func EndsWith(str string, suffixes []string) bool
- func Export(resources embed.FS, source, target string) error
- func FileExist(path string) bool
- func FileIsValid(path string) bool
- func Filter[S ~[]E, E any](slice S, condition func(E) bool) S
- func GetConcreteContainerInnerType(in reflect.Type) (inInnerWasPointer bool, inInnerType reflect.Type)
- func GetConcreteReflectValueAndType(in any) (reflect.Value, reflect.Type)
- 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 IsEmpty(s string) bool
- func IsErrorType(outType reflect.Type) bool
- func IsNaN(f float64) bool
- func IsWorkday(t time.Time) bool
- func KebabCase(s string) string
- func Keys[M ~map[K]V, K comparable, V any](m M) []K
- func LowerCamelCase(s string) string
- func NanosecondToTime(nanoseconds int64) time.Time
- func OpenEmbed(resources embed.FS, filename string) (fs.File, error)
- 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 SecondToTime(sec int64) time.Time
- 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 StartsWith(str string, prefixes []string) bool
- func String2Bytes(s string) []byte
- func ToCamelCase(kebab string) (camelCase string)
- func ToString(value interface{}) string
- func Touch(filename string) error
- func Unique[E canUnique](s []E) []E
- func UpperCamelCase(s string) string
- func UpperKebabCase(s string) string
- func UpperSnakeCase(s string) string
- func Values[M ~map[K]V, K comparable, V any](m M) []V
- type FileStat
- type Option
- type ScopeLimit
Constants ¶
const ( // DateFormat 日期格式 yyyy-MM-dd DateFormat = "2006-01-02" // DateFormat2 日期格式 yyyyMMdd DateFormat2 = "20060102" // DateFormat3 日期格式 yyMMdd DateFormat3 = "060102" // TimeFormat 时间格式 yyyy-MM-dd HH:mm:ss TimeFormat = "2006-01-02 15:04:05" // TimeFormat2 时间格式 yyyyMMddHHmmss TimeFormat2 = "20060102150405" // Timestamp 时间戳 - 毫秒 时间格式 yyyy-MM-dd HH:mm:ss.SSS Timestamp = "2006-01-02 15:04:05.000" // TimeOnly 时分秒 TimeOnly = time.TimeOnly // TimeAndMillisecond 时分秒毫 TimeAndMillisecond = "15:04:05.000" PathDate = "20060102" // 路径中的日期格式 TextDate = "2006-01-02" // 数据中的日期格式 )
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 ¶
var ( ErrInvalidCopyDestination = errors.New("copy destination is invalid") ErrInvalidCopyFrom = errors.New("copy from is invalid") ErrMapKeyNotMatch = errors.New("map's key type doesn't match") ErrNotSupported = errors.New("not supported") )
var ( ErrRangeInvalid = errors.New("range invalid") ErrLengthUndefined = errors.New("limit undefined") ErrLengthNotProvided = errors.New("end is nil so length must be provided") )
var (
ErrDateFormat = errors.New("日期格式无法确定")
)
var (
ErrInvalidFileStat = errors.New("invalid file stat")
)
var (
ErrNotConvert = errors.New("can not Convert")
)
Functions ¶
func CopyWithOption ¶
CopyWithOption copy with option
func CsvToSlices ¶ added in v1.6.7
CsvToSlices CSV文件转struct切片
func GetConcreteContainerInnerType ¶ added in v1.19.7
func GetConcreteReflectValueAndType ¶ added in v1.19.7
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 IsErrorType ¶ added in v1.19.7
func Keys ¶ added in v1.16.1
func Keys[M ~map[K]V, K comparable, V any](m M) []K
Keys returns the keys of the map m. The keys will be in an indeterminate order.
func LowerCamelCase ¶
LowerCamelCase converts a string into camel case starting with a lower case letter.
func NanosecondToTime ¶ added in v1.15.9
func ParseFloat ¶
func SecondToTime ¶ added in v1.16.1
SecondToTime 把秒级的时间戳转为time格式
func SliceUnique ¶ added in v1.6.5
func SlicesToCsv ¶ added in v1.6.7
SlicesToCsv struct切片转csv文件
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.
func Values ¶ added in v1.16.1
func Values[M ~map[K]V, K comparable, V any](m M) []V
Values returns the values of the map m. The values will be in an indeterminate order.
Types ¶
type FileStat ¶ added in v1.15.9
func GetFileStat ¶ added in v1.15.9
GetFileStat 获取文件状态(创建,修改和访问时间)
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) Limited ¶ added in v1.20.0
func (r *ScopeLimit) Limited(length int) (start, end int)
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.
Source Files ¶
- channel.go
- closer.go
- copier.go
- copier_errors.go
- datetime.go
- datetime_layout.go
- embed.go
- file.go
- filepath.go
- filestat.go
- filestat_linux.go
- filestat_nix.go
- maps.go
- number.go
- number_decimals.go
- reflect.go
- reflect_array.go
- slices.go
- slices_csv.go
- slices_limit.go
- slices_sort.go
- slices_unique.go
- string.go
- string_bytes_above_120.go
- string_camel.go
- string_helper.go
- string_kebab.go
- string_snake.go