MCPcopy Create free account
hub / github.com/CovenantSQL/CovenantSQL / GetBool

Method GetBool

cmd/cql-proxy/model/session.go:163–210  ·  view source on GitHub ↗

GetBool returns the bool value with specified key in session object.

(key string)

Source from the content-addressed store, hash-verified

161
162// GetBool returns the bool value with specified key in session object.
163func (s *Session) GetBool(key string) (value bool, exists bool) {
164 rv, exists := s.Get(key)
165 if !exists {
166 return
167 }
168
169 switch v := rv.(type) {
170 case int:
171 value = v != 0
172 case int8:
173 value = v != 0
174 case int16:
175 value = v != 0
176 case int32:
177 value = v != 0
178 case int64:
179 value = v != 0
180 case uint:
181 value = v != 0
182 case uint8:
183 value = v != 0
184 case uint16:
185 value = v != 0
186 case uint32:
187 value = v != 0
188 case uint64:
189 value = v != 0
190 case float32:
191 value = math.Abs(float64(v)) > 0
192 case float64:
193 value = math.Abs(v) > 0
194 case bool:
195 value = v
196 case string:
197 value = len(v) > 0
198 default:
199 rrv := reflect.ValueOf(rv)
200
201 switch rrv.Kind() {
202 case reflect.Array, reflect.Slice, reflect.Map, reflect.Chan:
203 value = rrv.Len() > 0
204 default:
205 exists = false
206 }
207 }
208
209 return
210}
211
212// MustGet returns the value with specified key in session object.
213func (s *Session) MustGet(key string) (value interface{}) {

Callers 1

MustGetBoolMethod · 0.95

Calls 2

GetMethod · 0.95
LenMethod · 0.45

Tested by

no test coverage detected