pkgdash/models/mapping.go
Vasiliy Tolstov 4be12c653b intermediate merge
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2023-08-11 21:45:08 +03:00

45 lines
775 B
Go

package models
import (
pb "go.unistack.org/unistack-org/pkgdash/proto"
)
type ListPackage []*Package
func (l ListPackage) Decode() []*pb.Package {
result := make([]*pb.Package, 0, len(l))
for i := range l {
temp := &pb.Package{
Id: l[i].ID,
Name: l[i].Name,
Url: l[i].URL,
Modules: l[i].Modules,
Issues: l[i].Issues,
Comments: l[i].Comments,
}
result = append(result, temp)
}
return result
}
type ListModule []*Module
func (l ListModule) Decode() []*pb.Module {
result := make([]*pb.Module, 0, len(l))
for i := range l {
temp := &pb.Module{
Id: l[i].ID,
Name: l[i].Name,
Version: l[i].Version,
LastVersion: l[i].LastVersion,
}
result = append(result, temp)
}
return result
}