From ce68d341900a377d121b925cf3454b5af31fa79d Mon Sep 17 00:00:00 2001 From: Dmitri Shuralyov Date: Sun, 8 May 2016 14:40:13 -0700 Subject: [PATCH] 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. --- compiler/natives/syscall/syscall.go | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/compiler/natives/syscall/syscall.go b/compiler/natives/syscall/syscall.go index ec205dcda..a269ea717 100644 --- a/compiler/natives/syscall/syscall.go +++ b/compiler/natives/syscall/syscall.go @@ -3,7 +3,6 @@ package syscall import ( - "bytes" "unsafe" "github.com/gopherjs/gopherjs/js" @@ -37,7 +36,7 @@ func printToConsole(b []byte) { lineBuffer = append(lineBuffer, b...) for { - i := bytes.IndexByte(lineBuffer, '\n') + i := indexByte(lineBuffer, '\n') if i == -1 { break } @@ -49,3 +48,13 @@ func printToConsole(b []byte) { func use(p unsafe.Pointer) { // no-op } + +// indexByte is copied from bytes package to avoid importing it (since the real syscall package doesn't). +func indexByte(s []byte, c byte) int { + for i, b := range s { + if b == c { + return i + } + } + return -1 +}