-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
52 lines (49 loc) · 1.1 KB
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
package main
import (
"fmt"
"io"
"github.com/of-night/ipfs-keystone-test"
)
func main() {
fmt.Println("Calling C function ipfs_keystone from Go...")
fmt.Println("test Processing file")
reader := ipfsKeystoneTest.Ipfs_keystone_test(1, "aestest.txt")
defer reader.Close()
buf := make([]byte, 16)
for {
n, err := io.ReadFull(io.Reader(&reader), buf)
fmt.Println("Read is ok")
if err != nil {
if err != io.ErrUnexpectedEOF {
fmt.Println("tt1 ", err)
err = io.EOF
fmt.Println("ttt ", err)
fmt.Println("Read %d bytes: ", n)
for i := 0; i < n; i++ {
fmt.Printf("%02X", buf[i])
if (i+1)%16 == 0 || i == n-1 {
fmt.Println()
}
}
return
}
fmt.Println("t1t ", err)
fmt.Println("Read %d bytes: ", n)
for i := 0; i < n; i++ {
fmt.Printf("%02X", buf[i])
if (i+1)%16 == 0 || i == n-1 {
fmt.Println()
}
}
return
}
fmt.Println("Read %d bytes: ", n)
for i := 0; i < n; i++ {
fmt.Printf("%02X", buf[i])
if (i+1)%16 == 0 || i == n-1 {
fmt.Println()
}
}
}
return
}