Closed ganeshmaharaj closed 3 years ago
I had a play around with this this morning and I still can't get it to work, I mean ccloudvm create still fails with go1.16. I think this commit is probably fine but we need something else as well to get things working. At this stage I think we need to stop using the GOPATH to locate the workloads. Perhaps we can copy them to a location that the systemd service can find when one does a ccloudvm create. We already look in ~/.ccloudvm/workloads so we could just copy them in there. I need a bit more time to fix this.
Perhaps we can copy them to a location that the systemd service can find when one does a ccloudvm create.
Of course the problem is, how can we copy them if we can't find them? Perhaps we could just embed them into the binary. This would add an extra step when adding a workload.
@ganeshmaharaj In the meantime you can get things to work by copying the workload you want into ~/.ccloudvm/workloads. If you do this the code that uses the GOPATH which no longer works, won't get called.
@markdryan with this patch and setting GO111MODULE to be auto go env -w GO111MODULE=auto
I was able to build and run a VM and find the right files. A simple program as below shows the issue.
package main
import (
"fmt"
"go/build"
)
func main() {
bld := build.Default
p, err := bld.Import("github.com/intel/ccloudvm", "", build.FindOnly)
fmt.Printf("%+v :: %+v\n", p, err)
}
The output of the test is
gmmaha@altair <> test % go run main.go
&{Dir:/home/gmmaha/go/src/github.com/intel/ccloudvm Name: ImportComment: Doc: ImportPath:github.com/intel/ccloudvm Root:/home/gmmaha/go SrcRoot:/home/gmmaha/go/src PkgRoot:/home/gmmaha/go/pkg PkgTargetRoot:/home/gmmaha/go/pkg/linux_amd64 BinDir:/home/gmmaha/go/bin Goroot:false PkgObj:/home/gmmaha/go/pkg/linux_amd64/github.com/intel/ccloudvm.a AllTags:[] ConflictDir: BinaryOnly:false GoFiles:[] CgoFiles:[] IgnoredGoFiles:[] InvalidGoFiles:[] IgnoredOtherFiles:[] CFiles:[] CXXFiles:[] MFiles:[] HFiles:[] FFiles:[] SFiles:[] SwigFiles:[] SwigCXXFiles:[] SysoFiles:[] CgoCFLAGS:[] CgoCPPFLAGS:[] CgoCXXFLAGS:[] CgoFFLAGS:[] CgoLDFLAGS:[] CgoPkgConfig:[] TestGoFiles:[] XTestGoFiles:[] Imports:[] ImportPos:map[] TestImports:[] TestImportPos:map[] XTestImports:[] XTestImportPos:map[] EmbedPatterns:[] EmbedPatternPos:map[] TestEmbedPatterns:[] TestEmbedPatternPos:map[] XTestEmbedPatterns:[] XTestEmbedPatternPos:map[]} :: <nil>
gmmaha@altair <> test % GO111MODULE=on go run main.go
&{Dir: Name: ImportComment: Doc: ImportPath:github.com/intel/ccloudvm Root: SrcRoot: PkgRoot: PkgTargetRoot: BinDir: Goroot:false PkgObj: AllTags:[] ConflictDir: BinaryOnly:false GoFiles:[] CgoFiles:[] IgnoredGoFiles:[] InvalidGoFiles:[] IgnoredOtherFiles:[] CFiles:[] CXXFiles:[] MFiles:[] HFiles:[] FFiles:[] SFiles:[] SwigFiles:[] SwigCXXFiles:[] SysoFiles:[] CgoCFLAGS:[] CgoCPPFLAGS:[] CgoCXXFLAGS:[] CgoFFLAGS:[] CgoLDFLAGS:[] CgoPkgConfig:[] TestGoFiles:[] XTestGoFiles:[] Imports:[] ImportPos:map[] TestImports:[] TestImportPos:map[] XTestImports:[] XTestImportPos:map[] EmbedPatterns:[] EmbedPatternPos:map[] TestEmbedPatterns:[] TestEmbedPatternPos:map[] XTestEmbedPatterns:[] XTestEmbedPatternPos:map[]} :: no required module provides package github.com/intel/ccloudvm: go.mod file not found in current directory or any parent directory; see 'go help modules'
I am still not sure why go will not fall back to the default src path for searching. I also tried switching over to golang.org/x/tools/packages
to see if that would work. I will keep you posted on what I find.
I am still not sure why go will not fall back to the default src path for searching. I also tried switching over to golang.org/x/tools/packages to see if that would work. I will keep you posted on what I find.
I think that code is just inherently fragile and we should just remove it.
I can merge this MR now as I have confirm that it does build.
Although maybe I'll wait until I have a full fix. I can push the updates to this PR I think. The README will need to be updated as well.
Coverage decreased (-0.02%) to 68.891% when pulling 701f218c5db584e972485b020c893524e4db611e on ganeshmaharaj:go-mod into e5228d32c7ed22bc67fcf59b1eb80c23108aa9e6 on intel:master.