must

package module
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Jul 5, 2021 License: MIT Imports: 6 Imported by: 32

README

must GoDoc

Package must provides fatal wrappers for common Go stdlib functions.

Installation

go get github.com/powerman/must

Documentation

Overview

Package must provides fatal wrappers for common stdlib functions.

Index

Constants

This section is empty.

Variables

View Source
var AbortIf = FatalIf

AbortIf should point to FatalIf or PanicIf or similar user-provided function which will interrupt execution in case it's param is not nil.

Functions

func Atoi

func Atoi(buf []byte) int

Atoi is a wrapper for strconv.Atoi.

func Close

func Close(f io.Closer)

Close is a wrapper for os.File.Close, …

func Create

func Create(name string) *os.File

Create is a wrapper for os.Create.

func Decode

func Decode(e Decoder, v interface{})

Decode is a wrapper for json.Decoder.Decode, gob.Decoder.Decode, xml.Decoder.Decode, …

func Encode

func Encode(e Encoder, v interface{})

Encode is a wrapper for json.Encoder.Encode, gob.Encoder.Encode, xml.Encoder.Encode, …

func FatalIf

func FatalIf(err error)

FatalIf will call log.Fatal(err) in case given err is not nil.

func MarshalJSON

func MarshalJSON(v interface{}) []byte

MarshalJSON is a wrapper for json.Marshal.

func NoErr

func NoErr(err error)

NoErr is just a synonym for AbortIf.

func Open

func Open(name string) *os.File

Open is a wrapper for os.Open.

func OpenFile

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

OpenFile is a wrapper for os.OpenFile.

func PanicIf

func PanicIf(err error)

PanicIf will call panic(err) in case given err is not nil.

func Read

func Read(r io.Reader, buf []byte) (n int)

Read is a wrapper for os.File.Read, bufio.Reader.Read, net.Conn.Read, rand.Read, …

func ReadAll

func ReadAll(f io.Reader) []byte

ReadAll is a wrapper for ioutil.ReadAll.

func ReadDir

func ReadDir(dirname string) []os.FileInfo

ReadDir is a wrapper for ioutil.ReadDir.

func ReadFile

func ReadFile(name string) []byte

ReadFile is a wrapper for ioutil.ReadFile.

func ReadFull

func ReadFull(f io.Reader, buf []byte) int

ReadFull is a wrapper for io.ReadFull.

func Remove

func Remove(name string)

Remove is a wrapper for os.Remove.

func Rename

func Rename(oldpath, newpath string)

Rename is a wrapper for os.Rename.

func Seek

func Seek(f io.Seeker, offset int64, whence int) int64

Seek is a wrapper for os.File.Seek, bytes.Buffer.Seek, …

func Stat

func Stat(f *os.File) os.FileInfo

Stat is a wrapper for os.File.Stat.

func StatPath

func StatPath(name string) os.FileInfo

StatPath is a wrapper for os.Stat.

func Sync

func Sync(f *os.File)

Sync is a wrapper for os.File.Sync.

func TempDir

func TempDir(dir, prefix string) string

TempDir is a wrapper for ioutil.TempDir.

func TempFile

func TempFile(dir, prefix string) *os.File

TempFile is a wrapper for ioutil.TempFile.

func Truncate

func Truncate(f *os.File, size int64)

Truncate is a wrapper for os.File.Truncate.

func TruncatePath

func TruncatePath(name string, size int64)

TruncatePath is a wrapper for os.Truncate.

func UnmarshalJSON

func UnmarshalJSON(data []byte, v interface{})

UnmarshalJSON is a wrapper for json.Unmarshal.

func Write

func Write(f io.Writer, b []byte) int

Write is a wrapper for os.File.Write, bufio.Writer.Write, net.Conn.Write, …

func WriteAt

func WriteAt(f io.WriterAt, b []byte, off int64) int

WriteAt is a wrapper for os.File.WriteAt.

func WriteFile

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

WriteFile is a wrapper for ioutil.WriteFile.

Types

type Decoder

type Decoder interface {
	Decode(v interface{}) error
}

Decoder is an interface compatible with json.Decoder, gob.Decoder, xml.Decoder, …

type Encoder

type Encoder interface {
	Encode(v interface{}) error
}

Encoder is an interface compatible with json.Encoder, gob.Encoder, xml.Encoder, …

Jump to

Keyboard shortcuts

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