MCPcopy Create free account
hub / github.com/sql-machine-learning/sqlflow / Int

Method Int

go/attribute/attribute.go:59–86  ·  view source on GitHub ↗

Int declares an attribute of int-typed in Dictionary d.

(name string, value interface{}, doc string, checker func(int) error)

Source from the content-addressed store, hash-verified

57
58// Int declares an attribute of int-typed in Dictionary d.
59func (d Dictionary) Int(name string, value interface{}, doc string, checker func(int) error) Dictionary {
60 interfaceChecker := func(value interface{}, name string) error {
61 if intValue, ok := value.(int); ok {
62 if checker != nil {
63 if err := checker(intValue); err != nil {
64 return fmt.Errorf("attribute %s error: %s", name, err)
65 }
66 }
67 return nil
68 }
69 return fmt.Errorf("attribute %s must be of type int, but got %T", name, value)
70 }
71
72 if value != nil {
73 err := interfaceChecker(value, name)
74 if err != nil {
75 log.Panicf("default value of attribute %s is invalid, error is: %s", name, err)
76 }
77 }
78
79 d[name] = &description{
80 typ: intType,
81 defaultValue: value,
82 doc: doc,
83 checker: interfaceChecker,
84 }
85 return d
86}
87
88// Float declares an attribute of float32-typed in Dictionary d.
89func (d Dictionary) Float(name string, value interface{}, doc string, checker func(float32) error) Dictionary {

Callers 15

TestSQLFSWriteAndReadFunction · 0.80
TestSQLFSNewHiveWriterFunction · 0.80
TestSQLFSWriterCreateFunction · 0.80
TestSQLFSNewSQLWriterFunction · 0.80
encodePODTypeFunction · 0.80
mainFunction · 0.80
mainFunction · 0.80
TestDictionaryValidateFunction · 0.80

Calls 1

ErrorfMethod · 0.80