Created
August 12, 2016 13:00
-
-
Save kenjiskywalker/95b5ef60ac2ae5c2f07946c49c5a9a04 to your computer and use it in GitHub Desktop.
Goでtemplateをつかう ref: http://qiita.com/kenjiskywalker/items/088b4489f6979bbf8b9e
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"bytes" | |
"fmt" | |
"html/template" | |
) | |
func main() { | |
type PersonalData struct { | |
Name string | |
Mail string | |
} | |
p := PersonalData{"おれです", "[email protected]"} | |
var b bytes.Buffer | |
tpl, _ := template.ParseFiles("personal_data.tmpl") | |
tpl.Execute(&b, p) | |
fmt.Println(b.String()) | |
// Name: おれです | |
// Mail: [email protected] | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Name: {{ .Name }} | |
Mail: {{ .Mail }} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment