msg

package
v0.72.5 Latest Latest
Warning

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

Go to latest
Published: Dec 18, 2024 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package msg provides common message functions.

Index

Examples

Constants

This section is empty.

Variables

View Source
var Verbose bool

Functions

func FatalInfoOnErr

func FatalInfoOnErr(err error, info string)

FatalInfoOnErr ends in osExit(1) if err not nil.

Example
package main

import (
	"github.com/rokath/trice/pkg/msg"
)

func main() {
	var e error
	msg.FatalInfoOnErr(e, "just in case")
}
Output:

func FatalInfoOnFalse added in v0.26.0

func FatalInfoOnFalse(flag bool, info string)

FatalInfoOnFalse prints info and a common error message with location info when err is not nil.

Example
package main

import (
	"github.com/rokath/trice/pkg/msg"
)

func main() {
	msg.FatalInfoOnFalse(true, "just in case")
}
Output:

func FatalInfoOnTrue added in v0.26.0

func FatalInfoOnTrue(flag bool, info string)

FatalInfoOnTrue prints info and a common error message with location info when err is not nil.

Example
package main

import (
	"github.com/rokath/trice/pkg/msg"
)

func main() {
	msg.FatalInfoOnTrue(false, "just in case")
}
Output:

func FatalOnErr

func FatalOnErr(err error)

FatalOnErr ends in osExit(1) if err not nil.

Example
package main

import (
	"log"

	"github.com/rokath/trice/pkg/msg"
)

func main() {
	log.SetFlags(0)
	var e error
	msg.FatalOnErr(e)
}
Output:

func FatalOnFalse

func FatalOnFalse(flag bool)

FatalOnFalse ends in osExit(1) if flag is false.

Example
package main

import (
	"github.com/rokath/trice/pkg/msg"
)

func main() {
	msg.FatalOnFalse(true)
}
Output:

func FatalOnTrue

func FatalOnTrue(flag bool)

FatalOnTrue ends in osExit(1) if flag is true.

Example
package main

import (
	"github.com/rokath/trice/pkg/msg"
)

func main() {
	msg.FatalOnTrue(false)
}
Output:

func Info

func Info(info string)

Info prints info with location info.

Example
package main

import (
	"github.com/rokath/trice/pkg/msg"
)

func main() {
	msg.Info("code issue")
}
Output:

Error in msg_blackbox_test.go:14: func 'github.com/rokath/trice/pkg/msg_test.ExampleInfo' -> code issue

func InfoOnErr

func InfoOnErr(err error, info string)

InfoOnErr prints info and a common error message with location info when err is not nil.

Example
package main

import (
	"errors"

	"github.com/rokath/trice/pkg/msg"
)

func main() {
	var e error
	msg.InfoOnErr(e, "just in case")
	e = errors.New("s.th. went wrong")
	msg.InfoOnErr(e, "just in case")
}
Output:

just in case
Error in msg_blackbox_test.go:39: func 'github.com/rokath/trice/pkg/msg_test.ExampleInfoOnErr' -> s.th. went wrong

func InfoOnFalse

func InfoOnFalse(flag bool, info string)

InfoOnFalse prints info and a common error message with location info when flag is false.

Example
package main

import (
	"github.com/rokath/trice/pkg/msg"
)

func main() {
	msg.InfoOnFalse(true, "just in case")
	msg.InfoOnFalse(false, "just in case")
}
Output:

Error in msg_blackbox_test.go:89: func 'github.com/rokath/trice/pkg/msg_test.ExampleInfoOnFalse' -> just in case

func InfoOnTrue

func InfoOnTrue(flag bool, info string)

InfoOnTrue prints info and a common error message with location info when flag is true.

Example
package main

import (
	"github.com/rokath/trice/pkg/msg"
)

func main() {
	msg.InfoOnTrue(false, "just in case")
	msg.InfoOnTrue(true, "just in case")
}
Output:

Error in msg_blackbox_test.go:65: func 'github.com/rokath/trice/pkg/msg_test.ExampleInfoOnTrue' -> just in case

func OnErr

func OnErr(err error)

OnErr prints info and a common error message with location info when err is not nil.

Example
package main

import (
	"errors"

	"github.com/rokath/trice/pkg/msg"
)

func main() {
	var e error
	msg.OnErr(e)
	e = errors.New("s.th. went wrong")
	msg.OnErr(e)
}
Output:

Error in msg_blackbox_test.go:23: func 'github.com/rokath/trice/pkg/msg_test.ExampleOnErr' -> s.th. went wrong

func OnErrF added in v0.44.0

func OnErrF(w io.Writer, err error)

OnErrF prints info and a common error message with location info when err is not nil.

func OnErrFv added in v0.70.0

func OnErrFv(w io.Writer, err error) error

OnErrFv prints info and a common error message with location info when err is not nil.

func OnFalse

func OnFalse(flag bool)

OnFalse prints info and a common error message with location info when flag is false.

Example
package main

import (
	"github.com/rokath/trice/pkg/msg"
)

func main() {
	msg.OnFalse(true)
	msg.OnFalse(false)
}
Output:

Error in msg_blackbox_test.go:77: func 'github.com/rokath/trice/pkg/msg_test.ExampleOnFalse' -> <nil>

func OnTrue

func OnTrue(flag bool)

OnTrue prints info and a common error message with location info when flag is true.

Example
package main

import (
	"github.com/rokath/trice/pkg/msg"
)

func main() {
	msg.OnTrue(false)
	msg.OnTrue(true)
}
Output:

Error in msg_blackbox_test.go:53: func 'github.com/rokath/trice/pkg/msg_test.ExampleOnTrue' -> <nil>

func OsExitAllow added in v0.29.2

func OsExitAllow(o OrigLogFatalf)

OsExitAllow place the original fatal function back

func Tell added in v0.70.0

func Tell(w io.Writer, info string)

Types

type OrigLogFatalf added in v0.49.0

type OrigLogFatalf func(format string, v ...interface{})

func OsExitDisallow added in v0.29.2

func OsExitDisallow() (o OrigLogFatalf)

OsExitDisallow replace the original fatal function

Jump to

Keyboard shortcuts

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