On 09/28/2017 08:12 AM, gocss wrote:
> go test
> # testmain
> /tmp/go-build584983468/csspc/alog/_test/_testmain.go:30:22: cannot use
> alog.ExampleNew (type func(*testing.T)) as type func() in field value
> FAIL    csspc/alog [build failed]
> 
> code follows:
> package alog
> 
> import (
>     "fmt"
>     "testing"
> )
> 
> func ExampleNew(t *testing.T) {
>     alog, err := New("alog:")
>     if err != nil {
>         t.Fatal(err)
>     }
>     fmt.Println(LogFlagsDefault)
>     alog.Debug.SetFlags(0)
>     // Output: 123
> }
> 

ExampleNew() shouldn't take a *testing.T.

Its signature should be just:

func ExampleNew() {
  ...
}

I get it. It is probably habit to add testing.T to tests. :)

-ayan

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to