Skip to content

Commit

Permalink
Add StateFile and SearchStateFile examples
Browse files Browse the repository at this point in the history
  • Loading branch information
adrg committed Jan 10, 2021
1 parent fb3d5d2 commit c523bf8
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,8 @@ func main() {
## Contributing

Contributions in the form of pull requests, issues or just general feedback,
are always welcome. See [CONTRIBUTING.MD](CONTRIBUTING.md).
are always welcome.
See [CONTRIBUTING.MD](CONTRIBUTING.md).

**Contributors**:
[adrg](https://github.com/adrg),
Expand Down
18 changes: 18 additions & 0 deletions example_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,15 @@ func ExampleRuntimeFile() {
fmt.Println("Save runtime file at:", runtimeFilePath)
}

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

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

func ExampleSearchDataFile() {
dataFilePath, err := xdg.SearchDataFile("appname/app.data")
if err != nil {
Expand Down Expand Up @@ -77,3 +86,12 @@ func ExampleSearchRuntimeFile() {

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

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)
}

0 comments on commit c523bf8

Please sign in to comment.