Documentation ¶
Index ¶
- Constants
- Variables
- func Big5ToUtf8(big5 []byte) (utf8 string)
- func BinRead(file io.ReadSeeker, v interface{}, theSize uintptr) error
- func BinWrite(file io.Writer, v interface{}, theSize uintptr) error
- func BinaryRead(reader io.ReadSeeker, order binary.ByteOrder, data interface{}) (err error)
- func BinaryWrite(writer io.Writer, order binary.ByteOrder, data interface{}) (err error)
- func CcharTolower(ch byte) byte
- func CcharToupper(ch byte) byte
- func CopyDirToDir(src string, dst string) (err error)
- func CopyFile(src string, dst string) (err error)
- func CopyFileToDir(src string, dst string) (err error)
- func CopyFileToFile(src string, dst string) (err error)
- func CstrCaseHasPrefix(cstr Cstr, substr Cstr) bool
- func CstrToBytes(cstr Cstr) []byte
- func CstrToString(cstr Cstr) string
- func Cstrcasecmp(cstr1 Cstr, cstr2 Cstr) int
- func Cstrcasestr(cstr Cstr, substr Cstr) int
- func Cstrcmp(cstr1 Cstr, cstr2 Cstr) int
- func Cstrlen(cstr Cstr) int
- func Cstrstr(cstr Cstr, substr Cstr) int
- func DashD(filename string) (isDir bool)
- func DashF(filename string) (isExists bool, err error)
- func DashS(filename string) (theSize int64)
- func ErrRecover(err interface{}) error
- func GetCurrentMilliTS() int64
- func GetRandom() string
- func InitConfig() error
- func IsDir(path string) bool
- func IsRegularFile(filename string) bool
- func Isalnum(c byte) bool
- func Isalpha(c byte) bool
- func Isascii(c byte) bool
- func Isnumber(c byte) bool
- func Kill(pid Pid_t, sig os.Signal) (err error)
- func Mkdir(path string) error
- func MkdirAll(path string) error
- func OpenCreate(filename string, flags int) (file *os.File, err error)
- func ReadFile(filename string) ([]byte, error)
- func ReadLine(reader *bufio.Reader) ([]byte, error)
- func Rename(src string, dst string) (err error)
- func SetIsTest(name string)
- func Symlink(src string, dst string) (err error)
- func TrimDBCS(theCstr Cstr) (theBytes []byte)
- func Unlink(filename string) (err error)
- func UnsetIsTest(name string)
- func Utf8ToBig5(utf8 string) (big5 []byte)
- type Cstr
- type DBCU
- type InAddr_t
- type Key_t
- type Pid_t
- type Size_t
- type Time4
- func (t Time4) Cdate() string
- func (t Time4) CdateMd() string
- func (t Time4) CdateMdHM() string
- func (t Time4) CdateMdHMS() string
- func (t Time4) Cdatedate() string
- func (t Time4) Cdatelite() string
- func (t Time4) Cdatemd() (str string)
- func (t Time4) Ctime() string
- func (t Time4) ToLocal() time.Time
- func (t Time4) ToUtc() time.Time
Constants ¶
const ( TS_TO_NANO_TS = 1000000000 // second to nano-second SYS_BUFFER_SIZE = 8192 DEFAULT_FOLDER_CREATE_PERM = 0o755 DEFAULT_FILE_CREATE_PERM = 0o644 )
const INT32_SZ = unsafe.Sizeof(int32(0))
const PID_SZ = unsafe.Sizeof(Pid_t(0))
const TIME4_SZ = unsafe.Sizeof(Time4(0))
XXX check whether INT32_SZ should be TIME4_SZ
const UINT32_SZ = unsafe.Sizeof(uint32(0))
const UINT8_SZ = unsafe.Sizeof(uint8(0))
Variables ¶
var ( TIME_LOCATION = "Asia/Taipei" IS_ALLOW_CROSSDOMAIN = true DEFAULT_PID_MAX = Pid_t(10000000) // big5 BIG5_TO_UTF8 = "types/uao250-b2u.big5.txt" UTF8_TO_BIG5 = "types/uao250-u2b.big5.txt" AMBCJK = "types/ambcjk.big5.txt" )
var ( ErrInvalidIni = errors.New("invalid ini") ErrBytesTooLarge = errors.New("bytes too large") ErrNilReader = errors.New("nil reader") ErrNotImplemented = errors.New("not implemented") ErrInvalidTimeLocale = errors.New("invalid time locale") ErrInvalidFile = errors.New("invalid file") ErrInvalidSize = errors.New("invalid size") )
var ( ZERO_TIME = time.Unix(int64(0), 0) ZERO_LOCAL_TIME = ZERO_TIME.In(TIMEZONE) ZERO_TIME4 = Time4(0) )
var ( VERSION string GIT_VERSION string )
var MILLI_TS_TO_NANO_TS int64 = 1000000
var TIMEZONE, _ = time.LoadLocation(TIME_LOCATION)
Functions ¶
func Big5ToUtf8 ¶
func BinRead ¶
func BinRead(file io.ReadSeeker, v interface{}, theSize uintptr) error
BinRead
Read the file with identified size, the first bytes are fit in v. Assuming that the size of v is <= theSize. XXX not sure what to do if v > theSize.
func BinWrite ¶
BinWrite
Write the file with identified size, the first bytes are with v. Assuming that the size of v is <= theSize. XXX not sure what to do if v > theSize.
func BinaryRead ¶ added in v0.15.1
func BinaryRead(reader io.ReadSeeker, order binary.ByteOrder, data interface{}) (err error)
func BinaryWrite ¶ added in v0.15.1
func CcharTolower ¶
func CcharToupper ¶ added in v0.2.3
func CopyDirToDir ¶
func CopyFileToDir ¶
func CopyFileToFile ¶
func CstrCaseHasPrefix ¶ added in v0.10.0
func CstrToBytes ¶
CstrToBytes
Only the bytes until \0. See tests for more examples.
Params
cstr
Return
[]byte: bytes
func CstrToString ¶
CstrToString
Only the bytes until \0 when converting to string. See tests for more examples.
Params
cstr
Return
string: string
func Cstrcasecmp ¶
func Cstrcasestr ¶
func Cstrcmp ¶
Cstrcmp The reason that we don't directly do C.strcmp is because cstr1 or cstr2 may not have \x00 in the end.
func ErrRecover ¶ added in v0.15.1
func ErrRecover(err interface{}) error
func GetCurrentMilliTS ¶
func GetCurrentMilliTS() int64
func InitConfig ¶
func InitConfig() error
func IsRegularFile ¶
func OpenCreate ¶ added in v0.12.0
func ReadLine ¶ added in v0.2.3
ReadLine
To avoid confusion, use only []byte is nil or not to know whether it's the end of file.
func UnsetIsTest ¶ added in v0.12.0
func UnsetIsTest(name string)
func Utf8ToBig5 ¶
Types ¶
type Cstr ¶
type Cstr []byte
Cstr
[]byte with C String property in that \0 is considered as the end of the bytes/string. It is used to convert from fixed-length bytes to string or []byte with no \0.
Naming Cstr instead of CString is to avoid confusion with C.CString (C.CString is from string, and should be compatible with string, not with []byte) (We also have str(len/cpy/cmp) functions in C)
See tests for more examples of how to use fixed-bytes with Cstr to get no-\0 string / []byte
func CstrTokenR ¶ added in v0.8.3
func CstrTolower ¶
func CstrToupper ¶ added in v0.2.3
type Time4 ¶
type Time4 int32
func TimeToTime4 ¶ added in v0.8.1
func (Time4) CdateMdHM ¶
CdateMdHM
Print month/day hour:minute in string 11+1 bytes, "01/31 10:01\0"
func (Time4) CdateMdHMS ¶
CdateMdHMS
Print month/day hour:minute:second in string 13+1 bytes, "01/31 10:01:01\0"
func (Time4) Cdatelite ¶
Cdatelite
Light-print date-time in string. 19+1 bytes, "01/31/2007 00:00:00\0"