fix(Compile): Fixed error "<module> is not in GOROOT"

This commit is contained in:
netbenix 2022-08-27 19:08:57 +02:00
parent cbbe886dbb
commit 39a136dc50
4 changed files with 35 additions and 30 deletions

View file

@ -1,34 +1,33 @@
package ProtoHandler
import (
proto "lotus-pm.net/proto"
"lpm-cli/Lotus"
proto "lpm-cli/Proto/lpm/go"
)
type Package struct{
type Package struct {
PackageMetadata PackageMetadata
Register Lotus.Registry
Register Lotus.Registry
}
type PackageMetadata struct {
Publisher string
Name string
Version string
Description string
Tags []string
Labels map[string]string
PackageSize uint64
Checksums Checksums
Platform string
Publisher string
Name string
Version string
Description string
Tags []string
Labels map[string]string
PackageSize uint64
Checksums Checksums
Platform string
Architecture string
Dependencies []Dependency
}
func fillDependencies(protoDependency []*proto.Dependency) []Dependency {
dependencies := make([]Dependency, len(protoDependency))
for i, dep := range protoDependency{
for i, dep := range protoDependency {
dependencies[i].ID = dep.GetId()
dependencies[i].VersionFilter = dep.GetVersionFilter()
}
@ -39,12 +38,16 @@ func fillDependencies(protoDependency []*proto.Dependency) []Dependency {
func fillChecksums(checksum []*proto.Checksum) Checksums {
checksums := Checksums{}
for i, chk := range checksum{
switch checksum[i].Algorithm{
case 0: checksums.MD5 = chk.Checksum
case 1: checksums.SHA1 = chk.Checksum
case 2: checksums.SHA256 = chk.Checksum
case 3: checksums.SHA512 = chk.Checksum
for i, chk := range checksum {
switch checksum[i].Algorithm {
case 0:
checksums.MD5 = chk.Checksum
case 1:
checksums.SHA1 = chk.Checksum
case 2:
checksums.SHA256 = chk.Checksum
case 3:
checksums.SHA512 = chk.Checksum
}
}
@ -63,4 +66,4 @@ func (pkgMeta *PackageMetadata) FillMetadata(protoData *proto.PackageMetadata) {
pkgMeta.Platform = protoData.Platform
pkgMeta.Architecture = protoData.Architecture
pkgMeta.Dependencies = fillDependencies(protoData.GetDependencies())
}
}

View file

@ -3,8 +3,8 @@ package ProtoHandler
import (
"golang.org/x/net/context"
"google.golang.org/grpc"
proto "lotus-pm.net/proto"
"lpm-cli/Lotus"
proto "lpm-cli/Proto/lpm/go"
"time"
)
@ -22,25 +22,24 @@ func (protoWrap ProtoWrapper) CreateConnection(address string) *grpc.ClientConn
func (protoWrap ProtoWrapper) CreateRegistryClient(conn *grpc.ClientConn) (proto.LpmRegistryClient, context.Context, context.CancelFunc) {
lrc := proto.NewLpmRegistryClient(conn)
ctx, cancel := context.WithTimeout(context.Background(), time.Second * 10)
ctx, cancel := context.WithTimeout(context.Background(), time.Second*10)
return lrc, ctx, cancel
}
func (protoWrap ProtoWrapper) ParsePackages(res *proto.SearchResponse, reg Lotus.Registry) []Package {
var packages []Package
for _, pkg := range res.GetPackages() {
var tmpMeta PackageMetadata
tmpMeta.FillMetadata(pkg)
packages = append(packages, Package {
packages = append(packages, Package{
PackageMetadata: tmpMeta,
Register: Lotus.Registry{
Register: reg.Register,
Address: reg.Address,
Address: reg.Address,
},
})
}
return packages
}
}