goplus / gop

The Go+ programming language is designed for engineering, STEM education, and data science. Our vision is to enable everyone to become a builder of the digital world.
https://goplus.org
Apache License 2.0
8.91k stars 546 forks source link

拿eql做web视图层是最好不过了,不过示例代码都报错,不知道是不是用法不对 #158

Closed ghost closed 6 years ago

ghost commented 6 years ago

工具链和qlang库应该都是最新的

go version go1.10.3 windows/386 git clone https://github.com/qiniu/qlang.git $GOPATH/src/qlang.io

package main

import (
    qlang "qlang.io/cl"
    "qlang.io/lib/eqlang"
)

func main() {
    ql := qlang.New()
    eql := eqlang.New(ql)
    eql.Execute("Hello, <%= strings.ToUpper(name) %>!\n", "", "")
}

报错信息

# main
src\main\main.go:10:19: cannot use ql (type *qlang.Compiler) as type eqlang.qlang in argument to eqlang.New:
    *qlang.Compiler does not implement eqlang.qlang (missing GetVar method)
ghost commented 6 years ago

我找到正确姿势了

package main

import (
    "qlang.io/cl/qlang"
    _ "qlang.io/lib/builtin"
    "qlang.io/lib/eqlang"
)

func main() {
    ql := qlang.New()
    eql := eqlang.New(ql)
    eql.Execute("Hello, <%= strings.ToUpper(name) %>!\n", "", "")
}