Skip to content

Commit 88986f5

Browse files
author
James Stewart
committed
Added error ignoring versions of Int, Float and Bool
1 parent 848ae27 commit 88986f5

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

constant.go

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,12 @@ func (pool *Pool) Int(name string) (val int, err error) {
6464
return
6565
}
6666

67+
// Run Int but ignore errors
68+
func (pool *Pool) IntI(name string) (val int) {
69+
val, _ = pool.Int(name)
70+
return
71+
}
72+
6773
// Returns the value of the constant in the pool named 'name' as a float64.
6874
//
6975
// Follows convention of strconv.ParseFloat (https://golang.org/pkg/strconv/#ParseFloat).
@@ -72,6 +78,12 @@ func (pool *Pool) Float(name string, bitSize int) (val float64, err error) {
7278
return
7379
}
7480

81+
// Run Float but ignore errors
82+
func (pool *Pool) FloatI(name string, bitSize int) (val float64) {
83+
val, _ = pool.Float(name, bitSize)
84+
return
85+
}
86+
7587
// Returns the value of the constant in the pool named 'name' as a boolean.
7688
//
7789
// Follows convention of strconv.ParseBool (https://golang.org/pkg/strconv/#ParseBool).
@@ -80,6 +92,12 @@ func (pool *Pool) Bool(name string) (val bool, err error) {
8092
return
8193
}
8294

95+
// Run Bool but ignore errors
96+
func (pool *Pool) BoolI(name string) (val bool) {
97+
val, _ = pool.Bool(name)
98+
return
99+
}
100+
83101
// Returns if the constant named 'name' is set in the pool.
84102
func (pool *Pool) IsSet(name string) bool {
85103
pool.mutex.RLock()

0 commit comments

Comments
 (0)