go模板的示例测试因导入而失败,并且未使用:“ testing”

As far as I can tell I'm following structure needed for 'go test' flawlessly. I don't see a discrepancy from tests I could run in other packages. 'go build' works fine. I'm getting

./HelloTemplate_test.go:3: imported and not used: "testing" ./HelloTemplate_test.go:5: undefined: Testing in Testing.T

What am I missing?

HelloTemplate.go

package templateprint

import "testing"

func TestRunTempl(t *Testing.T) {
    sweaters := Inventory{"wool", 17}
    tmpl := "{{.Count}} items are made of {{.Material}}"
    err := RunTempl(tmpl, sweaters)
    if err != nil {
        t.Error("Template failed ")
    }
}

HelloTemplate_test.go

package templateprint

import (
    "os"
    "text/template"
)

type Inventory struct {
    Material string
    Count    uint
}

func RunTempl(templ string, inv Inventory) error {
    tmpl, err := template.New("test").Parse(templ)
    if err != nil {
        return (err)
    }
    err = tmpl.Execute(os.Stdout, inv)
    if err != nil {
        return (err)
    }
    return nil
}

You are using an incorrect type in your test function:

// tesintg.T, not Testing.T
// T is a type defined in testing module
func TestRunTempl(t *testing.T) { 
    sweaters := Inventory{"wool", 17}
    tmpl := "{{.Count}} items are made of {{.Material}}"
    err := RunTempl(tmpl, sweaters)
    if err != nil {
        t.Error("Template failed ")
    }
}