MCPcopy Create free account
hub / github.com/go-git/go-git / IsBinary

Function IsBinary

utils/binary/read.go:156–180  ·  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

154// IsBinary detects if data is a binary value based on:
155// http://git.kernel.org/cgit/git/git.git/tree/xdiff-interface.c?id=HEAD#n198
156func IsBinary(r io.Reader) (bool, error) {
157 reader := bufio.NewReader(r)
158 c := 0
159 for {
160 if c == sniffLen {
161 break
162 }
163
164 b, err := reader.ReadByte()
165 if err == io.EOF {
166 break
167 }
168 if err != nil {
169 return false, err
170 }
171
172 if b == byte(0) {
173 return true, nil
174 }
175
176 c++
177 }
178
179 return false, nil
180}

Callers 2

IsBinaryMethod · 0.92
TestIsBinaryMethod · 0.85

Calls 1

ReadByteMethod · 0.80

Tested by 1

TestIsBinaryMethod · 0.68