Skip to content

vikrambiwal/golang-soap-example

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 

Repository files navigation

simple example

package main

import (
"os"
"text/template"
)

type Todo struct {
  Name string
  Description string
}

func main() {
  td := Todo{"Test templates", "Let's test a template to see the magic."}

  t, err := template.New("todos").Parse("You have a task named \"{{ .Name}}\" with description: \"{{ .Description}}\"")
  if err != nil {
    panic(err)
  }
  err = t.Execute(os.Stdout, td)
  if err != nil {
    panic(err)
  }
}

loop example

package main

import (
	"html/template"
	"os"
)

type entry struct {
	Name string
	Done bool
}

type ToDo struct {
	User string
	List []entry
}

func main() {
	paths := []string{
		"./loop_todo.tmpl",
	}

	todos := ToDo{
		User: "vkkk",
		List: []entry{
			entry{
				Name: "one",
				Done: true,
			},
			entry{
				Name: "two",
				Done: true,
			},
		},
	}

	t := template.Must(template.ParseFiles(paths...))
	err := t.Execute(os.Stdout, todos)
	if err != nil {
		panic(err)
	}
}

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages