Standard library / text/template

text/template.Template.Name()

Returns the name assigned to this template. Expected stdout: 'greet\n'.

Formal Syntax & Structure

go syntaxgo
func (t *Template) Name() string

Return Value

string

Returns the name assigned to this template.

Working Example

Example Snippetgo
package main
import (  "fmt"  "text/template")
func main() { t := template.Must(template.New("greet").Parse("Hello {{.}}")); fmt.Println(t.Name()) }
Go Reference