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)
| 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. |
| 36 | func 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. |
| 45 | func GenericID(ctx context.Context, uidPattern string) (res string) { |