Minor formatting issues

This commit is contained in:
9seconds
2021-03-11 21:50:47 +03:00
parent 5c4536c591
commit c0ab254acf
13 changed files with 16 additions and 50 deletions
+6 -8
View File
@@ -122,23 +122,21 @@ type configRaw struct {
func Parse(rawData []byte) (*Config, error) {
rawConf := &configRaw{}
jsonBuf := &bytes.Buffer{}
conf := &Config{}
jsonEncoder := json.NewEncoder(jsonBuf)
jsonEncoder.SetEscapeHTML(false)
jsonEncoder.SetIndent("", "")
if err := toml.Unmarshal(rawData, rawConf); err != nil {
return nil, fmt.Errorf("cannot parse toml config: %w", err)
}
jsonBuf := &bytes.Buffer{}
jsonEncoder := json.NewEncoder(jsonBuf)
jsonEncoder.SetEscapeHTML(false)
jsonEncoder.SetIndent("", "")
if err := jsonEncoder.Encode(rawConf); err != nil {
return nil, fmt.Errorf("cannot dump into interim format: %w", err)
}
conf := &Config{}
if err := json.NewDecoder(jsonBuf).Decode(conf); err != nil {
return nil, fmt.Errorf("cannot parse final config: %w", err)
}
+3 -1
View File
@@ -5,6 +5,8 @@ import (
"strconv"
)
const typeErrorRateIgnoreLess = 1e-8
type TypeErrorRate struct {
value float64
}
@@ -33,7 +35,7 @@ func (c TypeErrorRate) String() string {
}
func (c TypeErrorRate) Value(defaultValue float64) float64 {
if c.value < 1e-8 {
if c.value < typeErrorRateIgnoreLess {
return defaultValue
}
-1
View File
@@ -15,7 +15,6 @@ func (c *TypeMetricPrefix) UnmarshalText(data []byte) error {
}
prefix := string(data)
if ok, err := regexp.MatchString("^[a-z0-9]+$", prefix); !ok || err != nil {
return fmt.Errorf("incorrect metric prefix: %s", prefix)
}