import ( "testing" . "gopkg.in/check.v1" ) func Test(t *testing.T) { TestingT(t) } type MySuite struct{} var _ = Suite(&MySuite{}) func (s *MySuite) TestMyFunc(c *C) { result := myfunc() c.Assert(result, FitsTypeOf, "") c.Assert(result, Not(Equals), "expected value") c.Assert(result, Not(Equals), "another expected value") }
import ( "os" "testing" . "gopkg.in/check.v1" ) func Test(t *testing.T) { TestingT(t) } type MySuite struct{} var _ = Suite(&MySuite{}) func (s *MySuite) TestMyFunc(c *C) { _, err := os.Open("/nonexistent/file") c.Assert(err, ErrorMatches, "no such file or directory") }In this example, we're testing that an error is returned when trying to open a nonexistent file. We're using the `ErrorMatches` assertion to check that the error message matches the expected string. This package library is used for testing Go code.