util

package
v0.0.0-...-d5751c4 Latest Latest
Warning

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

Go to latest
Published: Mar 7, 2024 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Close

func Close(fd *os.File) error

Close fd

func CopyReader

func CopyReader(dst io.Writer, src io.Reader) (int64, error)

func Create

func Create(name string) (*os.File, error)

Create one file

func EnsureDir

func EnsureDir(fp string) error

EnsureDir mkdir dir if not exist

func EnsureDirRW

func EnsureDirRW(dataDir string) error

EnsureDirRW ensure the datadir and make sure it's rw-able

func NewUUID

func NewUUID() uuid.UUID

func OpenFile

func OpenFile(name string, flag int, perm os.FileMode) (*os.File, error)

func ReadDir

func ReadDir(dir string) ([]string, error)

func Remove

func Remove(name string) error

Remove one file

func TemporaryDir

func TemporaryDir(dir string) (string, error)

func TimeTrack

func TimeTrack(start time.Time) string

func Workers

func Workers(workers, jobs int) int

func WriteFile

func WriteFile(name string, data []byte, perm os.FileMode) error

Types

type Response

type Response struct {
	Code   int    `json:"-"`
	Pretty bool   `json:"-"`
	Data   any    `json:"data,omitempty"`
	Err    string `json:"error,omitempty"`
}

Response in order to unify the returned response structure

func (Response) Error

func (a Response) Error() string

func (Response) JSON

func (a Response) JSON(w http.ResponseWriter)

Jump to

Keyboard shortcuts

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