Language: Go
Label: vulnerable
CWE: CWE-362 \u2014 Concurrent Execution using Shared Resource with Improper Synchronization ('Race Condition')
The product contains a code sequence that can run concurrently with other code, and the code sequence requires temporary, exclusive access to a shared resource, but a timing window exists in which the shared resource can be modified by another code sequence that is operating concurrently.

Code:
func (cr *collectionRepo) AddCollection(ctx context.Context, collection *entity.Collection) (err error) {
	id, err := cr.uniqueIDRepo.GenUniqueIDStr(ctx, collection.TableName())
	if err == nil {
		collection.ID = id
		_, err = cr.data.DB.Insert(collection)
		if err != nil {
			return errors.InternalServer(reason.DatabaseError).WithError(err).WithStack()
		}
	}
	return nil
}