Move target code to dep.go

This commit is contained in:
morganamilo 2018-10-10 22:13:00 +01:00
parent 2034575a76
commit 5109fc6250
No known key found for this signature in database
GPG key ID: 6FE9E7996B0B082E
2 changed files with 31 additions and 31 deletions

31
dep.go
View file

@ -40,6 +40,37 @@ func (q providers) Swap(i, j int) {
q.Pkgs[i], q.Pkgs[j] = q.Pkgs[j], q.Pkgs[i]
}
type target struct {
Db string
Name string
Mod string
Version string
}
func toTarget(pkg string) target {
db, dep := splitDbFromName(pkg)
name, mod, version := splitDep(dep)
return target{
db,
name,
mod,
version,
}
}
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()
}
func splitDep(dep string) (string, string, string) {
mod := ""

View file

@ -9,37 +9,6 @@ import (
rpc "github.com/mikkeloscar/aur"
)
type target struct {
Db string
Name string
Mod string
Version string
}
func toTarget(pkg string) target {
db, dep := splitDbFromName(pkg)
name, mod, version := splitDep(dep)
return target{
db,
name,
mod,
version,
}
}
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()
}
type depPool struct {
Targets []target
Explicit stringSet