dongxi3859
2018-03-22 04:37
浏览 175
已采纳

在Golang中运行JavaScript代码

I need some javascript code inside go code.

package main

import (
    "fmt"
    "net/http"
)
func work(w http.ResponseWriter, r *http.Request){
    fmt.Printf("<script>console.log('javascript working')</script>")

}

func main() {
    http.HandleFunc("/", work)
    http.ListenAndServe(":4000", nil)
}

Running it in browser and see browser's console window there is nothing to see. How do I run javascript code in go code? Because using ajax with golang it is difficult.

  • 写回答
  • 好问题 提建议
  • 追加酬金
  • 关注问题
  • 邀请回答

1条回答 默认 最新

相关推荐 更多相似问题