-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvalues.go
More file actions
40 lines (30 loc) · 703 Bytes
/
Copy pathvalues.go
File metadata and controls
40 lines (30 loc) · 703 Bytes
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 main
type ValuesStruct struct {
key string
value string
InterpretFunc func(string) (string, error)
}
func MakeValueStruct(Key string, Interpret func(string) (string, error)) (*ValuesStruct, error) {
var TS ValuesStruct
var err error
TS.key = Key
TS.InterpretFunc = Interpret
return &TS, err
}
func (o *ValuesStruct) GetKey() string {
return o.key
}
func (o *ValuesStruct) GetValue() string {
return o.value
}
func (o *ValuesStruct) Ingest(Value string) (IsNew bool, err error) {
var NewValue string
NewValue, err = o.InterpretFunc(Value)
if err != nil {
return false, err
} else if NewValue == o.value {
return false, nil
}
o.value = NewValue
return true, err
}