Go Lang mysql html comments(Go语言mysql html注释)

huangapple go评论90阅读模式
英文:

Go Lang mysql html comments

问题

我想创建一个用于评论的MySQL表单,并在HTML中显示这些评论。我能够使用MySQL包在终端中读取数据,但在html/template引擎上输出方面遇到了困难。欢迎任何指导。

英文:

I would like to create a mysql form for comments and display them as well in html.
I am able to use the MySQL package to read out data in the terminal but am struggling to output on the html/template engine any pointers welcome.

答案1

得分: 0

如果我正确理解你的问题,你想要创建具有用户输入的动态网页。你需要学习一些HTML/CSS来使其看起来漂亮(即使你使用在线模板)。

在生成动态内容方面,Golang提供了一个内置的模板库[http://golang.org/pkg/text/template/]。或者,你也可以尝试其他模板语言,比如Mustache或Handlebars,在Go语言中也有相应的库。

对于收集用户输入,你需要创建一个表单,将数据以POST方式发送到服务器的特定端点。在构建服务器时,你可以研究一下Golang的net/http包,它功能齐全;或者你也可以研究一下Gorilla,这是另一个Go语言库,提供了许多强大的功能,适用于构建更强大的Web应用程序等。

以下是一些你可以查看的资源:

https://golang.org/doc/articles/wiki/
http://www.gorillatoolkit.org/

希望对你有所帮助!

英文:

If I understand your question correctly, you are looking for a way to create dynamic webpages that have user input. You are going to need to learn some HTML/CSS to make it look nice (Even if you do use templates you can find online).

In terms of generating the dynamic content, Golang provides a builtin templating library [http://golang.org/pkg/text/template/]. Or if you like, you can look into other templating languages like Mustache or Handlebars, which have libraries in Go if you want to go that route.

For collecting user input, you're going to want to create a form that POSTs the data to a particular endpoint of your server. In making your server, I would look into both Golang's net/http package, which is fully featured, or you could look into Gorilla, another Go library that has a lot of nice features for making more powerful webapps and such.

A couple resources for you to check out:

https://golang.org/doc/articles/wiki/
http://www.gorillatoolkit.org/

Hope this helps!

答案2

得分: 0

谢谢,我明白了。我会用PHP和HTML来完成这个任务,我只是想尝试将其转换为Go语言,以便从MySQL中提交和渲染出来。我会尝试使用模板引擎创建一个简单的Go表单。

英文:

Thanks I have understanding to do this with php and html I'm just trying to translate over too go Lang for the submitting and rendering out from mysql. I will look at creating a simple go form using the template engine.

huangapple
  • 本文由 发表于 2015年2月15日 03:55:31
  • 转载请务必保留本文链接:https://go.coder-hub.com/28519659.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定