AsConstantInt returns the value as an constant.Int if possible, along with a flag indicating whether the conversion was possible. The result contains the proper sign as per expr.negative.
()
| 243 | // with a flag indicating whether the conversion was possible. |
| 244 | // The result contains the proper sign as per expr.negative. |
| 245 | func (expr *NumVal) AsConstantInt() (constant.Value, bool) { |
| 246 | v := expr.AsConstantValue() |
| 247 | intVal := constant.ToInt(v) |
| 248 | if intVal.Kind() == constant.Int { |
| 249 | return intVal, true |
| 250 | } |
| 251 | return nil, false |
| 252 | } |
| 253 | |
| 254 | var ( |
| 255 | intLikeTypes = []*types.T{types.Int, types.Oid} |
no test coverage detected