New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
debug go-app in nowasm #946
Comments
I guess you mean it limits your development using Go-App? Could you give an example what is problematic for you to get right? Are you trying to combine "normal" JavaScript libraries with Go-App? We generally do not have problems with debugging and bug fixing for our steadily growing applications that are from using WASM / Go-App. Sure, a step debugger that links back to the Go source would be nice, but using our print logging with stack traces works very well for us and writing smaller example applications before using new functionalities in a larger project makes things also more manageable. P.S.: If you need some private Methods, just check out the Go-App code and use a "go.work" file in the project. Then you can add all the debugging you need. This possibility is one of the reasons why we use Go in the company. |
I use the following codes in unit test. The code is mostly effective in logical testing. I think that it will be nice if a go side DOM is supported in go-app nowasm mode. package tester
import (
"fmt"
"github.com/maxence-charriere/go-app/v9/pkg/app"
)
func CValue(v any) Value {
return value{
Value: app.ValueOf(v),
value: v,
methods: make(map[any]func(args ...any) app.Value),
}
}
type (
Value interface {
app.Value
Methods(map[string]func(args ...any) app.Value) Value
}
value struct {
app.Value
value any
methods map[any]func(args ...any) app.Value
}
)
func (v value) Methods(m map[string]func(args ...any) app.Value) Value {
for k, f := range m {
v.methods[k] = f
}
return v
}
func (v value) Call(m string, args ...any) app.Value {
if f, ok := v.methods[m]; ok {
return f(args...)
}
fmt.Println("unknown function ", m)
return CValue(v.value)
}
func (v value) IsNull() bool {
return v.value == nil
} This is logic test. func TestFundamentals(t *testing.T) {
v := Fundamentals(0)
canvas := tester.CValue(map[any]any{
"width": 100,
"height": 100,
}).Methods(map[string]func(args ...any) app.Value{
"getContext": func(args ...any) app.Value {
//name := args[0].(string)
//attrs := args[1]
return tester.CValue(map[any]any{}).
Methods(map[string]func(args ...any) app.Value{
"getParameter": func(args ...any) app.Value {
return tester.CValue(map[any]any{})
},
"getExtension": func(args ...any) app.Value {
return tester.CValue(map[any]any{})
},
"createTexture": func(args ...any) app.Value {
return tester.CValue(map[any]any{})
},
"bindTexture": func(args ...any) app.Value {
return tester.CValue(map[any]any{})
},
"texParameteri": func(args ...any) app.Value {
return tester.CValue(map[any]any{})
},
})
},
"addEventListener": func(args ...any) app.Value {
return tester.CValue(map[any]any{})
},
"removeEventListener": func(args ...any) app.Value {
return tester.CValue(map[any]any{})
},
})
v.Run(canvas)
} |
What is 'go-app nowasm mode'? Do you mean using the Go-App declarative HTML generation? Isn't this a totally bloated way to create a standard HTML web server? |
Go.work is a good idea.Thank you @oderwat very much. |
The difficulty in debugging wasm has limited the development of go-app. Here are a few suggestions for debugging wasm in nowasm mode. I'm not sure if they are feasible or not.
The text was updated successfully, but these errors were encountered: