You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
then run main.go
// debug: running "go get github.com/gin-gonic/gin" ...
// warning: created files in "C:\Users\Administrator\go\src\github.com\cosmos72\gomacro\imports/thirdparty", recompile gomacro to use it
repl.go:8:7: undefined "gin" in gin.Default <*ast.SelectorExpr>
Error: repl.go:17:1: undefined identifier: Gin
How to resolve this problem?
The text was updated successfully, but these errors were encountered:
Importing third-party packages at runtime is not supported on Windows, because the plugin Go package required for such feature does not (yet) work on Windows.
As a workaround, you can use gomacro inside a virtual machine running a Linux guest operating system.
Some examples of free virtual machine programs are:
WSL i.e. Windows Subsystem for Linux, is preinstalled on Windows 11
cosmos72
changed the title
An error will be reported when using third-party packages
An error will be reported when using third-party packages on Windows
Jan 7, 2024
vm.go file
package main
import (
"github.com/gin-gonic/gin"
)
func Gin() {
r := gin.Default()
r.GET("/ping", func(c *gin.Context) {
c.JSON(200, gin.H{
"message": "pong",
})
})
}
and main.go file
content, err := ioutil.ReadFile("vm.go")
if err != nil {
fmt.Println("read file failed")
}
source := string(content)
src := strings.NewReader(source)
// int gomacro
interp := fast.New()
// check code
if _, err := interp.EvalReader(src); err != nil {
fmt.Println("-------------")
}
interp.ChangePackage("main", "main")
interp.Eval(
Gin()
)then run main.go
// debug: running "go get github.com/gin-gonic/gin" ...
// warning: created files in "C:\Users\Administrator\go\src\github.com\cosmos72\gomacro\imports/thirdparty", recompile gomacro to use it
repl.go:8:7: undefined "gin" in gin.Default <*ast.SelectorExpr>
Error: repl.go:17:1: undefined identifier: Gin
How to resolve this problem?
The text was updated successfully, but these errors were encountered: