must

package
v3.22.0-alpha Latest Latest
Warning

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

Go to latest
Published: May 14, 2024 License: GPL-3.0 Imports: 12 Imported by: 0

Documentation

Overview

Package must contains functions that panic on error.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CopyFile

func CopyFile(source, dest string, perms fs.FileMode)

CopyFile is like shellx.CopyFile but calls runtimex.PanicOnError on failure.

func FirstLineBytes

func FirstLineBytes(data []byte) []byte

FirstLineBytes takes in input a sequence of bytes and returns in output the first line. This function will call runtimex.PanicOnError on failure.

func Fprintf

func Fprintf(w io.Writer, format string, v ...any)

Fprintf is like fmt.Fprintf but calls runtimex.PanicOnError on failure.

func Listen

func Listen(network string, address string) net.Listener

Listen is like net.Listen but calls runtimex.PanicOnError on failure.

func MarshalAndIndentJSON

func MarshalAndIndentJSON(v any, prefix string, indent string) []byte

MarshalAndIndentJSON is like json.MarshalIndent but calls runtimex.PanicOnError on failure.

func MarshalJSON

func MarshalJSON(v any) []byte

MarshalJSON is like json.Marshal but calls runtimex.PanicOnError on failure.

func NewHTTPRequest

func NewHTTPRequest(method string, url string, body io.Reader) *http.Request

NewHTTPRequest is like http.NewRequest but calls runtimex.PanicOnError on failure.

func ParseURL

func ParseURL(URL string) *url.URL

ParseURL is like url.Parse but calls runtimex.PanicOnError on failure.

func ReadFile

func ReadFile(filename string) []byte

ReadFile is like os.ReadFile but calls runtimex.PanicOnError on failure.

func Run

func Run(logger logmodel.Logger, command string, args ...string)

Run is like shellx.Run but calls runtimex.PanicOnError on failure.

func RunCommandLine

func RunCommandLine(logger logmodel.Logger, cmdline string)

RunCommandLine is like shellx.RunCommandLine but calls runtimex.PanicOnError on failure.

func RunCommandLineQuiet

func RunCommandLineQuiet(cmdline string)

RunCommandLineQuiet is like shellx.RunCommandLineQuiet but calls runtimex.PanicOnError on failure.

func RunOutput

func RunOutput(logger logmodel.Logger, command string, args ...string) []byte

RunOutput is like shellx.Output but calls runtimex.PanicOnError on failure.

func RunOutputQuiet

func RunOutputQuiet(command string, args ...string) []byte

RunOutputQuiet is like shellx.OutputQuiet but calls runtimex.PanicOnError on failure.

func RunQuiet

func RunQuiet(command string, args ...string)

RunQuiet is like shellx.RunQuiet but calls runtimex.PanicOnError on failure.

func SplitHostPort

func SplitHostPort(hostport string) (host string, port string)

SplitHostPort is like net.SplitHostPort but calls runtimex.PanicOnError on failure.

func UnmarshalJSON

func UnmarshalJSON(data []byte, v any)

UnmarshalJSON is like json.Marshal but calls runtimex.PanicOnError on failure.

func WriteFile

func WriteFile(filename string, content []byte, mode fs.FileMode)

WriteFile is like os.WriteFile but calls runtimex.PanicOnError on failure.

Types

type File

type File struct {
	*os.File
}

File wraps os.File.

func CreateFile

func CreateFile(name string) *File

CreateFile is like os.Create but calls runtimex.PanicOnError on failure.

func OpenFile

func OpenFile(name string) *File

OpenFile is like os.Open but calls runtimex.PanicOnError on failure.

func (*File) MustClose

func (fp *File) MustClose()

MustClose is like os.File.Close but calls runtimex.PanicOnError on failure.

Jump to

Keyboard shortcuts

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