mirror of
https://github.com/lus/pasty.git
synced 2023-08-10 21:13:09 +03:00
21 lines
389 B
Go
21 lines
389 B
Go
package storage
|
|
|
|
import (
|
|
"github.com/lus/pasty/internal/config"
|
|
"github.com/lus/pasty/internal/utils"
|
|
)
|
|
|
|
// AcquireID generates a new unique ID
|
|
func AcquireID() (string, error) {
|
|
for {
|
|
id := utils.RandomString(config.Current.IDCharacters, config.Current.IDLength)
|
|
paste, err := Current.Get(id)
|
|
if err != nil {
|
|
return "", err
|
|
}
|
|
if paste == nil {
|
|
return id, nil
|
|
}
|
|
}
|
|
}
|