Unsafe Type Assertion Without Ok Check
Description
Type assertion without two-value form can panic at runtime.
How to fix
Use the two-value form of type assertion to handle failures gracefully.
```go
result, ok := data.(map[string]interface{})
if !ok {
return errors.New("invalid data type")
}
```
Learn more: https://shoulder.dev/learn/go/cwe-476/unsafe-type-assertion
Applies to
Languages
References
Scan for this issue
Detect with Shoulder CLI
npx @shoulderdev/cli trust --rule=go-unsafe-type-assertion .