magiconair / properties

Java properties scanner for Go
BSD 2-Clause "Simplified" License
323 stars 77 forks source link

GetInt should return default val instead of panic #75

Open FarmerChillax opened 6 months ago

FarmerChillax commented 6 months ago

In GetInt function should return default value instead of panic

// GetInt parses the expanded value as an int if the key exists.
// If key does not exist or the value cannot be parsed the default
// value is returned. If the value does not fit into an int the
// function panics with an out of range error.
func (p *Properties) GetInt(key string, def int) int {
    v, err := p.getInt64(key)
    if err != nil {
        return def
    }
    return intRangeCheck(key, v)
}

more: https://github.com/magiconair/properties/blob/c9a06e8f8f0164e4e16c0d5c4793cbed4ac90264/rangecheck.go#L19