From d3866ddc65789d1dbdbb90e4bedafcf0bfc65c87 Mon Sep 17 00:00:00 2001 From: Rob Pike Date: Mon, 20 Dec 2010 13:36:47 -0800 Subject: [PATCH] template: fix trivial bug: integers are not "empty" Fixes #1357. R=adg, gri CC=golang-dev https://golang.org/cl/3809041 --- src/pkg/template/template.go | 2 +- src/pkg/template/template_test.go | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/pkg/template/template.go b/src/pkg/template/template.go index be5c59aed88..aa050776165 100644 --- a/src/pkg/template/template.go +++ b/src/pkg/template/template.go @@ -673,7 +673,7 @@ func empty(v reflect.Value) bool { case *reflect.SliceValue: return v.Len() == 0 } - return true + return false } // Look up a variable or method, up through the parent if necessary. diff --git a/src/pkg/template/template_test.go b/src/pkg/template/template_test.go index 1c491e34ae6..4075444a812 100644 --- a/src/pkg/template/template_test.go +++ b/src/pkg/template/template_test.go @@ -197,6 +197,12 @@ var tests = []*Test{ out: " Header\n", }, + &Test{ + in: "{.section integer}{@}{.end}", + + out: "77", + }, + // Repeated &Test{ in: "{.section pdata }\n" +