mirror of
https://github.com/ScuroNeko/mtg.git
synced 2026-08-31 21:34:02 +03:00
Minor formatting issues
This commit is contained in:
+6
-8
@@ -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)
|
||||
}
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user