MCPcopy
hub / github.com/cortexlabs/cortex / Float64FromFile

Function Float64FromFile

pkg/lib/configreader/float64.go:117–143  ·  view source on GitHub ↗
(filePath string, v *Float64Validation)

Source from the content-addressed store, hash-verified

115}
116
117func Float64FromFile(filePath string, v *Float64Validation) (float64, error) {
118 if !files.IsFile(filePath) {
119 val, err := ValidateFloat64Missing(v)
120 if err != nil {
121 return 0, errors.Wrap(err, filePath)
122 }
123 return val, nil
124 }
125
126 valStr, err := files.ReadFile(filePath)
127 if err != nil {
128 return 0, err
129 }
130 if len(valStr) == 0 {
131 val, err := ValidateFloat64Missing(v)
132 if err != nil {
133 return 0, errors.Wrap(err, filePath)
134 }
135 return val, nil
136 }
137
138 val, err := Float64FromStr(valStr, v)
139 if err != nil {
140 return 0, errors.Wrap(err, filePath)
141 }
142 return val, nil
143}
144
145func Float64FromEnvOrFile(envVarName string, filePath string, v *Float64Validation) (float64, error) {
146 valStr := ReadEnvVar(envVarName)

Callers 2

Float64FromEnvOrFileFunction · 0.85
MustFloat64FromFileFunction · 0.85

Calls 5

IsFileFunction · 0.92
WrapFunction · 0.92
ReadFileFunction · 0.92
ValidateFloat64MissingFunction · 0.85
Float64FromStrFunction · 0.85

Tested by

no test coverage detected