(data []byte)
| 1102 | |
| 1103 | |
| 1104 | func IsBinaryContent(data []byte) bool { |
| 1105 | if len(data) == 0 { |
| 1106 | return false |
| 1107 | } |
| 1108 | sampleSize := min(8192, len(data)) |
| 1109 | sample := data[:sampleSize] |
| 1110 | |
| 1111 | nullCount := 0 |
| 1112 | for _, b := range sample { |
| 1113 | if b == 0 { |
| 1114 | nullCount++ |
| 1115 | } |
| 1116 | } |
| 1117 | if float64(nullCount)/float64(len(sample)) > 0.01 { |
| 1118 | return true |
| 1119 | } |
| 1120 | |
| 1121 | if !utf8.Valid(sample) { |
| 1122 | return true |
| 1123 | } |
| 1124 | |
| 1125 | return false |
| 1126 | } |
| 1127 | |
| 1128 | func FormatRelativeTime(modTime time.Time) string { |
| 1129 | now := time.Now() |
no outgoing calls
no test coverage detected