MCPcopy Create free account
hub / github.com/TheThingsNetwork/lorawan-stack / ID

Function ID

pkg/unique/unique.go:36–42  ·  view source on GitHub ↗

ID returns the unique identifier of the specified identifiers. This function panics if the resulting identifier is invalid. The reason for panicking is that taking the unique identifier of a nil or zero value may result in unexpected and potentially harmful behavior.

(ctx context.Context, id ttnpb.IDStringer)

Source from the content-addressed store, hash-verified

34// The reason for panicking is that taking the unique identifier of a nil or
35// zero value may result in unexpected and potentially harmful behavior.
36func ID(ctx context.Context, id ttnpb.IDStringer) (res string) {
37 res = id.IDString()
38 if res == "" || strings.HasPrefix(res, ".") || strings.HasSuffix(res, ".") {
39 panic(fmt.Errorf("failed to determine unique ID: the primary identifier is invalid"))
40 }
41 return res
42}
43
44// GenericID returns a generic selector identifier for an entity.
45func GenericID(ctx context.Context, uidPattern string) (res string) {

Callers 15

TestMuxFunction · 0.92
runTestSubscriptionsFunction · 0.92
newEntityReqFunction · 0.92
TestRequireFunction · 0.92
RequireApplicationFunction · 0.92
RequireClientFunction · 0.92
RequireGatewayFunction · 0.92
RequireOrganizationFunction · 0.92
RequireUserFunction · 0.92
RequireAnyFunction · 0.92
TestContextFunction · 0.92
ListApplicationFunction · 0.92

Calls 3

IDStringMethod · 0.65
ErrorfMethod · 0.65
HasPrefixMethod · 0.45

Tested by 15

TestMuxFunction · 0.74
runTestSubscriptionsFunction · 0.74
TestRequireFunction · 0.74
TestContextFunction · 0.74
TestForwarderFunction · 0.74
TestGetAppSKeyFunction · 0.74
TestJoinServerCleanupFunction · 0.74
TestDeviceRegistryGetFunction · 0.74
TestDeviceRegistrySetFunction · 0.74
TestDeviceRegistryDeleteFunction · 0.74