--------------------------------------------------------------------------- Binary detection --------------------------------------------------------------------------- IsBinary returns true if data contains NUL bytes or is not valid UTF-8.
(data []byte)
| 80 | |
| 81 | // IsBinary returns true if data contains NUL bytes or is not valid UTF-8. |
| 82 | func IsBinary(data []byte) bool { |
| 83 | if len(data) == 0 { |
| 84 | return false |
| 85 | } |
| 86 | // Check for NUL bytes (common in binaries, never in text). |
| 87 | for _, b := range data { |
| 88 | if b == 0 { |
| 89 | return true |
| 90 | } |
| 91 | } |
| 92 | return !utf8.Valid(data) |
| 93 | } |
| 94 | |
| 95 | // --------------------------------------------------------------------------- |
| 96 | // Agent profile matching |
no outgoing calls