Skip to content

Commit

Permalink
fix time.Sleep
Browse files Browse the repository at this point in the history
  • Loading branch information
visualfc committed Sep 28, 2023
1 parent 9d56c66 commit 5043a29
Show file tree
Hide file tree
Showing 8 changed files with 191 additions and 135 deletions.
212 changes: 109 additions & 103 deletions docs/igop_81719d5a.js → docs/igop_05a250c0.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions docs/igop_05a250c0.js.map

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion docs/igop_81719d5a.js.map

This file was deleted.

4 changes: 2 additions & 2 deletions docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<script src="./static/jquery-linedtextarea.js"></script>
<script src="./static/playground.js"></script>
<script src="./static/playground-embed.js"></script>
<script src="./igop_81719d5a.js"></script>
<script src="./igop_05a250c0.js"></script>
<script>
$(document).ready(function() {
playground({
Expand Down Expand Up @@ -133,7 +133,7 @@ <h1 class="Playground-title">The iGo+ Playground</h1>

<div class="PlayAbout">
<p><b>About the Playground</b></p>
<p>iGo+ v0.14.1 (gop version v1.1.4-0.20230225130145-e37691ce5fea)</p>
<p>iGo+ v0.19.1 (gop version v1.1.4-0.20230926150317-c1262e6211b5)</p>
<p>
The iGo+ Playground is a web service that runs on
<a href="https://goplus.org/">goplus.org</a>'s servers.
Expand Down
6 changes: 3 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ go 1.16

require (
github.com/gopherjs/gopherjs v0.0.0-20210803090616-8f023c250c89 // indirect
github.com/goplus/gop v1.1.4-0.20230225130145-e37691ce5fea
github.com/goplus/igop v0.14.1
github.com/qiniu/x v1.11.9
github.com/goplus/gop v1.1.4-0.20230926150317-c1262e6211b5
github.com/goplus/igop v0.19.1
github.com/qiniu/x v1.13.0
)
80 changes: 63 additions & 17 deletions go.sum

Large diffs are not rendered by default.

4 changes: 3 additions & 1 deletion goplus.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package main

import (
"context"
"fmt"
"go/format"
"go/types"
Expand Down Expand Up @@ -45,6 +46,7 @@ func runCode(src string, enableGoplus bool) (code int, e error) {
return 2, err
}
defer interp.UnsafeRelease()
ctx.RunContext, _ = context.WithCancel(context.TODO())
code, e = ctx.RunInterp(interp, "main", nil)
if pe, ok := e.(igop.PanicError); ok {
e = fmt.Errorf("panic: %w", pe)
Expand All @@ -54,7 +56,7 @@ func runCode(src string, enableGoplus bool) (code int, e error) {

func formatCode(src []byte, enableGoplus bool) ([]byte, error) {
if enableGoplus {
return gopformat.Source(src, "main.gop")
return gopformat.Source(src, false, "main.gop")
} else {
return format.Source(src)
}
Expand Down
18 changes: 10 additions & 8 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,16 @@ func main() {
output = nil
source := args[1].Get("data").Get("body").String()
enabeGop := args[1].Get("data").Get("goplus").Bool()
_, err := runCode(source, enabeGop)
v := js.Global().Get("Object").New()
if err != nil {
v.Set("Error", err.Error())
} else {
v.Set("Body", strings.Join(output, ""))
}
args[1].Get("success").Invoke(v)
go func() {
_, err := runCode(source, enabeGop)
v := js.Global().Get("Object").New()
if err != nil {
v.Set("Error", err.Error())
} else {
v.Set("Body", strings.Join(output, ""))
}
args[1].Get("success").Invoke(v)
}()
case "/fmt":
source := args[1].Get("data").Get("body").String()
enabeGop := args[1].Get("data").Get("goplus").Bool()
Expand Down

0 comments on commit 5043a29

Please sign in to comment.