mirror of
https://github.com/Jguer/yay.git
synced 2024-11-07 09:37:22 +01:00
35 lines
562 B
Go
35 lines
562 B
Go
|
package dep
|
||
|
|
||
|
import "github.com/Jguer/yay/v11/pkg/text"
|
||
|
|
||
|
type Target struct {
|
||
|
DB string
|
||
|
Name string
|
||
|
Mod string
|
||
|
Version string
|
||
|
}
|
||
|
|
||
|
func ToTarget(pkg string) Target {
|
||
|
dbName, depString := text.SplitDBFromName(pkg)
|
||
|
name, mod, depVersion := splitDep(depString)
|
||
|
|
||
|
return Target{
|
||
|
DB: dbName,
|
||
|
Name: name,
|
||
|
Mod: mod,
|
||
|
Version: depVersion,
|
||
|
}
|
||
|
}
|
||
|
|
||
|
func (t Target) DepString() string {
|
||
|
return t.Name + t.Mod + t.Version
|
||
|
}
|
||
|
|
||
|
func (t Target) String() string {
|
||
|
if t.DB != "" {
|
||
|
return t.DB + "/" + t.DepString()
|
||
|
}
|
||
|
|
||
|
return t.DepString()
|
||
|
}
|