-
Notifications
You must be signed in to change notification settings - Fork 0
/
valueInfo.go
62 lines (48 loc) · 1.28 KB
/
valueInfo.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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
package goconfig
import (
"reflect"
)
// Value generic Config Value type interface
type Value interface {
Name() string
Shorthand() *string
UsageDescription() string
TypeOfValue() reflect.Type
HasAValue() bool
HasADefaultValue() bool
DefaultValueAsString() *string
SetDefaultForConfigFile()
UpdateValueFromConfigFile()
}
// valueInfo common Config value data
type valueInfo struct {
name string
shorthand *string
usageDescription string
typeOfValue reflect.Type
}
// MakeValueInfo make a new ValueInfo structure
func makeValueInfo(name string, shorthand *string, usageDescription string, typeOfValue reflect.Type) *valueInfo {
return &valueInfo{
name: name,
shorthand: shorthand,
usageDescription: usageDescription,
typeOfValue: typeOfValue,
}
}
// Name config/param name of value
func (this *valueInfo) Name() string {
return this.name
}
// Shorthand shorthand param of value, nil if no shorthand available
func (this *valueInfo) Shorthand() *string {
return this.shorthand
}
// UsageDescription description of usage of this value
func (this *valueInfo) UsageDescription() string {
return this.usageDescription
}
// TypeOfValue actual type of value
func (this *valueInfo) TypeOfValue() reflect.Type {
return this.typeOfValue
}