File: type.go

package info (click to toggle)
golang-github-rkoesters-xdg 0.0~git20181125.edd15b8-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 220 kB
  • sloc: makefile: 5
file content (45 lines) | stat: -rw-r--r-- 778 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
41
42
43
44
45
package desktop

// Type is the type of desktop entry.
type Type uint8

// These are the possible desktop entry types.
const (
	None Type = iota // No type. This is bad.
	Application
	Link
	Directory
	Unknown // Any unknown type.
)

// ParseType converts the given string s into a Type.
func ParseType(s string) Type {
	switch s {
	case None.String():
		return None
	case Application.String():
		return Application
	case Link.String():
		return Link
	case Directory.String():
		return Directory
	default:
		return Unknown
	}
}

// String returns the Type as a string.
func (t Type) String() string {
	switch t {
	case None:
		return ""
	case Application:
		return "Application"
	case Link:
		return "Link"
	case Directory:
		return "Directory"
	default:
		return "Unknown"
	}
}