-
Notifications
You must be signed in to change notification settings - Fork 3
/
example_constants_test.go
47 lines (39 loc) · 1.47 KB
/
example_constants_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
// Copyright 2020 Adam Chalkley
//
// https://github.com/atc0005/go-nagios
//
// Licensed under the MIT License. See LICENSE file in the project root for
// full license information.
package nagios_test
import (
"fmt"
"os"
"github.com/atc0005/go-nagios"
)
// Ignore this. This is just to satisfy the "whole file" example requirements
// per https://go.dev/blog/examples.
var _ = "https://github.com/atc0005/go-nagios"
// Example_usingOnlyTheProvidedExitCodeConstants is a simple example that
// illustrates using only the provided exit code constants from this package.
// After you've imported this library, reference the exported data types as
// you would from any other package.
func Example_usingOnlyTheProvidedExitCodeConstants() {
// In this example, we reference a specific exit code for the OK state:
fmt.Println("OK: All checks have passed")
os.Exit(nagios.StateOKExitCode)
}
// Example_usingOnlyTheProvidedConstants is a simple example that illustrates
// using only the provided constants from this package. After you've imported
// this library, reference the exported data types as you would from any other
// package.
func Example_usingOnlyTheProvidedConstants() {
// In this example, we reference a specific exit code for the OK state and
// also use the provided state "labels" to avoid using literal string
// state values (recommended):
fmt.Printf(
"%s: All checks have passed%s",
nagios.StateOKLabel,
nagios.CheckOutputEOL,
)
os.Exit(nagios.StateOKExitCode)
}