Skip to content

Commit ce68d34

Browse files
committed
compiler/natives/syscall: Don't import bytes package.
The real syscall package doesn't import bytes. This keeps the order in which stdlib packages must be built in for GopherJS consistent with the real standard library. Helps #388.
1 parent d5d8eb5 commit ce68d34

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

compiler/natives/syscall/syscall.go

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
package syscall
44

55
import (
6-
"bytes"
76
"unsafe"
87

98
"github.com/gopherjs/gopherjs/js"
@@ -37,7 +36,7 @@ func printToConsole(b []byte) {
3736

3837
lineBuffer = append(lineBuffer, b...)
3938
for {
40-
i := bytes.IndexByte(lineBuffer, '\n')
39+
i := indexByte(lineBuffer, '\n')
4140
if i == -1 {
4241
break
4342
}
@@ -49,3 +48,13 @@ func printToConsole(b []byte) {
4948
func use(p unsafe.Pointer) {
5049
// no-op
5150
}
51+
52+
// indexByte is copied from bytes package to avoid importing it (since the real syscall package doesn't).
53+
func indexByte(s []byte, c byte) int {
54+
for i, b := range s {
55+
if b == c {
56+
return i
57+
}
58+
}
59+
return -1
60+
}

0 commit comments

Comments
 (0)