On Mon, Aug 30, 2021 at 12:01 PM Victor Medrano <vmedr...@gmail.com> wrote:
>
> I.m new to go, and working with a web  aplicación I need to pass a tray of 
> struct to the template.
> something like this
>
> type Month struct {
> Mname string
> Color string
> Id int
> }
>
>
> type Year struct {
> Yname, Color string
> Selected bool
> }
>
> type Data struct {
> Years []*Year
> Months []*Month
> }
> but I haven found the way to fill data Data structure from mysql.
> I came to this group because I found it on a book.

Just to clarify, you want to first create an object of Data struct
type by querying data from a MySQL database and then passing the
object to a template where you will render a HTML page using the data?

If so, for the first step, you will use the database/sql package
(along with the mysql driver) to first create the struct, then execute
the template by passing the object to it. For templates, you may find
https://astaxie.gitbooks.io/build-web-application-with-golang/content/en/07.4.html
and https://echorand.me/posts/golang-templates/ useful.

>
> so thanks.
>
> Victor
>
> --
> You received this message because you are subscribed to the Google Groups 
> "golang-nuts" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to golang-nuts+unsubscr...@googlegroups.com.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/golang-nuts/ce221a92-ffec-48b5-b635-a0f29ffe932an%40googlegroups.com.

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/CANODV3kXFcqa94XCeAzDEZ5XMu_y9BZ3J4P9vB99KVTexA8jHQ%40mail.gmail.com.

Reply via email to