Documentation
¶
Overview ¶
Package msg provides common message functions.
Index ¶
- func FatalInfoOnErr(err error, info string)
- func FatalInfoOnFalse(flag bool, info string)
- func FatalInfoOnTrue(flag bool, info string)
- func FatalOnErr(err error)
- func FatalOnFalse(flag bool)
- func FatalOnTrue(flag bool)
- func Info(info string)
- func InfoOnErr(err error, info string)
- func InfoOnFalse(flag bool, info string)
- func InfoOnTrue(flag bool, info string)
- func OnErr(err error)
- func OnFalse(flag bool)
- func OnTrue(flag bool)
- func PanicInfoOnErr(err error, info string)
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FatalInfoOnErr ¶
FatalInfoOnErr ends in osExit(1) if err 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")
func FatalInfoOnFalse ¶ added in v0.26.0
FatalInfoOnFalse prints info and a common error message with location info when err is not nil.
Example ¶
package main
import (
"log"
"github.com/rokath/trice/pkg/msg"
)
func main() {
log.SetFlags(0)
var f bool
msg.FatalInfoOnFalse(f, "just in case")
//msg.FatalInfoOnFalse(!f, "just in case")
func FatalInfoOnTrue ¶ added in v0.26.0
FatalInfoOnTrue prints info and a common error message with location info when err is not nil.
Example ¶
package main
import (
"log"
"github.com/rokath/trice/pkg/msg"
)
func main() {
log.SetFlags(0)
var f bool
msg.FatalInfoOnTrue(f, "just in case")
//msg.FatalInfoOnTrue(!f, "just in case")
func FatalOnErr ¶
func FatalOnErr(err error)
FatalOnErr ends in osExit(1) if err not nil.
Example ¶
package main
import (
"errors"
"log"
"github.com/rokath/trice/pkg/msg"
)
func main() {
log.SetFlags(0)
var e error
msg.FatalOnErr(e)
e = errors.New("s.th. went wrong")
// msg.FatalOnErr(e)
func FatalOnFalse ¶
func FatalOnFalse(flag bool)
FatalOnFalse ends in osExit(1) if flag is false.
Example ¶
package main
import (
"log"
"github.com/rokath/trice/pkg/msg"
)
func main() {
log.SetFlags(0)
var f bool
msg.FatalOnFalse(f)
//msg.FatalOnFalse(!f)
func FatalOnTrue ¶
func FatalOnTrue(flag bool)
FatalOnTrue ends in osExit(1) if flag is true.
Example ¶
package main
import (
"log"
"github.com/rokath/trice/pkg/msg"
)
func main() {
log.SetFlags(0)
var f bool
msg.FatalOnTrue(f)
//msg.FatalOnTrue(!f)
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_test.go:14: func 'github.com/rokath/trice/pkg/msg_test.ExampleInfo' -> code issue
func InfoOnErr ¶
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_test.go:52: func 'github.com/rokath/trice/pkg/msg_test.ExampleInfoOnErr' -> s.th. went wrong
func InfoOnFalse ¶
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() {
var f bool
msg.InfoOnFalse(f, "just in case")
msg.InfoOnFalse(!f, "just in case")
}
Output: Error in msg_test.go:121: func 'github.com/rokath/trice/pkg/msg_test.ExampleInfoOnFalse' -> just in case
func InfoOnTrue ¶
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() {
var f bool
msg.InfoOnTrue(f, "just in case")
msg.InfoOnTrue(!f, "just in case")
}
Output: Error in msg_test.go:88: 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_test.go:23: func 'github.com/rokath/trice/pkg/msg_test.ExampleOnErr' -> s.th. went wrong
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() {
var f bool
msg.OnFalse(f)
msg.OnFalse(!f)
}
Output: Error in msg_test.go:104: 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() {
var f bool
msg.OnTrue(f)
msg.OnTrue(!f)
}
Output: Error in msg_test.go:71: func 'github.com/rokath/trice/pkg/msg_test.ExampleOnTrue' -> <nil>
func PanicInfoOnErr ¶ added in v0.27.2
PanicInfoOnErr ends in panic if err not nil.
Example ¶
package main
import (
"errors"
"log"
"github.com/rokath/trice/pkg/msg"
)
func main() {
log.SetFlags(0)
var e error
msg.PanicInfoOnErr(e, "just in case")
e = errors.New("s.th. went wrong")
// msg.PanicInfoOnErr(e, "just in case")
Types ¶
This section is empty.