24 lines
451 B
Go
24 lines
451 B
Go
package projects
|
|
|
|
import "errors"
|
|
|
|
func (c *Cache) addAlias(alias string, projectID int) error {
|
|
if c.GetAliasByName(alias) != nil {
|
|
return errors.New("Failed to add alias, already exists")
|
|
}
|
|
|
|
c.Aliases = append(c.Aliases,
|
|
&ProjectAlias{
|
|
Alias: alias,
|
|
ProjectID: projectID,
|
|
})
|
|
|
|
return nil
|
|
}
|
|
|
|
func (c *Cache) AddAlias(alias string, projectID int) error {
|
|
c.lock.Lock()
|
|
defer c.lock.Unlock()
|
|
return c.addAlias(alias, projectID)
|
|
}
|