-
Notifications
You must be signed in to change notification settings - Fork 21
/
number.go
69 lines (48 loc) · 1.51 KB
/
number.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
63
64
65
66
67
68
69
package cwl
import (
"fmt"
//"github.com/mitchellh/mapstructure"
"reflect"
"strconv"
)
//type String struct {
// CWLType_Impl `yaml:",inline" json:",inline" bson:",inline" mapstructure:",squash"`
// //Class CWLType_Type `yaml:"class,omitempty" json:"class,omitempty" bson:"class,omitempty"`
// Value string `yaml:"value,omitempty" json:"value,omitempty" bson:"value,omitempty"`
//}
type Number string
func (s *Number) GetClass() string { return string(CWL_string) } // for CWL_object
func (s *Number) GetType() CWLType_Type { return CWL_string }
func (s *Number) String() string { return string(*s) }
func (s *Number) GetId() string { return "" }
func (s *Number) SetId(i string) {}
func (s *Number) Is_CWL_minimal() {}
func NewNumberFromstring(value string) (s *Number) {
var s_nptr Number
s_nptr = Number(value)
s = &s_nptr
return
}
func NewNumber(id string, value string) (s *Number) {
_ = id
return NewNumberFromstring(value)
}
func NewNumberFromInterface(id string, native interface{}) (s *Number, err error) {
_ = id
switch native.(type) {
case string:
real_string, ok := native.(string)
if !ok {
err = fmt.Errorf("(NewStringFromInterface) Cannot create string")
return
}
s = NewNumberFromstring(real_string)
case float64:
real_float64, _ := native.(float64)
real_string := strconv.FormatFloat(real_float64, 'f', 6, 64)
s = NewNumberFromstring(real_string)
default:
err = fmt.Errorf("(NewNumberFromInterface) type %s unknown", reflect.TypeOf(native))
}
return
}