File: example_test.go

package info (click to toggle)
golang-github-adrg-xdg 0.5.3-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 268 kB
  • sloc: makefile: 2
file content (97 lines) | stat: -rw-r--r-- 2,058 bytes parent folder | download | duplicates (2)
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
package xdg_test

import (
	"fmt"

	"github.com/adrg/xdg"
)

func ExampleDataFile() {
	dataFilePath, err := xdg.DataFile("appname/app.data")
	if err != nil {
		// Treat error.
	}

	fmt.Println("Save data file at:", dataFilePath)
}

func ExampleConfigFile() {
	configFilePath, err := xdg.ConfigFile("appname/app.yaml")
	if err != nil {
		// Treat error.
	}

	fmt.Println("Save config file at:", configFilePath)
}

func ExampleStateFile() {
	stateFilePath, err := xdg.DataFile("appname/app.state")
	if err != nil {
		// Treat error.
	}

	fmt.Println("Save state file at:", stateFilePath)
}

func ExampleCacheFile() {
	cacheFilePath, err := xdg.CacheFile("appname/app.cache")
	if err != nil {
		// Treat error.
	}

	fmt.Println("Save cache file at:", cacheFilePath)
}

func ExampleRuntimeFile() {
	runtimeFilePath, err := xdg.RuntimeFile("appname/app.pid")
	if err != nil {
		// Treat error.
	}

	fmt.Println("Save runtime file at:", runtimeFilePath)
}

func ExampleSearchDataFile() {
	dataFilePath, err := xdg.SearchDataFile("appname/app.data")
	if err != nil {
		// The data file could not be found.
	}

	fmt.Println("The data file was found at:", dataFilePath)
}

func ExampleSearchConfigFile() {
	configFilePath, err := xdg.SearchConfigFile("appname/app.yaml")
	if err != nil {
		// The config file could not be found.
	}

	fmt.Println("The config file was found at:", configFilePath)
}

func ExampleSearchStateFile() {
	stateFilePath, err := xdg.SearchStateFile("appname/app.state")
	if err != nil {
		// The state file could not be found.
	}

	fmt.Println("The state file was found at:", stateFilePath)
}

func ExampleSearchCacheFile() {
	cacheFilePath, err := xdg.SearchCacheFile("appname/app.cache")
	if err != nil {
		// The cache file could not be found.
	}

	fmt.Println("The cache file was found at:", cacheFilePath)
}

func ExampleSearchRuntimeFile() {
	runtimeFilePath, err := xdg.SearchRuntimeFile("appname/app.pid")
	if err != nil {
		// The runtime file could not be found.
	}

	fmt.Println("The runtime file was found at:", runtimeFilePath)
}