MCPcopy
hub / github.com/go-git/go-git / IsBinary

Function IsBinary

utils/binary/read.go:171–195  ·  view source on GitHub ↗

IsBinary detects if data is a binary value based on: http://git.kernel.org/cgit/git/git.git/tree/xdiff-interface.c?id=HEAD#n198

(r io.Reader)

Source from the content-addressed store, hash-verified

169// IsBinary detects if data is a binary value based on:
170// http://git.kernel.org/cgit/git/git.git/tree/xdiff-interface.c?id=HEAD#n198
171func IsBinary(r io.Reader) (bool, error) {
172 reader := bufio.NewReader(r)
173 c := 0
174 for {
175 if c == sniffLen {
176 break
177 }
178
179 b, err := reader.ReadByte()
180 if err == io.EOF {
181 break
182 }
183 if err != nil {
184 return false, err
185 }
186
187 if b == byte(0) {
188 return true, nil
189 }
190
191 c++
192 }
193
194 return false, nil
195}

Callers 2

IsBinaryMethod · 0.92
TestIsBinaryMethod · 0.85

Calls 1

ReadByteMethod · 0.80

Tested by 1

TestIsBinaryMethod · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…