File: settings_example_test.go

package info (click to toggle)
golang-github-twpayne-go-xdg 6.0.0-1.1
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 140 kB
  • sloc: makefile: 2
file content (40 lines) | stat: -rw-r--r-- 724 bytes parent folder | download
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
package xdg_test

import (
	"fmt"

	xdg "github.com/twpayne/go-xdg/v6"
)

func ExampleSetting_Check() {
	setting := xdg.Setting{
		Property: xdg.DefaultWebBrowserProperty,
	}
	isGoogleChrome, err := setting.Check("google-chrome.desktop")
	if err != nil {
		panic(err)
	}
	fmt.Println(isGoogleChrome)
}

func ExampleSetting_Get() {
	setting := xdg.Setting{
		Property:    xdg.DefaultURLSchemeHandlerProperty,
		SubProperty: "http",
	}
	value, err := setting.Get()
	if err != nil {
		panic(err)
	}
	fmt.Println(value)
}

func ExampleSetting_Set() {
	setting := xdg.Setting{
		Property:    xdg.DefaultURLSchemeHandlerProperty,
		SubProperty: "http",
	}
	if err := setting.Set("firefox.desktop"); err != nil {
		panic(err)
	}
}