basics

package
v0.0.0-...-517d9f4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 18, 2022 License: MIT Imports: 19 Imported by: 0

Documentation

Overview

Package basics Time : 2022/7/26 11:11 Author : xushiyin contact : yuqingxushiyin@gmail.com

Package basics Time : 2021/5/7 10:22 上午 Author : xushiyin contact : yuqingxushiyin@gmail.com

Package basics Time : 2022/8/4 10:10 Author : xushiyin contact : yuqingxushiyin@gmail.com

Package basics Time : 2022/7/26 10:15 Author : xushiyin contact : yuqingxushiyin@gmail.com description : Go语言官方库:os、io/iouti(弃用)、bufio涵盖了文件操作的所有场景 os库中的方法对文件都是直接的IO操作,频繁的IO操作会增加CPU的中断频率,所以我们可以使用内存缓存区来减少IO操作, 在写字节到硬盘前使用内存缓存,当内存缓存区的容量到达一定数值时在写内存数据buffer到硬盘

Package basics Time : 2022/8/6 16:50 Author : xushiyin contact : yuqingxushiyin@gmail.com

Package basics Time : 2021/5/7 8:48 下午 Author : xushiyin contact : yuqingxushiyin@gmail.com

Package basics Time : 2021/5/7 9:26 上午 Author : xushiyin contact : yuqingxushiyin@gmail.com

Package basics Time : 2021/5/7 8:57 下午 Author : xushiyin contact : yuqingxushiyin@gmail.com

Package basics Time : 2022/8/7 17:18 Author : xushiyin contact : yuqingxushiyin@gmail.com

Package basics Time : 2022/7/26 17:13 Author : xushiyin contact : yuqingxushiyin@gmail.com

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateFile

func CreateFile(fileName string) (*os.File, error)

func CreateTables

func CreateTables(db *sqlx.DB, schemes string) error

func DeleteCustomer

func DeleteCustomer(customer Customer) error

DeleteCustomer method with parameter customer

func DialWithTimeout

func DialWithTimeout(network, address string, timeout time.Duration) (net.Conn, error)

func EntrancePipeline

func EntrancePipeline()

func Fibonacci

func Fibonacci(ch chan int, done chan struct{})

func FileChMod

func FileChMod(fileName string, mode os.FileMode) error

func FileChown

func FileChown(fileName string, uid, gid int) error

func GetConnection

func GetConnection() (database *sql.DB, err error)

GetConnection method which returns sql.DB

func GetFileInfo

func GetFileInfo(fileName string) (os.FileInfo, error)

func GetIntTwoSlice

func GetIntTwoSlice(rows int, cols int) [][]int

func GetSqliteConn

func GetSqliteConn(dbFile string) (db *sqlx.DB, err error)

func InsertCustomer

func InsertCustomer(customer Customer) (sql.Result, error)

func InsertPerson

func InsertPerson(db *sqlx.DB, persons []*Person) error

func InsertPlace

func InsertPlace(db *sqlx.DB, places []*Place) error

func ReadBytes

func ReadBytes(fileName string, size int) ([]byte, error)

func ReadFileAll

func ReadFileAll(fileName string) ([]byte, error)

func ReadLine

func ReadLine(fileName string) ([]byte, error)

func ReadScanWord

func ReadScanWord(fileName string, size int) ([]byte, error)

func RmFile

func RmFile(fileName string) error

func StrSliceJoin

func StrSliceJoin(list []string, sep string) string

func Tar

func Tar(src string, writers ...io.Writer) error

Tar takes a source and variable writers and walks 'source' writing each file found to the tar writer; the purpose for accepting multiple writers is to allow for multiple outputs (for example a file, or md5 hash)

func UnZipFiles

func UnZipFiles(zipName string) error

func Untar

func Untar(dst string, r io.Reader) error

Untar takes a destination path and a reader; a tar reader loops over the tarfile creating the file structure at 'dst' along the way, and writing any files

func UpdateCustomer

func UpdateCustomer(customer Customer) error

UpdateCustomer method with parameter customer

func WriteAll

func WriteAll(fileName string, content []byte) error

func WriteAt

func WriteAt(fileName string, content []byte, offset int64) error

func WriteBuffer

func WriteBuffer(fileName string, content []byte) error

func WriteLine

func WriteLine(fileName string, content []byte) error

func WriteLine2

func WriteLine2(fileName string, content []byte) error

func ZipFiles

func ZipFiles(zipName string, zFiles []FileBody) error

Types

type Customer

type Customer struct {
	CustomerId   int
	CustomerName string
	SSN          string
}

Customer Class

func GetCustomers

func GetCustomers() ([]Customer, error)

GetCustomers method returns Customer Array

type FileBody

type FileBody struct {
	Name string
	Data []byte
}

type Person

type Person struct {
	FirstName string `db:"first_name"`
	LastName  string `db:"last_name"`
	Email     string
}

func GetPerson

func GetPerson(db *sqlx.DB, firstName string) (*Person, error)

func NamedQueryPerson

func NamedQueryPerson(db *sqlx.DB) ([]*Person, error)

func QueryPerson

func QueryPerson(db *sqlx.DB) ([]*Person, error)

type Place

type Place struct {
	Country string
	City    sql.NullString
	TelCode int
}

func QueryXPlace

func QueryXPlace(db *sqlx.DB) ([]*Place, error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL