Skip to content

Commit 794e970

Browse files
committed
Clarify note to Resource
Model it after time.Time
1 parent 038712b commit 794e970

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

sdk/resource/resource.go

+7-5
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,13 @@ import (
2222
// (`*resource.Resource`). The `nil` value is equivalent to an empty
2323
// Resource.
2424
//
25-
// While Resource is comparable, its comparison should not be relied on when
26-
// checking equality. The [Resource.Equal] method should be used to check
27-
// equality between two resources and the [attribute.Distinct] returned from
28-
// [Resource.Equivalent] should be used for map keys instead. No guantee of the
29-
// correctness of direct comparisons is provided.
25+
// Note that the Go == operator compares not just the resource attributes but
26+
// also all other internals of the Resource type. Therefore, Resource values
27+
// should not be used as map or database keys. In general, the [Resource.Equal]
28+
// method should be used instead of direct comparison with ==, since that
29+
// method ensures the correct comparison of resource attributes, and the
30+
// [attribute.Distinct] returned from [Resource.Equivalent] should be used for
31+
// map and database keys instead.
3032
type Resource struct {
3133
attrs attribute.Set
3234
schemaURL string

0 commit comments

Comments
 (0)