Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Add GoString for Value #82

Open
Open
Assignees

Description

This came up recently when I was trying to test some code that calls the stats package like this: eng.Add("foo", uint64(1)).

// test
handler := &statstest.Handler{}
eng := stats.NewEngine("test", handler)
runCode(eng)
assert.Equal(t, []stats.Measure{
{
 Name: "test.foo",
 Fields: []stats.Field{
 stats.MakeField("", 1, stats.Counter),
 },
 Tags: []stats.Tag{},
 }
}, handler.Measures())

This test failed with a cryptic error: assert.go:24: ! [0].Fields[0].Value.typ: 2 != 3.

The error was that my code is using uint, but the test is using an `int.

If the value type had a GoString method, the error could have been more obvious.

Metadata

Metadata

Labels

No labels
No labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      AltStyle によって変換されたページ (->オリジナル) /